blackbox_exporter applies the provided regular expression against the
entire body.

This means in particular that if your body is something like ['O', 'K',
'\n'] (O, followed by K, followed by a carriage return), the regular
expression '^OK$' WILL NOT match because '$' anchors it to the end of the
body, not the end of the line.

In order to match lines, not the whole body, you have to write '(?m:^OK$)'.
This will match 'OK' on a line by its own, but not say NOK on a line by its
own. It will also match on a body like 'Something\nOK\nsomething\n'.

I hope this helps,

Marcelo

On Mon, Mar 22, 2021 at 1:54 PM Yagyansh S. Kumar <[email protected]>
wrote:

> Hi Julius,
>
> Using the expression "^OK$" leads to the failure of all the checks for
> which response was OK. This seems weird to me. Ideally, should have worked.
> Any more workarounds or suggestions to achieve this?
>
> On Mon, Mar 22, 2021 at 9:38 PM Yagyansh S. Kumar <
> [email protected]> wrote:
>
>> Thanks, Julius.
>>
>> On Mon, Mar 22, 2021 at 6:50 PM Julius Volz <[email protected]>
>> wrote:
>>
>>> Hi,
>>>
>>> the Blackbox exporter doesn't do full-string matching for these regexes,
>>> but substring matching, so it also matches if the body contains "OK"
>>> anywhere (which is true for "NOK"). Try '^OK$` instead?
>>>
>>> Also, in case your HTTP endpoint returns a status code other than 2xx,
>>> you will have to set the "valid_status_codes" list to the allowed ones (it
>>> defaults to 2xx).
>>>
>>> Regards,
>>> Julius
>>>
>>> On Mon, Mar 22, 2021 at 9:03 AM [email protected] <
>>> [email protected]> wrote:
>>>
>>>> Can someone please help! I am confused here.
>>>>
>>>> On Monday, March 15, 2021 at 12:20:03 PM UTC+5:30 [email protected]
>>>> wrote:
>>>>
>>>>>
>>>>> Hi. I am using blackbox_exporter version 0.18.0 and I am using http
>>>>> prober to check if the response by my URL is "OK" or not. Below is the
>>>>> configuration of the module.
>>>>>
>>>>>   http_healthcheck_ok:
>>>>>     prober: http
>>>>>     timeout: 10s
>>>>>     http:
>>>>>       valid_http_versions: ["HTTP/1.1", "HTTP/2.0", "HTTP/1.0"]
>>>>>      * fail_if_body_not_matches_regexp: ['OK']*
>>>>>       method: GET
>>>>>       no_follow_redirects: false
>>>>>       fail_if_ssl: false
>>>>>       fail_if_not_ssl: false
>>>>>       tls_config:
>>>>>         insecure_skip_verify: true
>>>>>       preferred_ip_protocol: "ip4"
>>>>>
>>>>> So, whenever my URL throws anything other than OK in the response
>>>>> body, probe_failed_due_to_regex should 1 right? But when the URL was
>>>>> throwing *NOK *as the response body, probe_failed_due_to_regex was
>>>>> still 0, whereas it should be 1. Am I missing something here?
>>>>>
>>>>> Thanks in advance!
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Prometheus Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/prometheus-users/e6db4504-48e6-4ad9-a640-1e63dc6e472en%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/prometheus-users/e6db4504-48e6-4ad9-a640-1e63dc6e472en%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
>>>
>>> --
>>> Julius Volz
>>> PromLabs - promlabs.com
>>>
>>
>>
>> --
>> Thanks & Regards
>> Yagyansh S. Kumar
>> DevOps Engineer, Dailyhunt - Bangalore
>> 8696078312,8209496395
>>
>
>
> --
> Thanks & Regards
> Yagyansh S. Kumar
> DevOps Engineer, Dailyhunt - Bangalore
> 8696078312,8209496395
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/CAFGi5vArLJ1m-2Huui6P50N6HFdwztTDw7m0-bC8fGhiV9q0fg%40mail.gmail.com
> <https://groups.google.com/d/msgid/prometheus-users/CAFGi5vArLJ1m-2Huui6P50N6HFdwztTDw7m0-bC8fGhiV9q0fg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Marcelo Magallón

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CABiJYgYsoPRsy%3DYskNG5VErhv9%3DtYNqh%3DJ47JJsGC2vHaMZRbw%40mail.gmail.com.

Reply via email to