Monitor result of a bash command or shell script using Prometheus

11/1/2021

My requirement is to monitor the helpdesk system of the company which is running inside the Kubernetes cluster, for example, URL https://xyz.zendesk.com

They provide their API set to monitor this efficiently.

We can easily check the status using curl

$ curl -s "https://status.zendesk.com/api/components/support?domain=xyz.zendesk.com" | jq '.active_incidents'
[]

The above output means success status according to zendesk documentation.

Now the main part is, the company uses Prometheus to monitor everything.

How to have Prometheus check the success status from the output of this curl command?.

I did some research already and found somewhat related threads here and using pushgateway

Are they applicable to my requirement or going in the wrong route?

-- vjwilson
docker
kubernetes
prometheus

1 Answer

11/1/2021

What you probably (!?) want is something that:

  1. Provides an HTTP(s) (e.g. /metrics) endpoint
  2. Producing metrics in Prometheus' exposition format
  3. From Zendesk's API

NOTE curl only gives you #3

There are some examples of solutions that appear to meet the requirements but none is from Zendesk:

https://www.google.com/search?q=%22zendesk%22+prometheus+exporter

There are >2 other lists of Prometheus exporters (neither contains Zendesk):

I recommend you contact Zendesk and ask whether there's a Prometheus Exporter already. It's surprising to not find one.

It is straightforward to write a Prometheus Exporter. Prometheus Client libraries and Zendesk API client are available and preferred. While it's possible, bash is probably sub-optimal.

If all you want to do is GET that static endpoint, get a 200 response code and confirm that the body is [], you may be able to use Prometheus Blackbox exporter

NOTE Logging and monitoring tools often provide a higher-level tool that provides something analogous to a "universal translator", facilitating translation from 3rd-party systems' native logging|monitoring formats into some canonical form using config rather than code. Although in the logging space, fluentd is an example. To my knowledge, there is no such tool for Prometheus but I sense that there's an opportunity for someone to create one.

-- DazWilkin
Source: StackOverflow