DEV Community

Cover image for Prometheus-Grafana Using BlackBox exporter
Kannan
Kannan

Posted on

Prometheus-Grafana Using BlackBox exporter

Here we are going to use Blackbox export on grafana Dashboard

  • Download the blackbox exporter
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.24.0/blackbox_exporter-0.24.0.linux-amd64.tar.gz
Enter fullscreen mode Exit fullscreen mode
  • extract the package
tar -xvf blackbox_exporter-0.24.0.linux-amd64.tar.gz
Enter fullscreen mode Exit fullscreen mode
  • enter into blackbox directory
cd blackbox_exporter-0.24.0.linux-amd64
Enter fullscreen mode Exit fullscreen mode
  • create the monitor_website.yml file
vim monitor_website.yml
Enter fullscreen mode Exit fullscreen mode
modules:
  http_2xx_example:
    prober: http
    timeout: 5s
    http:
      valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
      valid_status_codes: [200]  # Defaults to 2xx
      method: GET
Enter fullscreen mode Exit fullscreen mode
  • Create the service file for blackbox
vim /etc/systemd/system/blackbox.service
Enter fullscreen mode Exit fullscreen mode
[Unit]
Description = Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
User=root
Restart=on-failure

ExecStart=/root/blackbox_exporter-0.24.0.linux-amd64/blackbox_exporter --config.file=/root/blackbox_exporter-0.24.0.linux-amd64/monitor_website.yml

[Install]
WantedBy=multi-user.target
Enter fullscreen mode Exit fullscreen mode
  • Reload,start,enable and find the status of the balckbox service
systemctl daemon-reload
systemctl start blackbox
systemctl enable blackbox
systemctl status blackbox
Enter fullscreen mode Exit fullscreen mode
  • At prometheus server creating the scrape config file
vim /etc/prometheus/prometheus.yml
Enter fullscreen mode Exit fullscreen mode
- job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_2xx_example]  # Look for a HTTP 200 response.
    static_configs:
      - targets:
        - http://prometheus.io    # Target to probe with http.
        - https://prometheus.io   # Target to probe with https.
        - http://kaniyam.com
        - http://freetamilebooks.com
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 192.168.122.138:9115
Enter fullscreen mode Exit fullscreen mode
  • Restart the services
systemctl restart prometheus
systemctl restart grafana-server        
Enter fullscreen mode Exit fullscreen mode

Image description

  • In Grafana Dashboard Create a query and add metrics
probe_http_status_code
Enter fullscreen mode Exit fullscreen mode
probe_http_ssl
Enter fullscreen mode Exit fullscreen mode

Image description

  • Add > Virtulization >select tables >set value mappings and set colour >rename the panel.

  • Below the metric "option" set the type as "Table", "instant"
    Select "Transform data" and modify the name as your choice.

Image description

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up