Blackbox Operator Check Response

2,128 views
Skip to first unread message

jain....@gmail.com

unread,
Jul 19, 2017, 5:57:01 PM7/19/17
to Prometheus Users
Hi,

I am trying to use prometheus with blackbox-exporter to create a smart pinger which pings a url and checks the response with some logic. Is there a way to do that in blackbox-exporter?

Thanks

Conor Broderick

unread,
Jul 19, 2017, 6:02:20 PM7/19/17
to jain....@gmail.com, Prometheus Users
Can you provide us with more details as to what you're trying to achieve here? 

Setting up the blackbox exporter to send a http probe to a url and check the response in Prometheus is fairly straightforward.  

I'm guessing you're interested in sending an alert or something based on the probe response? 

--
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 prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/f7dcb747-af10-4c13-a96f-b12fb8f0fa3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Nehil Jain

unread,
Jul 19, 2017, 6:10:44 PM7/19/17
to Conor Broderick, Prometheus Users
Oh, Sorry about that.

here is an example pinger I want to set

Ping url http://free.currencyconverterapi.com/api/v3/convert?q=SAR_USD&compact=ultra and check is the reponse is 200 and the body has SAR_USD keyword in it. 

Thanks a ton for looking into this.

On Wed, 19 Jul 2017 at 18:02 Conor Broderick <conor.b...@robustperception.io> wrote:
Can you provide us with more details as to what you're trying to achieve here? 

Setting up the blackbox exporter to send a http probe to a url and check the response in Prometheus is fairly straightforward.  

I'm guessing you're interested in sending an alert or something based on the probe response? 

On 19 July 2017 at 22:57, <jain....@gmail.com> wrote:
Hi,

I am trying to use prometheus with blackbox-exporter to create a smart pinger which pings a url and checks the response with some logic. Is there a way to do that in blackbox-exporter?

Thanks

--
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 prometheus-use...@googlegroups.com.

To post to this group, send email to promethe...@googlegroups.com.



--

Conor Broderick

unread,
Jul 19, 2017, 6:45:10 PM7/19/17
to Nehil Jain, Prometheus Users
Run blackbox exporter with the default configuration.  

In the following URL I've tested probing your desired target. 


At http://localhost:9115/metric I can see the following metric: 
probe_http_status_code 200 
Now lets configure and run Prometheus to scrape the blackbox exporter to get the probe_http_status_code metric into Prometheus itself.

scrape_configs:
  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_2xx]  # Look for a HTTP 200 response.
    static_configs:
      - targets:
        - http://free.currencyconverterapi.com/api/v3/convert?q=SAR_USD&compact=ultra
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9115  # Blackbox exporter.

Running Prometheus now, you should be able to see probe_http_status_code in the expression browser.

What we've done here essentially is set the Blackbox exporter to probe your given target via http. We're then scraping the metrics the Blackbox exporter produces with Prometheus.

I will check out how to get the response body tomorrow as it's quite late here but the above should sort out your answer your first query!

On 19 July 2017 at 23:43, Conor Broderick <conor.b...@robustperception.io> wrote:
Run blackbox exporter with the default configuration.  

In the following URL I've tested probing your desired target. 


At http://localhost:9115/metric I can see the following metric: 
probe_http_status_code 200 
Now lets configure and run Prometheus to scrape the blackbox exporter to get the probe_http_status_code metric into Prometheus itself.

scrape_configs:
  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_2xx]  # Look for a HTTP 200 response.
    static_configs:
      - targets:
        - http://free.currencyconverterapi.com/api/v3/convert?q=SAR_USD&compact=ultra
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9115  # Blackbox exporter.

Running Prometheus now, you should be able to see probe_http_status_code in the expression browser.

What we've done here essentially is set the Blackbox exporter to probe your given target via http. We're then scraping the metrics the Blackbox exporter produces with Prometheus.

I will check out how to get the response body tomorrow as it's quite late here but the above should sort out your answer your first query!


On 19 July 2017 at 23:10, Nehil Jain <jain....@gmail.com> wrote:
Oh, Sorry about that.

here is an example pinger I want to set

Ping url http://free.currencyconverterapi.com/api/v3/convert?q=SAR_USD&compact=ultra and check is the reponse is 200 and the body has SAR_USD keyword in it. 

Thanks a ton for looking into this.
On Wed, 19 Jul 2017 at 18:02 Conor Broderick <conor.broderick@robustperception.io> wrote:
Can you provide us with more details as to what you're trying to achieve here? 

Setting up the blackbox exporter to send a http probe to a url and check the response in Prometheus is fairly straightforward.  

I'm guessing you're interested in sending an alert or something based on the probe response? 

On 19 July 2017 at 22:57, <jain....@gmail.com> wrote:
Hi,

I am trying to use prometheus with blackbox-exporter to create a smart pinger which pings a url and checks the response with some logic. Is there a way to do that in blackbox-exporter?

Thanks

--
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 prometheus-users+unsubscribe@googlegroups.com.

To post to this group, send email to prometheus-users@googlegroups.com.



--



--



--

Ben Kochie

unread,
Jul 20, 2017, 4:07:10 AM7/20/17
to Conor Broderick, Nehil Jain, Prometheus Users
This is not what the user is looking for exactly, they also want to use a body match.  These config options are not really documented out side the example.yml

In the blackbox.yml, you will want to adjust the http probe module slightly.

modules:
  http_2xx_SAR_USD:
    prober: http
    http:
      fail_if_not_matches_regexp:
        - "SAR_USD"

The above is actually a regexp, so you could make it more specific to the body response.


Brian Brazil

unread,
Jul 20, 2017, 4:10:05 AM7/20/17
to Ben Kochie, Conor Broderick, Nehil Jain, Prometheus Users
On 20 July 2017 at 09:07, Ben Kochie <sup...@gmail.com> wrote:
This is not what the user is looking for exactly, they also want to use a body match.  These config options are not really documented out side the example.yml



In the blackbox.yml, you will want to adjust the http probe module slightly.

modules:
  http_2xx_SAR_USD:
    prober: http
    http:
      fail_if_not_matches_regexp:
        - "SAR_USD"

The above is actually a regexp, so you could make it more specific to the body response.


For more options, visit https://groups.google.com/d/optout.



--

Nehil Jain

unread,
Jul 20, 2017, 8:31:45 AM7/20/17
to Ben Kochie, Conor Broderick, Prometheus Users
This is what I was looking for. Thanks Ben. I do have a follow up question on this approach, because I will be setting up multiple urls which different bodies, it is quite lot of repeated code to get the job done. For each url and body regex I will have to setup a module. Is there a better way?

Thanks for youe help.

On 19 July 2017 at 23:10, Nehil Jain <jain....@gmail.com> wrote:
Oh, Sorry about that.

here is an example pinger I want to set

Ping url http://free.currencyconverterapi.com/api/v3/convert?q=SAR_USD&compact=ultra and check is the reponse is 200 and the body has SAR_USD keyword in it. 

Thanks a ton for looking into this.
On Wed, 19 Jul 2017 at 18:02 Conor Broderick <conor.b...@robustperception.io> wrote:
Can you provide us with more details as to what you're trying to achieve here? 

Setting up the blackbox exporter to send a http probe to a url and check the response in Prometheus is fairly straightforward.  

I'm guessing you're interested in sending an alert or something based on the probe response? 

On 19 July 2017 at 22:57, <jain....@gmail.com> wrote:
Hi,

I am trying to use prometheus with blackbox-exporter to create a smart pinger which pings a url and checks the response with some logic. Is there a way to do that in blackbox-exporter?

Thanks

--
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 prometheus-use...@googlegroups.com.

To post to this group, send email to promethe...@googlegroups.com.



--



--



--

--
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 prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.

Brian Brazil

unread,
Jul 20, 2017, 8:33:57 AM7/20/17
to Nehil Jain, Ben Kochie, Conor Broderick, Prometheus Users
On 20 July 2017 at 13:31, Nehil Jain <jain....@gmail.com> wrote:
This is what I was looking for. Thanks Ben. I do have a follow up question on this approach, because I will be setting up multiple urls which different bodies, it is quite lot of repeated code to get the job done. For each url and body regex I will have to setup a module. Is there a better way?

For each body you'll need a module, but you can have multiple URLs on the Prometheus side. The blackbox exporter is designed with the idea that you're running a single test against many many identical servers.

Brian
 

Thanks for youe help.


To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.

To post to this group, send email to prometheus-users@googlegroups.com.



--



--



--

--
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 prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.

--
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 prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/CAFUpag5E9nMuU4s3fPwggcgZjq%3D5j43BG7MF%3DJYHcWPEyU%2BjUQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--

Ben Kochie

unread,
Jul 21, 2017, 5:35:06 AM7/21/17
to Nehil Jain, Conor Broderick, Prometheus Users
On Thu, Jul 20, 2017 at 2:31 PM, Nehil Jain <jain....@gmail.com> wrote:
This is what I was looking for. Thanks Ben. I do have a follow up question on this approach, because I will be setting up multiple urls which different bodies, it is quite lot of repeated code to get the job done. For each url and body regex I will have to setup a module. Is there a better way?

No, there's not really a way to pass arbitrary template parameters into the blackbox exporter.  Best suggestion is to use a config management template to generate all of the modules you will need.

You can also possibly match a number of parameters using regular expression syntax.
 

Thanks for youe help.


To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.

To post to this group, send email to prometheus-users@googlegroups.com.



--



--



--

--
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 prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages