Blackbox exporter: Difference between revisions

From wikinotes
Line 34: Line 34:
= Configuration =
= Configuration =
<blockquote>
<blockquote>
blackbox seems to be configured both within <code>prometheus.yml</code> and it's own config file.
* You define your own test-modules (endpoints test-conditions) in <code>blackbox_exporter.yml</code>.
* You configure test-modules to test endpoints with in your <code>prometheus.yml</code>.


TBD.
== Define Test-Modules ==
<blockquote>
<syntaxhighlight lang="yaml">
# /usr/local/etc/blackbox_exporter.yml
 
modules:
  http_2xx:
    http:
      prober: http
      valid_status_codes: 2xx
      method: GET
      follow_redirects: true
      fail_if_not_ssl: true
      timeout: 5s
 
  http_401:
    http:
      prober: http
      valid_status_codes: 401
      method: GET
      follow_redirects: true
      fail_if_not_ssl: true
      timeout: 5s
</syntaxhighlight>
 
Here we configure two test-modules.<br>
The first tests for a HTTP-2XX return-code, the second for an HTTP-401.
 
See the sample config where all options/types are documented.
</blockquote><!-- Define Test-Modules -->
 
== Use Modules ==
<blockquote>
<syntaxhighlight lang="yaml">
# /usr/local/etc/prometheus.yml
 
global:
  scrape_interval: 120s
 
scrape_configs:
  - job_name: http_2xx
    params:
      module: [http_2xx]
    static_configs:
      - targets:
        - https://foo.com
        - https://bar.net
    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
 
</syntaxhighlight>
 
This config creates a scrape-job that uses our <code>http_2xx</code> module to test both <code>https://foo.com</code> and <code>https://bar.net</code>.
</blockquote><!-- Use Modules -->
</blockquote><!-- Configuration -->
</blockquote><!-- Configuration -->

Revision as of 02:06, 17 February 2022

Prometheus exporter that probes endpoints over HTTP/HTTPS/DNS/TCP/ICMP.

Documentation

github https://github.com/prometheus/blackbox_exporter
config syntax https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md
example config https://github.com/prometheus/blackbox_exporter/blob/master/example.yml

Locations

9115 default port
${PREFIX}/etc/blackbox_exporter.yml config

Install

pacman -S prometheus-blackbox-exporter  # Archlinux
pkg install blackbox_exporter           # FreeBSD

Configuration

  • You define your own test-modules (endpoints test-conditions) in blackbox_exporter.yml.
  • You configure test-modules to test endpoints with in your prometheus.yml.

Define Test-Modules

# /usr/local/etc/blackbox_exporter.yml

modules:
  http_2xx:
    http:
      prober: http
      valid_status_codes: 2xx
      method: GET
      follow_redirects: true
      fail_if_not_ssl: true
      timeout: 5s

  http_401:
    http:
      prober: http
      valid_status_codes: 401
      method: GET
      follow_redirects: true
      fail_if_not_ssl: true
      timeout: 5s

Here we configure two test-modules.
The first tests for a HTTP-2XX return-code, the second for an HTTP-401.

See the sample config where all options/types are documented.

Use Modules

# /usr/local/etc/prometheus.yml

global:
  scrape_interval: 120s

scrape_configs:
  - job_name: http_2xx
    params:
      module: [http_2xx]
    static_configs:
      - targets:
        - https://foo.com
        - https://bar.net
    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

This config creates a scrape-job that uses our http_2xx module to test both https://foo.com and https://bar.net.