Newbie Question - blackbox_exporter/ config

46 views
Skip to first unread message

Eric

unread,
Aug 7, 2020, 4:16:18 AM8/7/20
to Prometheus Users
Hi,

I want to check variaous URLs with the help of the blackbox_exporter module:  http_2xx.
As far as good, it works.

My Question:
The targets have  to be defined in the prometheus.yml, they can't be defined in blackbox.yml as far as I understand.

Is there a possibility to split the prometheus.yml config, in oder to have more configs with different file permissions?

Background:
The configfile of the named URLs to check, should be edited by our serviceprovider and I don't want to that they are break something in my main configfile.

Sorry for this trivial question.

Regards
Eric

Brian Candler

unread,
Aug 7, 2020, 7:31:41 AM8/7/20
to Prometheus Users
On Friday, 7 August 2020 09:16:18 UTC+1, Eric wrote:
My Question:
The targets have  to be defined in the prometheus.yml, they can't be defined in blackbox.yml as far as I understand.


The targets are defined as prometheus targets, but they don't have to be static_sd_configs.  They can be in other files using file_sd_configs.
 
Is there a possibility to split the prometheus.yml config, in oder to have more configs with different file permissions?


Yes.  file_sd_configs can point to one or more target files.
 
Doing this neatly involves using a little label rewriting.  Here is a config you can base on:

  - job_name: blackbox
    file_sd_configs:
      - files:
        - /etc/prometheus/targets.d/foo_targets.yml
        - /etc/prometheus/targets.d/bar_targets.yml
    metrics_path: /probe
    relabel_configs:
      - source_labels: [__address__]
        target_label: instance
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [module]
        target_label: __param_module
      - target_label: __address__
        replacement: 127.0.0.1:9115  # Blackbox exporter

Then in the targets files you can write things like this:

- labels:
    module: http_2xx
  targets:
- labels:
    module: http_3xx
  targets:

Ben Kochie

unread,
Aug 7, 2020, 7:39:03 AM8/7/20
to Eric, Prometheus Users
In addition to what Brian said, I can highly recommend looking at the Prometheus Ansible roles.


There is pre-processing Ansible that will help prevent typos from causing failures. You can have a private git repo where your service provider can send change requests, and use approval workflow. This will completely side-step  problems with bad edits.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/c86b1a9e-6b80-43d2-8024-793938f73261o%40googlegroups.com.

Eric

unread,
Aug 7, 2020, 7:50:55 AM8/7/20
to Prometheus Users
Hi Brian,

thanks for your quick response, this is exactly what I need and a way it should work.
Perhaps I didn' read the fucking manual in detail, sorry.

Have a nice weekend.

Regards
Eric
Reply all
Reply to author
Forward
0 new messages