项目作者: prometheus

项目描述 :
Blackbox prober exporter
高级语言: Go
项目地址: git://github.com/prometheus/blackbox_exporter.git
创建时间: 2015-09-05T14:45:00Z
项目社区:https://github.com/prometheus/blackbox_exporter

开源协议:Apache License 2.0

下载


Blackbox exporter

CircleCI
Docker Repository on Quay
Docker Pulls

The blackbox exporter allows blackbox probing of endpoints over
HTTP, HTTPS, DNS, TCP, ICMP and gRPC.

Running this software

From binaries

Download the most suitable binary from the releases tab

Then:

  1. ./blackbox_exporter <flags>

Using the docker image

Note: You may want to enable ipv6 in your docker configuration

  1. docker run --rm \
  2. -p 9115/tcp \
  3. --name blackbox_exporter \
  4. -v $(pwd):/config \
  5. quay.io/prometheus/blackbox-exporter:latest --config.file=/config/blackbox.yml

Checking the results

Visiting http://localhost:9115/probe?target=google.com&module=http_2xx
will return metrics for a HTTP probe against google.com. The probe_success
metric indicates if the probe succeeded. Adding a debug=true parameter
will return debug information for that probe.

Metrics concerning the operation of the exporter itself are available at the
endpoint http://localhost:9115/metrics.

TLS and basic authentication

The Blackbox Exporter supports TLS and basic authentication. This enables better
control of the various HTTP endpoints.

To use TLS and/or basic authentication, you need to pass a configuration file
using the --web.config.file parameter. The format of the file is described
in the exporter-toolkit repository.

Note that the TLS and basic authentication settings affect all HTTP endpoints:
/metrics for scraping, /probe for probing, and the web UI.

Building the software

Local Build

  1. make

Building with Docker

After a successful local build:

  1. docker build -t blackbox_exporter .

Configuration

Blackbox exporter is configured via a configuration file and command-line flags (such as what configuration file to load, what port to listen on, and the logging format and level).

Blackbox exporter can reload its configuration file at runtime. If the new configuration is not well-formed, the changes will not be applied.
A configuration reload is triggered by sending a SIGHUP to the Blackbox exporter process or by sending a HTTP POST request to the /-/reload endpoint.

To view all available command-line flags, run ./blackbox_exporter -h.

To specify which configuration file to load, use the --config.file flag.

Additionally, an example configuration is also available.

HTTP, HTTPS (via the http prober), DNS, TCP socket, ICMP and gRPC (see permissions section) are currently supported.
Additional modules can be defined to meet your needs.

The timeout of each probe is automatically determined from the scrape_timeout in the Prometheus config, slightly reduced to allow for network delays.
This can be further limited by the timeout in the Blackbox exporter config file. If neither is specified, it defaults to 120 seconds.

Prometheus Configuration

Blackbox exporter implements the multi-target exporter pattern, so we advice
to read the guide Understanding and using the multi-target exporter pattern to get the general
idea about the configuration.

The blackbox exporter needs to be passed the target as a parameter, this can be
done with relabelling.

Example config:

  1. scrape_configs:
  2. - job_name: 'blackbox'
  3. metrics_path: /probe
  4. params:
  5. module: [http_2xx] # Look for a HTTP 200 response.
  6. static_configs:
  7. - targets:
  8. - http://prometheus.io # Target to probe with http.
  9. - https://prometheus.io # Target to probe with https.
  10. - http://example.com:8080 # Target to probe with http on port 8080.
  11. relabel_configs:
  12. - source_labels: [__address__]
  13. target_label: __param_target
  14. - source_labels: [__param_target]
  15. target_label: instance
  16. - target_label: __address__
  17. replacement: 127.0.0.1:9115 # The blackbox exporter's real hostname:port.
  18. - job_name: 'blackbox_exporter' # collect blackbox exporter's operational metrics.
  19. static_configs:
  20. - targets: ['127.0.0.1:9115']

HTTP probes can accept an additional hostname parameter that will set Host header and TLS SNI. This can be especially useful with dns_sd_config:

  1. scrape_configs:
  2. - job_name: blackbox_all
  3. metrics_path: /probe
  4. params:
  5. module: [ http_2xx ] # Look for a HTTP 200 response.
  6. dns_sd_configs:
  7. - names:
  8. - example.com
  9. - prometheus.io
  10. type: A
  11. port: 443
  12. relabel_configs:
  13. - source_labels: [__address__]
  14. target_label: __param_target
  15. replacement: https://$1/ # Make probe URL be like https://1.2.3.4:443/
  16. - source_labels: [__param_target]
  17. target_label: instance
  18. - target_label: __address__
  19. replacement: 127.0.0.1:9115 # The blackbox exporter's real hostname:port.
  20. - source_labels: [__meta_dns_name]
  21. target_label: __param_hostname # Make domain name become 'Host' header for probe requests
  22. - source_labels: [__meta_dns_name]
  23. target_label: vhost # and store it in 'vhost' label

Permissions

The ICMP probe requires elevated privileges to function:

  • Windows: Administrator privileges are required.
  • Linux: either a user with a group within net.ipv4.ping_group_range, the
    CAP_NET_RAW capability or the root user is required.
    • Your distribution may configure net.ipv4.ping_group_range by default in
      /etc/sysctl.conf or similar. If not you can set
      net.ipv4.ping_group_range = 0 2147483647 to allow any user the ability
      to use ping.
    • Alternatively the capability can be set by executing setcap cap_net_raw+ep blackbox_exporter
  • BSD: root user is required.
  • OS X: No additional privileges are needed.