export and capture rest endpoint output for metrics calculation

29 views
Skip to first unread message

Ketan Talreja

unread,
Apr 30, 2020, 11:04:23 AM4/30/20
to Prometheus Users
Hi All, 

I have a use-case where I need to collect rest endpoint output metric i.e. let's say the output/response of rest endpoint is some value which I need to export to prometheus for calculating how many times the endpoint returned the 'x' value 

For example - 
GET /<endpoint>/users - return list of users which need to be exported to prometheus for metric calculation 

Question - 

Does anyone know how would I capture the endpoint results values and export to prometheus? Do I need to consider implementing custom exporter to do this job? If yes, could you help in providing some samples. 

Thank you,

Ketan

Julius Volz

unread,
May 1, 2020, 5:25:29 AM5/1/20
to Ketan Talreja, Prometheus Users
Yes, it sounds like you probably will need to build a custom exporter for that to transform your custom REST format into the Prometheus metrics format.

You can see a huge list of example exporters at https://prometheus.io/docs/instrumenting/exporters/, and general guidelines for writing exporters at https://prometheus.io/docs/instrumenting/writing_exporters/.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/fa5a3aa6-5ec4-49d3-9058-5a8583fd183b%40googlegroups.com.

Julius Volz

unread,
May 1, 2020, 5:27:54 AM5/1/20
to Ketan Talreja, Prometheus Users
Btw., googling turned up https://github.com/project-sunbird/prometheus-jsonpath-exporter - I don't know this one at all, but if your REST endpoint serves JSON, it looks like you could use this existing exporter to convert the JSON format to Prometheus metrics via some configuration rules.

Julius Volz

unread,
May 1, 2020, 5:28:32 AM5/1/20
to Ketan Talreja, Prometheus Users

Julius Volz

unread,
May 1, 2020, 5:29:50 AM5/1/20
to Ketan Talreja, Prometheus Users
Oh, apparently we also have a JSON exporter in prometheus-community: https://github.com/prometheus-community/json_exporter

Ketan Talreja

unread,
May 1, 2020, 8:33:14 AM5/1/20
to Prometheus Users
Sure, thanks Julius, This is very helpful and I will try json_exporter too. 

Thank you!
Ketan
To unsubscribe from this group and stop receiving emails from it, send an email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages