Skip to content

Prometheus Exporters: Node Exporter, cAdvisor & Custom

DodaTech 3 min read

In this tutorial, you'll learn about Prometheus Exporters: Node Exporter, cAdvisor & Custom. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Exporters are Prometheus components that collect metrics from third-party systems and expose them in the Prometheus format, enabling monitoring of databases, hardware, containers, and custom applications that do not natively expose Prometheus metrics.

What You'll Learn

In this tutorial, you will install Node Exporter for system metrics, deploy cAdvisor for container monitoring, create a custom exporter for your application, and configure scrapes for all of them.

Why It Matters

Most systems do not natively speak Prometheus. Your Linux server does not expose CPU metrics on an HTTP endpoint. Your database does not serve query latency at /metrics. Exporters bridge this gap. Without them, Prometheus can only monitor applications that you have instrumented yourself.

Real-World Use

Durga Antivirus Pro uses a custom exporter that exposes the number of virus definitions, last update timestamp, scan queue depth, and scan throughput. Operations dashboards combine Node Exporter data (CPU, memory, disk) with the custom exporter data to give a complete view of each scanner node.

Node Exporter

Node Exporter exposes hardware and OS metrics for Linux and Unix systems. Install and run it:

wget https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz
tar xvf node_exporter-1.8.0.linux-amd64.tar.gz
cd node_exporter-1.8.0.linux-amd64
./node_exporter

Expected output:

ts=2026-06-21T10:00:00.000Z caller=node_exporter.go:115 level=info msg="Starting node_exporter" version=1.8.0
ts=2026-06-21T10:00:00.000Z caller=node_exporter.go:116 level=info msg="Build context" ...
ts=2026-06-21T10:00:00.000Z caller=node_exporter.go:146 level=info msg="Listening on" address=:9100

Test it at http://localhost:9100/metrics. You will see hundreds of metrics including node_cpu_seconds_total, node_memory_MemTotal_bytes, node_disk_io_time_seconds_total, and node_network_receive_bytes_total.

cAdvisor

cAdvisor provides container resource usage metrics for Docker and Kubernetes. Run it as a container:

sudo docker run --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:ro \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --publish=8080:8080 \
  --name=cadvisor \
  gcr.io/cadvisor/cadvisor:latest

cAdvisor exposes metrics at http://localhost:8080/metrics including container_cpu_usage_seconds_total, container_memory_usage_bytes, and container_network_receive_bytes_total.

Creating a Custom Exporter

For applications that do not have an existing exporter, write a custom one in Python using the <a href="/devops/prometheus-grafana/">Prometheus</a>_client library:

from prometheus_client import start_http_server, Gauge
import time
import random

request_latency = Gauge("app_request_latency_seconds", "Request latency in seconds", ["endpoint"])
active_users = Gauge("app_active_users", "Currently active users")

def collect_metrics():
    request_latency.labels(endpoint="/api").set(random.uniform(0.01, 2.0))
    active_users.set(random.randint(10, 100))

if __name__ == "__main__":
    start_http_server(8000)
    while True:
        collect_metrics()
        time.sleep(15)

Configure Prometheus Scrapes

Add each exporter as a scrape target in <a href="/devops/prometheus-grafana/">Prometheus</a>.yml:

scrape_configs:
  - job_name: node
    static_configs:
      - targets:
          - server1:9100
          - server2:9100

  - job_name: cadvisor
    static_configs:
      - targets:
          - server1:8080

  - job_name: custom-app
    static_configs:
      - targets:
          - app-server:8000

Common Mistakes

1. Running Exporters Without Authentication

Exporters expose sensitive system metrics. Use firewall rules, reverse proxy authentication, or the --web.config flag for TLS and basic auth.

2. Too Many Collectors Enabled

Node Exporter by default enables all collectors. Disable unnecessary ones with --no-collector.<name> to reduce resource usage.

3. Not Pinning Exporter Versions

Always pin exporter versions in production to avoid breaking changes in metric names or labels.

4. Forgetting to Reload Prometheus Config

After adding new targets, reload Prometheus. Scrapes only start after the configuration is reloaded.

5. Custom Exporter Without Error Handling

A crash in your custom exporter stops metrics collection. Add recovery logic and run the exporter behind a Process manager.

Practice Questions

1. What is the purpose of a Prometheus exporter? It collects metrics from a system that does not natively expose Prometheus metrics and serves them at an HTTP endpoint in Prometheus format.

2. What metrics does Node Exporter provide? System-level metrics: CPU usage, memory usage, disk I/O, network traffic, load average, disk space, and hardware temperature.

3. What is cAdvisor used for? Container resource monitoring. It exposes CPU, memory, network, and filesystem metrics for running Docker containers.

4. How do you create a custom exporter for your application? Use the Prometheus client library for your language (Python, Go, Java, etc.) to define metrics, then serve them on an HTTP endpoint.

5. Challenge: Write a custom exporter that exposes database Connection Pool metrics (active connections, idle connections, connection wait time) and add it as a scrape target.

What's Next

Use recording rules to precompute expensive PromQL queries from exporter data, speeding up dashboards and alerting.

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro