How to Monitor Website Performance with Blackbox Exporter and Grafana?

Do you’re keen on Grafana for monitoring server statistics? You will additionally love Blackbox Exporter for web site monitoring!

On this tutorial, you’ll learn to set up Blackbox Exporter on CentOS/RHEL and perceive how one can use it with Prometheus and Grafana to watch web site efficiency and uptime.

What’s Blackbox Exporter?

Blackbox Exporter by Prometheus is used to look at endpoints comparable to HTTPS, HTTP, TCP, DNS and ICMP. After you outline the endpoint, the Blackbox exporter generates a whole lot of statistics that may be visualized with Grafana. Measuring the response time is the primary characteristic of the Blackbox exporter.

Blackbox Exporter is a self-hosted answer. For those who’re on the lookout for one thing related, however SaaS or cloud-based, you’ll be able to strive Grafana worldPing.


Prometheus and Grafana should be pre-installed. Comply with this text to put in Prometheus and Grafana.

Set up of Blackbox Exporter

I will first present you how one can set up Blackbox Exporter.

Step 1: Obtain Blackbox Exporter

Go to the official web page to obtain the newest Linux AMD Blackbox export bundle. I’m the blackbox_exporter-0.16.0.linux-amd64.tar.gz file.

  • Switch the downloaded file to the server
  • Extract information from the bundle.
[centos@geekflare ~]$ tar -xzf blackbox_exporter-0.16.0.linux-amd64.tar.gz

Verify all information in Blackbox Exporter.

[centos@geekflare ~]$ cd blackbox_exporter-0.16.0.linux-amd64/
[centos@geekflare blackbox_exporter-0.16.0.linux-amd64]$ ls -l
complete 16672
-rwxr-xr-x. 1 centos centos 17050332 Nov 11 2019 blackbox_exporter
-rw-r--r--. 1 centos centos 629 Nov 11 2019 blackbox.yml
-rw-r--r--. 1 centos centos 11357 Nov 11 2019 LICENSE
-rw-r--r--. 1 centos centos 94 Nov 11 2019 NOTICE

Two information blackbox_exporter And blackbox.yml are essential right here.

  • blackbox_exporter: That is an executable file for working the service.
  • blackbox.yml: A YAML file containing all of the backbox exporter configurations, the place you outline all of the endpoints to look at and modules to run.

The command beneath offers you all of the flags you need to use with Blackbox Exporter.

[centos@geekflare blackbox_exporter-0.16.0.linux-amd64]$ ./blackbox_exporter -h
utilization: blackbox_exporter [<flags>]

-h, --help Present context-sensitive assist (additionally strive --help-long and --help-man).

Blackbox exporter configuration file.
The deal with to hear on for HTTP requests.

--timeout-offset=0.5 Offset to subtract from timeout in seconds.

--config.examine If true validate the config file after which exit.

--history.restrict=100 The utmost quantity of things to maintain within the historical past.

The URL below which Blackbox exporter is externally reachable (for instance, if Blackbox exporter is served by way of a
reverse proxy). Used for producing relative and absolute hyperlinks again to Blackbox exporter itself. If the URL has a
path portion, it will likely be used to prefix all HTTP endpoints served by Blackbox exporter. If omitted, related URL
elements shall be derived robotically.

Prefix for the interior routes of internet endpoints. Defaults to path of --web.external-url.

--log.stage=information Solely log messages with the given severity or above. Considered one of: [debug, info, warn, error]

--log.format=logfmt Output format of log messages. Considered one of: [logfmt, json]
--version Present software model.

Step 2: Create a consumer for Blackbox

That is non-compulsory.

You possibly can create a brand new consumer to run Blackbox or use current Prometheus customers to run Blackbox.

Grant permissions and assign possession of all information to the brand new consumer.

[centos@geekflare ~]$ sudo useradd -rs /bin/false blackbox
[centos@geekflare ~]$ sudo chmod -R 777 /dwelling/centos/blackbox_exporter-0.16.0.linux-amd64
[centos@geekflare ~]$ sudo chown -R blackbox:blackbox /dwelling/centos/blackbox_exporter-0.16.0.linux-amd64

Step 3: Configure the Blackbox service

It is time to configure Blackbox Exporter as a service inside systemd. Create a file blackbox.service and put the strains beneath into the file and put it aside.

[centos@geekflare ~]$ sudo gedit /and so on/systemd/system/blackbox.service

Description=Blackbox Exporter Service

ExecStart=/dwelling/centos/blackbox_exporter-0.16.0.linux-amd64/blackbox_exporter --config.file==/dwelling/centos/blackbox_exporter-0.16.0.linux-amd64/blackbox.yml


Do not forget to vary the trail to the precise path the place you extracted it.

Step 4: Launch Blackbox Exporter

Run the instructions beneath to start out the blackbox exporter as a service.

[centos@geekflare ~]$ sudo systemctl daemon-reload
[centos@geekflare ~]$ sudo systemctl begin blackbox.service
[centos@geekflare ~]$ sudo systemctl standing blackbox.service ● blackbox.service - Blackbox Exporter Service Loaded: loaded (/and so on/systemd/system/blackbox.service; enabled; vendor preset: disabled) Energetic: working (working) since Saturday 6/13/2020 17 :28:40 EDT;  1s in the past Most important PID: 30427 (blackbox_export) Duties: 5 CGroup: /system.slice/blackbox.service └─30427 /usr/native/bin/blackbox_exporter --config.file=/and so on/blackbox.yml Jun 13, 17: 28 :40 systemd[1]: Blackbox Exporter service began.  Jun 13 17:28:40 blackbox_exporter[30427]: stage=information ts=2020-06-13T21:28:40.283Z caller=primary.go:212 msg="Beginning b...b9a9)" Jun 13 17:28:40 blackbox_exporter[30427]: stage=information ts=2020-06-13T21:28:40.283Z caller=primary.go:213 msg="Construct cont...SSING) Jun 13 17:28:40 blackbox_exporter[30427]: stage=information ts=2020-06-13T21:28:40.283Z caller=primary.go:225 msg="Loaded configuration file" Jun 13 17:28:40 blackbox_exporter[30


Blackbox exporter has successfully started. At http://localhost:9115/ you can find Blackbox Exporter running.

blackbox exporter - geekflare

Integrating Blackbox with Prometheus

Let’s integrate Blackbox Exporter with Prometheus to start scraping the metrics.

  • Add a blackbox job with below configurations inside the prometheus.yml file. I am going to monitor the performance of
[centos@geekflare ~]$ sudo gedit /and so on/prometheus/prometheus.yml -job_name: 'blackbox' metrics_path: /probe params: module: [http_2xx] # Search for an HTTP 200 response.  static_configs: - targets: - relabel_configs: - source_labels: [__address__]
target_label: __param_target - source_labels: [__param_target]
target_label: occasion - target_label: __address__ alternative: # The actual hostname of the blackbox exporter:port.
  • Restart Prometheus.
[centos@geekflare ~]$ sudo systemctl restart prometheus.service
  • While you examine the targets for http://localhost:9090/targets once more, you may discover a blackbox job working with the endpoint I’ve outlined.
blackbox task target - geekflare
  • Click on on the chart and run the question – probe_http_duration_seconds.
prometheus query - geekflare
  • A visualization is created of the info monitored by Prometheus.
prometheus visualization - geekflare

Now it is time to visualize the Blackbox job on Grafana.

There are lots of methods to get began, however one of many quickest is to start out with a ready-made dashboard: Prometheus Blackbox Exporter.

  • Go to the Grafana dashboard, click on + signal and click on Import.
  • Below Import by way of, enter the dashboard ID 7587 and click on Load.
  • Then choose the Prometheus information supply and click on Import.
grafana import - geekflare
  • The Prometheus Blackbox Exporter dashboard is imported.
  • You possibly can visualize metrics comparable to world probe period, standing, HTTP period, common probe period, common DNS lookup, SSL expiration date and way more.
grafana dashboard - geekflare
grafana dashboard 1 - geekflare
  • These are all separate panels on the dashboard. I’ll present the HTTP period panel intimately. This panel exhibits the visualization of the size of time it takes for connection, processing, decision, TLS, and switch requests.
HTTP Duration

There are tons of choices on the dashboard so that you can mess around with. You possibly can change the time vary for which you need the visualization to look. You can too change the time interval when information is refreshed; right here the brand new information comes into the dashboard each 5 seconds.

time frame
  • While you click on the down arrow to HTTP Period, you may be introduced with the choices beneath. Click on edit.
edit panel
  • Below the visualization panel, you’ll get a question editor. At present, the question is visualized within the snapshot beneath: probe_http_duration_seconds.
query editor
  • There are a whole lot of queries that you could simply visualize and add to your dashboard as you want.
  • You even have loads of choices to vary the visualization sort. The typical probe period is on the market in textual content format on the dashboard. Within the visualization panel on the best, click on the Mate medium probe period possibility.
average probe duration
  • And so the visualization will change.
average probe duration


The above is simply to offer you an concept of ​​how simple it’s to watch the web site utilizing Prometheus Blackbox and Grafana. There are many choices, and I extremely advocate enjoying round with it to expertise it. For those who’re interested by studying from Grafana, try his on-line course.

Rate this post
Leave a Comment