How To Install and Configure Blackbox Exporter for Prometheus

1. Create Docker Container Grafana

” docker run -d –name Grafana -p 3000:3000 -e ” GF_SECURITY_ADMIN_USER= admin” -e ” GF_SECURITY_ADMIN_

PASSWORD= password ” grafana/grafana:latest “

2. Create Docker Container Prometheus

” docker run -d –name Prometheus -p 9090:9090 -v /opt/prometheus/prometheus.yml:/etc/prometheus/prome theus.yml prom/prometheus –config.file=/etc/prometheus/prometheus.yml “

Before crerating a Prometheus docker container you need to create a folder and create .yml

” mkdir /opt/prometheus “

” nano /opt/prometheus/prometheus.yml “

Prometheus Config .Yml (This configure file only refer to connect with blackbox-exporter)

global:
external_labels:
monitor: ‘prometheus’

scrape_configs:

  • job_name: ‘blackbox’ metrics_path: /probe params: module: [http_2xx] static_configs:
    • targets:
      • “https://……..”
      • “https://……..”
      • “https://……../”
        relabel_configs:
    • source_labels: [address]
      target_label: __param_target
    • source_labels: [__param_target]
      target_label: instance
    • target_label: address
      replacement: localhost:9115 # Blackbox exporter

Targets: Replace which you want to connect URL (Example “https://google.com“)

Replacement: Replace your IP address and Port of Blackbox (Example: 192.168.1.1:9115)

3. Create Docker Container Blackbox-Exporter

” docker run -d –name Blackbox-Exporter -p 9115:9115 -v /opt/prometheus/prometheus.yml:/etc/prometheus/

prometheus.yml prom/blackbox-exporter “

Before Creating a Blackbox-Exporter docker container you need to create a folder and create file

” mkdir /opt/blackbox-exporter “

” nano /opt/blackbox-exporter/blackbox.yml “

modules:
http_2xx:
prober: http
timeout: 5s
http:
method: GET
http_post_2xx:
prober: http
http:
method: POST

After all create a docker container, Open Grafana URL before you create ” docker grafana Port” and use it with your Localhost.

To Add Data Source click “ Toggle Menu ” at left side of “ Home ” and click Data Source

After that click + add new data source  on right side top corner and choice prometheus. After that Create Dashboard Import using this ID:7587

Thank you Thank you all guys if you have any suggestions for this. Please leave a comment below.