Prometheus Blackbox-Exporter fail_if_body_matches_regexp not working

205 views
Skip to first unread message

Alexandra Hilzinger

unread,
Nov 18, 2021, 8:23:02 AM11/18/21
to Prometheus Users
Hi, it might be a stupid question but I can't get fail_if_body_matches_regexp to run. 

Briefly what I want to achieve. I have a redirect set up, when a web page returns error code 503, it redirects to a maintenance web page.Now when I query the http probe results with the blackboxexporter, there is also when the maintenance page is displayed a return code of 200 (which is also correct the maintenance page is working). How can I make it so that when the maintenance page is displayed I don't get the return code 200? 
I have the following configuration at the moment. But it is not clear to me why this does not work. 

    modules:
      http_2xx:
        http:
          no_follow_redirects: false
          preferred_ip_protocol: ip4
          fail_if_body_matches_regexp:
          - "The page is temporarily unavailable"
          valid_http_versions:
          - HTTP/1.1
          - HTTP/2
          valid_status_codes: []
        prober: http
        timeout: 5s
      tcp_connect:
        prober: tcp

If someone knows what is wrong, I would appreciate any help. 
Also sorry for my bad english, it is not my native language. I hope you understand what I want to do. 

Greetings  Alexandra

Brian Candler

unread,
Nov 18, 2021, 9:04:07 AM11/18/21
to Prometheus Users
"The page is temporarily unavailable" may be a message generated by your browser, not the remote server. Check using curl:

In any case: a much better way to check for this condition is to check on the status code, not on the message body.

But I don't understand what you mean when you say "I have a redirect set up, when a web page returns error code 503, it redirects to a maintenance web page".  A redirect is a 3xx status code, by definition.  So it can't be *both* returning 503 *and* returning a redirect at the same time.

Alexandra Hilzinger

unread,
Nov 18, 2021, 11:10:31 AM11/18/21
to Prometheus Users
I managed to solve the problem myself...it was just a dumb mistake, I forgot to actually map the config-file. As soon as I did that it worked just as expected....but thank you very much for your help :)
Reply all
Reply to author
Forward
0 new messages