How to monitor authenticated API endpoint using Blackbox exporter and Prometheus

1,940 views
Skip to first unread message

Santanu Mishra

unread,
Jun 7, 2022, 9:27:44 AM6/7/22
to Prometheus Users
Hi Team,
      I have a requirement to monitor the authenticated API endpoint using Balckbox Exporter and Prometheus. I am unable to figure out the solution. Please help!
The Blackbox exporter gives 200 success message for APIs without authentication though. 
I am putting the yml files for blackbox exporter and Prometheus.

blackbox.yml
Screen Shot 2022-06-06 at 12.03.19 PM.png

prometheus.yml

Screen Shot 2022-06-06 at 12.07.41 PM.png

Note: I tried with http_2xx and it didn't help either.

Thanks!
Message has been deleted

Brian Candler

unread,
Jun 7, 2022, 4:46:53 PM6/7/22
to Prometheus Users
What you've put in prometheus.yml under 'targets' is wrong.  Blackbox_exporter does not run external programs such as curl.  The target should be a URL, not a command line.

I suggest you forget about prometheus.yml to start with, and get blackbox_exporter running by itself - and you can hit blackbox_exporter with curl.  If you do this, then you can add debug=true to get more information:

curl -vg 'host.docker.internal:9115/probe?module=http_post_2xx&target=https://asdf.b.cloud:443/whatever&debug=true'

Only after you've got that working, then you can move on to configuring prometheus.

However, what's clear from the above is you've put nothing in blackbox.yml to configure authentication. For the settings you need, see https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md#http_probe
Assuming that you can connect to the API directly using -u username:password, then what you're looking for is "basic auth":

modules:
  http_2xx_with_auth:
    prober: http
    http:
      basic_auth:
        username: my_username
        password: my_password
      ... other settings as required (e.g. method: POST, headers, body etc ...
Reply all
Reply to author
Forward
0 new messages