Skip to content

Latest commit

 

History

History
81 lines (66 loc) · 2.34 KB

L09-BlackboxExporter.md

File metadata and controls

81 lines (66 loc) · 2.34 KB

BlackBox Exporter

Blackbox Exporter is used for endpoint monitoring and can help generate meaningful uptime and availability metrics. Blackbox Exporter can probe endpoints over HTTP, HTTPS, DNS, TCP, and ICMP. While most exporters accept static configurations and expose metrics accordingly, Blackbox Exporter works a little differently.

Install Blackbox exporter to monitor http/https endpoints by running the following commands:

$ wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.14.0/blackbox_exporter-0.14.0.linux-amd64.tar.gz
$ tar xvzf blackbox_exporter-0.14.0.linux-amd64.tar.gz
$ cd blackbox_exporter-0.14.0.linux-amd64
$ ./blackbox_exporter -h
$ sudo mv blackbox_exporter /usr/local/bin
$ sudo mkdir -p /etc/blackbox
$ sudo mv blackbox.yml /etc/blackbox
$ sudo useradd -rs /bin/false blackbox
$ sudo chown blackbox:blackbox /usr/local/bin/blackbox_exporter
$ sudo chown -R blackbox:blackbox /etc/blackbox/*
$ cd /lib/systemd/system

create service file:


$ sudo touch blackbox.service

$ sudo nano blackbox.service

[Unit]
Description=Blackbox Exporter Service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=blackbox
Group=blackbox
ExecStart=/usr/local/bin/blackbox_exporter \
  --config.file=/etc/blackbox/blackbox.yml \
  --web.listen-address=":9115"

Restart=always

[Install]
WantedBy=multi-user.target

Enable and start service

$ sudo systemctl enable blackbox.service
$ sudo systemctl start blackbox.service
$ curl http://localhost:9115/metrics

Add Black box expoter configuration in prometheus.yml file

$ sudo nano /etc/prometheus/prometheus.yml

global:
  scrape_interval:     15s
  evaluation_interval: 15s

scrape_configs:
 - job_name: 'blackbox-http-endpoints-status'
    metrics_path: /probe
    params:
      module: [http_2xx] # Look for a HTTP 200 response.
    static_configs:
      - targets:
        - https://google.com/
        - https://www.abc.com/
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: localhost:9115  # The blackbox exporter's real hostname:port.      
  • Import dashboard 7587 for blackbox exporter

Note : Use will get hands-on upon Observability tools in LEVEL 3