Stage 6 · Operate
Metrics with Prometheus
Exporters Overview
Choosing blackbox_exporter, postgres_exporter, redis_exporter, and custom instrumentation.
What Are Exporters?
Exporters translate metrics from third-party systems into Prometheus format. They act as bridges between systems that do not natively expose Prometheus metrics and the Prometheus scraper. Each exporter typically runs as a sidecar or separate process.
The Prometheus ecosystem maintains dozens of official and community exporters. Choosing the right one depends on what you need to monitor and how much control you have over the application code.
Common Exporters
| Exporter | Monitors | Default Port |
|---|---|---|
| node_exporter | Linux host metrics | 9100 |
| blackbox_exporter | HTTP, TCP, DNS, ICMP probes | 9115 |
| postgres_exporter | PostgreSQL metrics | 9187 |
| redis_exporter | Redis metrics | 9121 |
| mysqld_exporter | MySQL metrics | 9104 |
| nginx-prometheus-exporter | Nginx metrics | 9113 |
Blackbox Exporter
The blackbox_exporter probes external endpoints from Prometheus's perspective. It measures availability, latency, SSL certificate expiry, and DNS resolution. This is essential for monitoring services you do not control or cannot instrument directly.
scrape_configs:
- job_name: "blackbox-http"
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- "https://api.example.com/health"
- "https://status.example.com"
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: "blackbox-exporter:9115"Blackbox exporter creates two series per target: probe_success (0 or 1) and probe_duration_seconds. The probe runs from the exporter's perspective, so it measures network latency from where the exporter runs, not from Prometheus itself.
Database Exporters
Database exporters connect to database instances and expose internal metrics. postgres_exporter runs SQL queries against PostgreSQL system views and converts results into Prometheus gauges and counters.
scrape_configs:
- job_name: "postgres"
static_configs:
- targets: ["postgres-exporter:9187"]
metrics_path: /metrics
# Environment variable for connection
# DATA_SOURCE_NAME="postgresql://user:pass@localhost:5432/dbname?sslmode=disable"Custom Instrumentation
When no exporter exists, you instrument your application directly using client libraries. Prometheus provides official libraries for Go, Java, Python, Ruby, and others. This gives you full control over metric names, labels, and types.
from prometheus_client import Counter, Histogram, start_http_server
REQUEST_COUNT = Counter(
"http_requests_total",
"Total HTTP requests",
["method", "endpoint", "status"]
)
REQUEST_LATENCY = Histogram(
"http_request_duration_seconds",
"HTTP request latency",
["method", "endpoint"],
buckets=[0.01, 0.05, 0.1, 0.5, 1.0, 5.0]
)
start_http_server(8000)Custom instrumentation gives you semantic accuracy that exporters cannot match. You control what gets measured, how labels are structured, and which operations are tracked. Start with client libraries before reaching for exporters.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.