How to monitor 3xx redirection in server and configure alert manager for the same in prometheus.

43 views
Skip to first unread message

Pooja Chauhan

unread,
Mar 13, 2020, 2:53:31 AM3/13/20
to Prometheus Users
I have to monitor few server which has 302 redirection,i want to configure these to Prometheus with alert when it goes down.Please suggest how to do it as I am facing many challenges.


Aditya Nageswar

unread,
Mar 13, 2020, 3:53:28 AM3/13/20
to Prometheus Users
How are the metrics being fetched?
Is the data present in Prometheus?

If the response code is recorded in the labels, a simple regex can do the job.

For Eg:

server_redirections{response_code~="3.*"} > 10

The above will send an alert if 3xx count is greater 10 and rule can be changed accordingly.

Brian Candler

unread,
Mar 13, 2020, 4:45:15 AM3/13/20
to Prometheus Users
Are you monitoring with blackbox_exporter?  You can configure it to gives success on result code 302 and give an error on any other response.  Then alert on probe_success != 1

Pooja Chauhan

unread,
Mar 16, 2020, 5:01:07 AM3/16/20
to Prometheus Users
yes ,I am using black-box exporter . what is meant when probe_success == 2/3 value comes? 

Brian Candler

unread,
Mar 16, 2020, 7:44:55 AM3/16/20
to Prometheus Users
You should only see probe_success=0 or probe_success=1.

To make result_code 302 return probe_success=1 and everything else return probe_success=0, you configure a "module" in blackbox_exporter appropriately.

modules:
  http_must_redirect:
    valid_status_codes: [302]
    method: GET
 
If you want to check the response to see that the redirect sends you to a particular URL, then use fail_if_header_not_matches: on the Location header.
Reply all
Reply to author
Forward
0 new messages