Blackbox exporter - add Header dynamically after First requests to server

49 views
Skip to first unread message

Alexander Wilke

unread,
Jan 10, 2024, 1:46:02 PM1/10/24
to Prometheus Users
Hello,
i Connect with Blackbox exporter and http POST to an API.
I Connect with body_file which contains credentials to Login and some other Parameters.

The API answers with two Header
sid: XYZ
uid: ABC

For further actions in the API I have to add These dynamic Headers to each requests.

Is it possible with Blackbox exporter to read this content and proceed and add IT to the next body_file?


Brian Candler

unread,
Jan 10, 2024, 2:17:17 PM1/10/24
to Prometheus Users
No. For a linked sequence of HTTP exchanges, you'll need to write your own test script. You could, for example, write a Python script to do what you want, and emit some metrics when it's done. (Carrying state from one request to another can be done using the requests Session object)

Then there are several ways you can run that script:

- you could run it from cron, e.g. once per minute, write the results into a temporary file, then move that file into a directory for the node_exporter textfile collector to pick up (or any random HTTP server that can serve static content). This is particularly useful if the check is slow or expensive.

- exporter_exporter has an exec method which can run your script immediately in response to a scrape

- you could run a simple webserver within Python, and scrape it directly. Then you've just written a custom exporter.

- if you already written a Nagios plugin which implements your check logic, then you can run it under nrped with nrpe_exporter. However I don't recommend that (it's very crusty, using an old mode of SSL that current versions of openssl don't support)
Reply all
Reply to author
Forward
0 new messages