Getting Data In

Instrumenting metrics in a C++ application

MisterBoy
Engager

Hi, I'm brand new to Splunk coming from a background using Prometheus metrics.

I've been reading through Splunk docs but I'm struggling to get some of the basics down. I was looking at https://docs.splunk.com/Documentation/Splunk/8.1.1/Metrics/GetMetricsInOther which talks about HTTP/JSON but is this saying my application would offer an HTTP endpoint for polling/pulling, or my application needs to call an endpoint on the Splunk server?

I've always worked using the poll paradigm before and one thing I can't seem to find are examples of how to instrument metrics in my own code. In particular, 90% of our system (which comprises dozens of modules) is written in C++ and I would really love to see a code example of instrumenting and exposing a metric (e.g. number of calls to MyMethod() in C++, for consumption by Splunk Enterprise.

Many thanks for any help.

 

Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Your application needs to send data to an HTTP endpoint on a Splunk server.

How to instrument your code perhaps is a better question for StackOverflow. One approach, however, is to call a function whenever something you want to measure happens. That function will increment the appropriate static variable. A separate thread initiates a timer and, when the timer pops, collects the measurement variables into a JSON string, sends it to Splunk, then resets the variables. Implementation details are left as an exercise for the reader.

---
If this reply helps you, Karma would be appreciated.

MisterBoy
Engager

Thanks @richgalloway . Does Splunk provide any libraries for widely used languages? Measurement code needs to be very performant and thread-safe so this is not a trivial task, especially if either Splunk or the community has already created such things that are tried and tested.

And Splunk is exclusively a push-based metrics store, just to be absolutely double-sure on that?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Splunk provides a few SDKs: Java, Python, and C#, if memory serves.  C++ is not on the list.

Splunk is exclusively push-based, with a few exceptions that don't apply here (like querying an SQL database).

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...