magenta-aps / check_prometheus_metric

Nagios plugin for alerting on Prometheus query results.
Apache License 2.0
46 stars 10 forks source link

Allow extra get / post data to be passed through #1

Open thinkl33t opened 4 years ago

thinkl33t commented 4 years ago

We're trying to grab prometheus data from gitlab - this requires a token adding to the URL:

https://gitlab.your.company/-/metrics?token=TOKENTOKENTOKEN

When using this script, we've found it doesn't appear to work specifying the above as a url, possibly because the url given has a path appended to it in the check_prometheus_metric script.

We tried passing the key through as extra data:

./check_prometheus_metric -H 'https://gitlab.your.company/-/metrics' -q 'http_requests_total{method="get"}' -w '0:40000' -c '0:42000' -n 'total http requests' -p -C "-d '{ \"token\": \"TOKENTOKENTOKEN\" }'"

But still got an error - presumably you can't have two data entries passed to curl.

Skeen commented 4 years ago

Hi @thinkl33t

Sorry about not getting back to you sooner. It appears my watch of the repository was disabled.

Try using multiple -C calls, so the command line becomes:

... -n 'total http requests' -p -C "-d" -C "{\"token\": \"TOKENTOKENTOKEN\"}"

For Icinga2, you might find this relevant for your CheckCommand definition.