Promtheus custom exporter using prometheus python client

2,033 views
Skip to first unread message

kavya KULSHRESHTHA

unread,
Dec 27, 2017, 4:40:38 AM12/27/17
to Prometheus Users
Hi,

I have created an exporter for checking health of various applications using API exposed by these applications.
Workflow:
  1.  A csv file is created with details about various application's host/ports/API URL etc.
  2. This custom exporter reads the file at a certain interval and gets the health check return code

Problem: Whenever there is a new config added, new metrics are exposed by the exporter. But in case a config is updated in CSV, the exporter along with new health check gives the result for the old data as well.


Gauge Definition


  • g = Gauge('healthcheck', 'Metrics generated by Health Check exporter', [
  •        'customer',
  •        'application',
  •        'component',
  •        'version',
  •        'description',
  •        'source_host_name',
  •        'target_host_name',
  •        'target_host_port',
  •        'environment'
  • ])

Gauge set value:

  1.     g.labels(
  2.        chs['customer'],
  3.        chs['application'],
  4.        chs['container'],
  5.        chs['version'],
  6.        chs['description'],
  7.        chs['nehost'],
  8.        chs['hostname'],
  9.        chs['port'],
  10.        chs['environment']
       
    ).set(value)
Enter code here...

Regards,

Kavya K

Brian Brazil

unread,
Dec 27, 2017, 4:47:00 AM12/27/17
to kavya KULSHRESHTHA, Prometheus Users
On 27 December 2017 at 09:40, kavya KULSHRESHTHA <kavya.kul...@gmail.com> wrote:
Hi,

I have created an exporter for checking health of various applications using API exposed by these applications.
Workflow:
  1.  A csv file is created with details about various application's host/ports/API URL etc.
  2. This custom exporter reads the file at a certain interval and gets the health check return code

Problem: Whenever there is a new config added, new metrics are exposed by the exporter. But in case a config is updated in CSV, the exporter along with new health check gives the result for the old data as well.

Use a custom collector that scrapes the data on each Prometheus scrape: https://github.com/prometheus/client_python#custom-collectors

Have you considered the blackbox exporter for this?

 

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/ab39f4f8-d02f-474e-b1c7-86a23353787e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

kavya KULSHRESHTHA

unread,
Dec 27, 2017, 6:11:38 AM12/27/17
to Prometheus Users
Thanks, I will try using this.
Yes, I read about blackbox exporter but there is a requirement that in case certain heath check fails its response JSON body has to be read and then metrics needs to be created from them.

By the way, does blackbox exporter provides flexibility to pass different headers for a single probe? As we have multiple applications which needs different headers.


Regards,
Kavya K
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.



--

Brian Brazil

unread,
Dec 27, 2017, 6:54:12 AM12/27/17
to kavya KULSHRESHTHA, Prometheus Users


On 27 Dec 2017 11:11, "kavya KULSHRESHTHA" <kavya.kul...@gmail.com> wrote:
Thanks, I will try using this.
Yes, I read about blackbox exporter but there is a requirement that in case certain heath check fails its response JSON body has to be read and then metrics needs to be created from them.

By the way, does blackbox exporter provides flexibility to pass different headers for a single probe? As we have multiple applications which needs different headers.

You can set headers per module.


Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/e0ae727e-05c9-4dc0-bd3a-4512fdea75fd%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages