Prometheus does only one thing to collect data: it sends an HTTP request and reads a text in the format it expects. An exporter is the program that produces this text from a source that knows nothing about it: an operating system, a database, a network device. This guide helps you pick the right tool and understand how the pieces fit together.
What you will learn
- Tell the three exporter families apart, and know which one requires relabeling.
- Choose between an exporter and direct instrumentation of your code.
- Install Node Exporter as a systemd service, under a dedicated account.
- Set up the multi-target pattern with Blackbox, relabeling included.
- Avoid cardinality traps and never expose
/metricswithout protection.
Where do exporters fit?
The exporter never sends anything on its own: Prometheus comes to read its
/metrics endpoint at regular intervals, an operation called a scrape. This
pull model, as opposed to the push of a classic agent, explains most of the
rest of the page: the exporter must be reachable over the network from the
Prometheus server, not the other way around.
[SOURCE] → (exporter / instrumentation) → /metrics ──scrape──▶ Prometheus- Source: OS, DB, network service, application…
- Exporter: queries the source and publishes the result on
/metrics - Prometheus: collects, stores, queries, alerts
Exporter or instrumentation: how to decide?
A single criterion decides: who owns the code. Instrumenting means making the application produce its own metrics, which gives access to business indicators that no external tool can infer: an average basket value, a number of pending orders. An exporter observes from the outside what a component is willing to expose, so it is limited to what that component already publishes.
| Situation | Solution | Why |
|---|---|---|
| I have the app's code | Instrumentation (client libs, OTel) | Precise business metrics, less approximation |
| Third-party product, no code | Dedicated exporter | MySQL, PostgreSQL, Redis, Nginx… |
| Operating system | Agent (Node/Windows Exporter) | CPU, RAM, disk, network |
| Check external availability | Blackbox Exporter | HTTP, DNS, TCP, ICMP probes |
The 3 exporter families
This is the distinction to understand before configuring anything, because
it changes the way you write the scrape_config. The sorting criterion is
simple: how many targets can one instance of the exporter observe, and
where does it run relative to them. The first two families are configured with
an ordinary list of targets; the third one requires relabeling, detailed below.
Family A, Single-target (agents)
One exporter = one machine or service. The exporter runs on or next to the target.
| Example | Use |
|---|---|
| Node Exporter | Linux system metrics |
| Windows Exporter | Windows system metrics |
Prometheus configuration (simple):
scrape_configs: - job_name: node static_configs: - targets: ['server1:9100', 'server2:9100']Each target is the exporter itself.
Family B, Service (DB, caches, brokers)
The exporter connects to a service (MySQL, PostgreSQL, Redis…) over TCP with
credentials, then exposes /metrics.
| Example | Use |
|---|---|
| mysqld_exporter | MySQL/MariaDB |
| postgres_exporter | PostgreSQL |
| redis_exporter | Redis |
| mongodb_exporter | MongoDB |
Points to watch:
- Minimum privileges (read-only whenever possible)
- Collection latency → adjust
scrape_timeout - Label cardinality
Family C, Multi-target (proxy/prober)
A single exporter can monitor N targets through a target=... parameter.
This is the multi-target exporter pattern.
| Example | Use |
|---|---|
| Blackbox Exporter | HTTP, DNS, TCP, ICMP probes |
| SNMP Exporter | SNMP network devices |
Why is it different?
- The exporter does not know the targets in advance
- Prometheus passes the target as a parameter through relabeling
- A single exporter can probe hundreds of URLs
Choosing the right tool (decision table)
This table starts from the intent, not from the tool: first state what you want to know, then the family column tells you which kind of configuration to plan. The last row is an exception, since cAdvisor is not an exporter in the strict sense, as the note below explains.
| Intent | Tool | Family | What it measures |
|---|---|---|---|
| Linux machine health | Node Exporter | A | CPU, RAM, disk, network |
| Windows health | windows_exporter | A | Performance counters |
| HTTP/DNS/TCP/ICMP availability | Blackbox Exporter | C | External probes, SSL expiry |
| MySQL/MariaDB health | mysqld_exporter | B | Connections, queries, replication |
| PostgreSQL health | postgres_exporter | B | Connections, locks, bloat |
| Redis health | redis_exporter | B | Memory, keys, ops/sec |
| Container metrics | cAdvisor / kubelet | Source | CPU, RAM, I/O per container |
Full list of official exporters
Node Exporter (Family A)
This is the exporter to deploy first: it collects the system metrics of a Linux machine: CPU, memory, disks, network interfaces. It is installed on every server you want to monitor and listens on port 9100 by default. No configuration is needed to start: the settings only serve to enable or disable collectors.
Installation
The binary is the recommended mode on a physical or virtual machine, because the exporter must see the host system to measure anything. The Docker variant exists but requires several options to share resources with the host, detailed in its tab.
-
Download the archive and the checksum file
Terminal window cd /tmpVERSION="1.12.1"BASE="https://github.com/prometheus/node_exporter/releases/download/v${VERSION}"wget "${BASE}/node_exporter-${VERSION}.linux-amd64.tar.gz"wget "${BASE}/sha256sums.txt"On a minimal Debian 13 installation,
wgetis not installed whilecurlis: runningapt install wgetfirst avoids acommand not foundon the very first command of the procedure. -
Check the digest before extracting
Terminal window sha256sum --ignore-missing -c sha256sums.txtThe output must show the archive line followed by
OK. If it showsFAILED, the archive is corrupted or tampered with: delete it without extracting it. The order matters, and that is the whole point of this step: a digest computed after extraction protects nothing. -
Install
Terminal window tar xvfz node_exporter-${VERSION}.linux-amd64.tar.gzsudo cp node_exporter-${VERSION}.linux-amd64/node_exporter /usr/local/bin/sudo useradd --system --no-create-home --shell /usr/sbin/nologin node_exporterThe
--systemoption is not decorative: without it,useraddpicks from the range of human accounts. Measured on Debian 13, the same account gets UID 1002 without--systemand UID 988 with it, and a UID above 1000 makes a service account show up in login screens and user inventories. Thenode_exportergroup is created automatically because/etc/login.defscontainsUSERGROUPS_ENAB yes: this is what lets the unit ask forGroup=node_exporterwithout any other command. -
Create the service
/etc/systemd/system/node_exporter.service [Unit]Description=Node ExporterWants=network-online.targetAfter=network-online.target[Service]User=node_exporterGroup=node_exporterType=execExecStart=/usr/local/bin/node_exporterRestart=always# HardeningNoNewPrivileges=trueProtectSystem=strictProtectHome=true[Install]WantedBy=multi-user.targetType=execdeserves an explanation, becauseType=simpleis the value you meet most often in exporter units. Both start a foreground process, but they do not tellsystemctl startthe same thing. Tested on systemd 257, Debian 13, with a deliberately missingExecStart:Setting What systemctl startreturnsActual service state Type=simple0, so a success active, although nothing is runningType=exec1, so a failure failedWith
Type=simple, systemd considers the service started as soon as it has forked, without waiting to know whether the binary runs. A typo in the path, or a forgotten copy step, therefore produces a service reported as active and a silent terminal.Type=execwaits forexecve()and reports the failure. -
Start
Terminal window sudo systemctl daemon-reloadsudo systemctl enable node_exportersudo systemctl start node_exporter -
Check that the exporter really answers
An
activeservice proves that the process is running, not that it publishes its metrics. The two commands complement each other:Terminal window systemctl is-active node_exportercurl -s http://localhost:9100/metrics | head -5The first must print
active. The second must open with the two lines of metadata that Prometheus expects at the top of each metric,# HELPthen# TYPE, followed by the values themselves. An empty answer or a refused connection on port 9100 means an exporter that started but does not listen, typically because of a misspelled option inExecStart:journalctl -u node_exporter -n 20will tell you.
docker run -d \ --name node_exporter \ --net host \ --pid host \ -v /:/host:ro,rslave \ quay.io/prometheus/node-exporter:v1.12.1@sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0 \ --path.rootfs=/hostPrometheus configuration
On the Prometheus side, nothing special: each server is declared as an ordinary target, with its exporter port. The job name becomes a label attached to every collected metric, and it will later be used to filter in each query, so choose an explicit one.
scrape_configs: - job_name: 'node' static_configs: - targets: - 'server1:9100' - 'server2:9100'Key metrics
Node Exporter publishes several hundred series; these are enough to cover
everyday monitoring. Note the _total suffix, which marks a cumulative
counter: its raw value is of no interest, only its change over time matters,
hence the use of rate() right after.
| Metric | Description |
|---|---|
node_cpu_seconds_total | CPU time per mode (idle, user, system) |
node_memory_MemAvailable_bytes | Available memory |
node_filesystem_avail_bytes | Available disk space |
node_network_receive_bytes_total | Bytes received per interface |
node_load1, node_load5, node_load15 | Load average |
Useful PromQL queries
These three queries rest on the same principle: Node Exporter provides no
usage percentage, you have to compute it. For the processor, you
start from the time spent in idle mode and subtract it from 100; for memory
and disk, you divide the available space by the total space.
# CPU used (%)100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
# Memory used (%)(1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100
# Disk used (%)(1 - node_filesystem_avail_bytes / node_filesystem_size_bytes) * 100Blackbox Exporter (Family C, Multi-target)
Monitors availability from the outside: HTTP, DNS, TCP, ICMP. This is synthetic monitoring (probes), not internal telemetry.
Why the multi-target pattern?
Blackbox does not run on the targets it monitors. A single instance can
probe hundreds of URLs, because the target is not part of its
configuration: Prometheus passes it at every scrape, in the target parameter
of the HTTP request.
Prometheus queries: GET /probe?target=https://boutique.internal&module=http_2xx
Blackbox answers: probe_success 1 probe_duration_seconds 0.234Installation
One instance is enough for all the targets. The point to decide is not how many to deploy, but where: place it where you want to measure availability from. A probe running from the same datacenter as the service says nothing about what your users experience.
docker run -d \ --name blackbox_exporter \ -p 9115:9115 \ -v $(pwd)/blackbox.yml:/config/blackbox.yml:ro \ prom/blackbox-exporter:v0.28.0@sha256:e753ff9f3fc458d02cca5eddab5a77e1c175eee484a8925ac7d524f04366c2fc \ --config.file=/config/blackbox.ymlBlackbox configuration
The configuration file contains no target: it declares modules, that is
ways of probing. Each module has a name that Prometheus will request at
scrape time. The http_2xx module illustrates the important point: it is the
valid_status_codes that decide whether the probe is a success, so a 404
correctly returned will be counted as a failure.
modules: http_2xx: prober: http timeout: 5s http: valid_http_versions: ["HTTP/1.1", "HTTP/2.0"] valid_status_codes: [200, 201, 204] follow_redirects: true
tcp_connect: prober: tcp timeout: 5s
icmp: prober: icmp timeout: 5s
dns_resolve: prober: dns dns: query_name: "boutique.internal" query_type: "A"Prometheus configuration (relabeling explained)
Relabeling turns a list of URLs into parameters for Blackbox:
scrape_configs: - job_name: 'blackbox-http' metrics_path: /probe params: module: [http_2xx] static_configs: - targets: - https://boutique.internal - https://api.boutique.internal/health - https://docs.boutique.internal relabel_configs: # 1. The URL becomes the ?target= parameter - source_labels: [__address__] target_label: __param_target
# 2. The URL is also copied into the "instance" label - source_labels: [__param_target] target_label: instance
# 3. The real scrape address becomes Blackbox Exporter - target_label: __address__ replacement: blackbox-exporter:9115What happens:
- Prometheus sees
https://boutique.internalin targets - Relabeling turns it into
GET blackbox-exporter:9115/probe?target=https://boutique.internal - The
instancelabel keeps the original URL to identify the metrics
Metrics
All probes produce the same small set of metrics, whatever the module used, which makes alerts uniform: a rule written for an HTTP probe also works for a TCP probe. The last row is an exception in two ways: it is the one people forget to watch, since it lets you be warned of a certificate expiring before the outage, and it is the only one that does not always appear.
| Metric | Description |
|---|---|
probe_success | 1 if the probe succeeded, 0 otherwise |
probe_duration_seconds | Total probe duration |
probe_http_status_code | HTTP code returned |
probe_ssl_earliest_cert_expiry | TLS certificate expiry date, only on an HTTPS probe |
The last row deserves its caveat. Verified on Blackbox 0.28.0: a probe
against an http:// URL produces no probe_ssl_earliest_cert_expiry
series, whereas probe_success, probe_duration_seconds and
probe_http_status_code produce one each. A certificate expiry alert set on a
plain-text endpoint will therefore never fire, and this silence looks very much
like "all is well".
Common alerts
These two rules cover most of what Blackbox brings. The for: 2m of the
first one avoids waking someone up for a transient network incident: the
expression must keep returning at least one series for two minutes in a
row. The wording matters, because a PromQL comparison operator filters the
vector instead of returning a boolean; the
Prometheus configuration (in French)
details this mechanism. The second one compares the certificate expiry date
with the current time and fires thirty days before the deadline, which leaves
time for a renewal.
groups: - name: blackbox rules: - alert: EndpointDown expr: probe_success == 0 for: 2m labels: severity: critical annotations: summary: "{{ $labels.instance }} is down"
- alert: SSLCertExpiringSoon expr: probe_ssl_earliest_cert_expiry - time() < 86400 * 30 for: 1h labels: severity: warning annotations: summary: "SSL cert for {{ $labels.instance }} expires in < 30 days"Database exporters (Family B)
These exporters all work the same way: they open a connection to the engine with a dedicated account, query its internal statistics views and publish the result. Two points of vigilance follow. The account used must have the minimum privileges needed to read the statistics, never administration rights. And the connection string contains a password: it has no place in a Git repository, so pass it through an environment variable or a protected file.
MySQL Exporter
The PROCESS, REPLICATION CLIENT and SELECT privileges are enough to feed
all the exposed metrics. Replace the example password before running anything.
-
Create the MySQL user (minimum privileges)
If the exporter runs on the same machine as MySQL, create the user for
localhost:CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'password';GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';FLUSH PRIVILEGES;If the exporter runs in a Docker container (variant of step 2), MySQL sees it coming from an address of the Docker network: create the user for
%instead. The%accepts all addresses, so only open port 3306 to the Docker network.CREATE USER 'exporter'@'%' IDENTIFIED BY 'password';GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'%';FLUSH PRIVILEGES; -
Run the exporter
Since version 0.15.0,
mysqld_exporterno longer reads theDATA_SOURCE_NAMEvariable. The address and the user are passed as options, the password through theMYSQLD_EXPORTER_PASSWORDvariable.Terminal window export MYSQLD_EXPORTER_PASSWORD='password'./mysqld_exporter \--mysqld.address=localhost:3306 \--mysqld.username=exporterOr with Docker. The exporter and MySQL must share a Docker network (here
monitoring, adapt it), and the options go after the image:Terminal window docker run -d \--name mysqld_exporter \--network monitoring \-p 9104:9104 \-e MYSQLD_EXPORTER_PASSWORD='password' \prom/mysqld-exporter:v0.20.0@sha256:abed8dac117b4ae5b70757f988e44795935b9a72c3b58d720c67ba688f8cb79e \--mysqld.address=mysql:3306 \--mysqld.username=exporterFor this variant, use the
'exporter'@'%'user from step 1. With'exporter'@'localhost', MySQL answersAccess denied.To check the connection, run
curl -s localhost:9104/metrics | grep '^mysql_up': the value must be1. A0means the exporter cannot connect to MySQL. To keep the credentials in a file, the--config.my-cnfoption reads a file in.my.cnfformat ([client]section) instead of the variable. -
Prometheus configuration
- job_name: 'mysql'static_configs:- targets: ['localhost:9104']
Key metrics:
| Metric | Description |
|---|---|
mysql_up | MySQL reachable (1/0) |
mysql_global_status_threads_connected | Active connections |
mysql_global_status_slow_queries | Slow queries |
mysql_global_status_questions | Executed queries |
PostgreSQL Exporter
The configuration fits in a single environment variable in URI format.
The sslmode=disable of the example assumes that the exporter runs on the
same machine as the database; as soon as the connection crosses the network,
switch to sslmode=require or stronger, otherwise the credentials travel in
clear text.
export DATA_SOURCE_NAME='postgresql://exporter:password@localhost:5432/postgres?sslmode=disable'./postgres_exporterKey metrics:
| Metric | Description |
|---|---|
pg_up | PostgreSQL reachable |
pg_stat_activity_count | Connections per state |
pg_stat_database_deadlocks | Deadlocks |
pg_stat_database_tup_fetched | Rows fetched |
Redis Exporter
The instance address is passed as a command-line option. If your Redis requires a password, supply it through the environment variable provided for that purpose rather than in the command: any account on the system can read the process list, and would find it there in clear text.
docker run -d \ --name redis_exporter \ -p 9121:9121 \ oliver006/redis_exporter:v1.91.1@sha256:c67a432dba6b4ae30f471e3c77cf14a289133bbeeb89abb0bb03e6092efb2836 \ --redis.addr=redis://localhost:6379Writing your own exporter
For metrics from a third-party system that no exporter covers, write one.
Python example (relay to an external API)
The official client library does all the work of the format and the
HTTP serving: start_http_server opens the /metrics endpoint, and all
that is left is to update the values. Watch the final loop: the refresh interval
must stay lower than or equal to the Prometheus scrape_interval, otherwise
Prometheus will collect the same value twice and the graph will show a plateau
that does not exist.
from prometheus_client import start_http_server, Gaugeimport requestsimport time
# Define the metricsORDERS_PENDING = Gauge('orders_pending_total', 'Pending orders count')ORDERS_VALUE = Gauge('orders_pending_value_euros', 'Value of pending orders')
def collect_metrics(): """Collect from an external API.""" response = requests.get('https://api.internal/orders/stats') data = response.json() ORDERS_PENDING.set(data['pending_count']) ORDERS_VALUE.set(data['pending_value'])
if __name__ == '__main__': start_http_server(8000) print("Exporter running on :8000/metrics")
while True: collect_metrics() time.sleep(15)Metric types
The type is chosen at declaration and cannot be changed afterwards without breaking existing queries. The fundamental distinction opposes the Counter, which only grows and resets to zero when the process restarts, and the Gauge, which represents an instantaneous value that can go up or down.
| Type | Use | Example |
|---|---|---|
| Counter | Increasing value only | Requests, errors |
| Gauge | Goes up and down | Memory, connections |
| Histogram | Distribution with buckets | Latency |
| Summary | Client-side quantiles | Latency (less recommended) |
Naming conventions
A metric name is public and long-lived: renaming it breaks every dashboard and every alert that uses it. Two rules are enough: prefix with the component name and end with the unit of measure, in base units (seconds and bytes, never milliseconds or megabytes).
namespace_name_unit_suffixmyapp_http_requests_total: compliantmyapp_request_duration_seconds: compliantrequestCount: avoid (no namespace, no unit)
Common pitfalls
Two of these pitfalls deserve particular attention. A /metrics endpoint left
open tells an attacker about your estate, versions and volumes
included, without any authentication. And cardinality, that is the number of
distinct label combinations, is a common cause of a saturated Prometheus:
putting a user ID or a full URL in a label creates one time series per value
encountered.
| Pitfall | Impact | Solution |
|---|---|---|
/metrics exposed without auth | Information leak | Firewall, TLS, basic auth |
| Too many labels | Cardinality explosion | Low-cardinality labels only |
| Scrape interval too short | Exporter overload | 15s-60s depending on criticality |
| Scrape timeout too short | Targets "DOWN" | Adjust scrape_timeout |
Troubleshooting
The first reflex is to query the /metrics endpoint by hand, from the
machine that hosts Prometheus and not from your workstation: a target marked
DOWN is most often so because of network filtering, and the workstation is
not on the same path. If the answer arrives but the expected metrics are
missing, the problem has moved to the permissions of the account used by the
exporter.
| Symptom | Likely cause | Solution |
|---|---|---|
| Exporter not reachable | Firewall/network | curl http://exporter:port/metrics |
| Empty metrics | Missing permissions | Check DB/system rights |
| Scrape timeout | Slow exporter | Increase scrape_timeout |
| Target "DOWN" | DNS/network | Check resolution + ping |
Debug commands:
# Check the endpointcurl -s http://localhost:9100/metrics | head -20
# Check in Prometheus# Status → Targets
# For Blackbox, test the probe manuallycurl "http://localhost:9115/probe?target=https://boutique.internal&module=http_2xx"Key takeaways
- 3 families: single-target (Node), service (MySQL), multi-target (Blackbox)
- Instrumentation > Exporter if you have the code
- Blackbox = synthetic monitoring (external availability)
- Relabeling: essential for the multi-target pattern
- Security: never expose
/metricswithout network protection Type=execin the systemd unit: a missing binary makessystemctl startfail, whereasType=simplereports an active service- Metric quality: component prefix, base unit as suffix, no high-cardinality label (ID, full URL)