Feedback

Chat Icon

Observability with Prometheus and Grafana

A Complete Hands-On Guide to Operational Clarity in Cloud-Native Systems

Monitoring Endpoints with Prometheus and Blackbox Exporter
54%

Your First Steps with the Blackbox Exporter

The Blackbox Exporter listens on port 9115 by default. You can check if the container (or service) is running by visiting http://:9115/metrics in your browser (where is the IP address of the server where you installed the exporter) or from the command line with curl:

curl http://localhost:9115/metrics

These metrics give you insights into the performance of the Blackbox Exporter itself, such as the number of probes executed, their duration, and any errors encountered.

The configuration of the Blackbox Exporter is done using its blackbox.yml file. In the previous example, we configured it to probe HTTP endpoints that return a 2xx status code (e.g., 200 OK, 201 Created, 202 Accepted, etc.).

# /etc/prometheus/blackbox.yml
# Define the modules to use
modules:
  # Create a module called http_2xx
  http_2xx:
    # Configure the prober to use the http module
    # The http prober probes a HTTP or HTTPS endpoint
    prober: http

In order to test this probe, we need to choose a target host. Let's use google.com as an example. The full probe command looks like this:

curl "http://localhost:9115/probe?target=google.com&module=http_2xx"

Where:

  • localhost:9115 is the address of the Blackbox Exporter.
  • /probe is the endpoint where the Blackbox Exporter exposes the probe functionality.
  • target=google.com is the target URL we want to probe.
  • module=http_2xx is the module we configured earlier in blackbox.yml.

This command will return the probe results in Prometheus exposition format:

# HELP probe_dns_lookup_time_seconds Returns the time taken for probe dns lookup in seconds
# TYPE probe_dns_lookup_time_seconds gauge
probe_dns_lookup_time_seconds 0.000862674
# HELP probe_duration_seconds Returns how long the probe took to complete in seconds
# TYPE probe_duration_seconds gauge
probe_duration_seconds 0.001254561
# HELP probe_failed_due_to_regex Indicates if probe failed due to regex
# TYPE probe_failed_due_to_regex gauge
probe_failed_due_to_regex 0
# HELP probe_http_content_length Length of http content response
# TYPE probe_http_content_length gauge
probe_http_content_length 0
# HELP probe_http_duration_seconds Duration of http request by phase, summed over all redirects
# TYPE probe_http_duration_seconds gauge
probe_http_duration_seconds{phase="connect"} 0
probe_http_duration_seconds{phase="processing"} 0
probe_http_duration_seconds{phase="resolve"} 0.000862674
probe_http_duration_seconds{phase="tls"}

Observability with Prometheus and Grafana

A Complete Hands-On Guide to Operational Clarity in Cloud-Native Systems

Enroll now to unlock all content and receive all future updates for free.