Collecting metrics from C app

1,063 views
Skip to first unread message

ris...@gmail.com

unread,
Mar 3, 2015, 5:44:24 AM3/3/15
to prometheus...@googlegroups.com
Hi,
I am interestedin using Prometheus to collect metrics from a few custom C apps. What is the recommended approach? All the client libraries are for dynamic languages and I can't figure out with the documentation how it should be done. Is a embedded server necessary? Seems like a heavy lift for c/c++/Java apps.

Brian Brazil

unread,
Mar 3, 2015, 6:05:34 AM3/3/15
to ris...@gmail.com, prometheus-developers
On 3 March 2015 at 10:44, <ris...@gmail.com> wrote:
Hi,
I am interestedin using Prometheus to collect metrics from a few custom C apps. What is the recommended approach?

There's no C client yet, so main approach would be to write one.

 
All the client libraries are for dynamic languages and I can't figure out with the documentation how it should be done. Is a embedded server necessary? Seems like a heavy lift for c/c++/Java apps.

The embedded http server is the suggested way of doing things. From my experience, it has little effect on system performance and works for the the existing Java client.

Brian
 

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julius Volz

unread,
Mar 3, 2015, 7:52:43 AM3/3/15
to Brian Brazil, ris...@gmail.com, prometheus-developers
Just to add: if you really can't add an HTTP server, then you can also push to the Pushgateway and let Prometheus scrapes that: http://prometheus.io/docs/instrumenting/pushing/

Keep in mind that Prometheus works best with pull, and pushing is best left as a last resort for things behind a firewall or batch jobs.

Some explanation:

The pushgateway acts as a single-value caching proxy (i.e. it doesn't keep any history, only the last value). When Prometheus scrapes it, it will assign the timestamp from the scrape to the scraped samples, not the timestamp from the push. It's also possible to set client-side manual timestamps in the push, but you have to be a bit careful with that, and the expectation is that the pushing client should regularly send updates then.

If a job that pushes dies or goes away, the values it pushed need to be manually cleaned up from the pushgateway, and Prometheus won't automatically detect that they're no longer needed.

ris...@gmail.com

unread,
Mar 3, 2015, 9:27:40 AM3/3/15
to prometheus...@googlegroups.com, brian....@boxever.com, ris...@gmail.com
Never really looked into embedding a http server into C but I probably don't need to: handing http GET requests from Prometheus and responding with a well-formed http response using the Prometheus text format is probably only a couple hundred lines of C.

Thanks.

Brian Brazil

unread,
Mar 3, 2015, 9:34:18 AM3/3/15
to ris...@gmail.com, prometheus-developers
You may want to look at http://www.gnu.org/software/libmicrohttpd/ if you don't already have a http server in mind.
It's LGPL.

Brian
 

Thanks.

Reply all
Reply to author
Forward
0 new messages