Skip to content

blackbox-exporter

blackbox-exporter is an open-source monitoring probe, part of the Prometheus ecosystem, designed to collect Metrics regarding the reachability and health of endpoints over protocols like HTTP, HTTPS, TCP, and ICMP^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

Overview

Unlike exporters that expose internal system Metrics (like CPU or memory), blackbox-exporter operates by probing external targets^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. It executes checks against specified endpoints (such as a website URL or a TCP port) and returns the results—such as success status, latency, or SSL certificate expiration—to the Prometheus server for storage and alerting^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

Configuration

The behavior of the exporter is defined by a configuration file (typically blackbox.yml), which organizes probing logic into modules^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. Each module specifies the protocol and parameters for the probe.

Example Modules:

  • http_2xx: Performs an HTTP GET request^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
    • Protocol: HTTP
    • Valid Status Codes: 200, 301, 302^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]
    • Valid HTTP Versions: HTTP/1.1, HTTP/2^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]
    • Preferred IP Protocol: IPv4^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]
  • tcp_connect: Verifies TCP connectivity^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

Usage in Kubernetes

In a Kubernetes environment, blackbox-exporter is typically deployed as a Prometheus scrape job^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

To monitor business containers, Prometheus utilizes Kubernetes Service Discovery along with Relabeling^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md]. This setup allows dynamic monitoring of Pods based on their annotations:

  • HTTP Monitoring: Pods annotated with blackbox_scheme: http (along with blackbox_port and blackbox_path) trigger the http_2xx probe^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].
  • TCP Monitoring: Pods annotated with blackbox_scheme: tcp (and blackbox_port) trigger the tcp_connect probe^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

This configuration enables the monitoring of service availability and SSL certificate expiry^[400-devops__06-Kubernetes__k8s-paas__07.Promtheus监控k8s企业级应用.md].

Sources