Ravindra BagaleCourses & study guides मराठी

Chapter 87: Prometheus and Grafana Monitoring

DevOps

87.4 Exporters and /metrics on apps

Story. A Zomato-style city team in Kolkata already had node_exporter on every VM. Their Go menu API still had no business metrics. Anika added a Prometheus client library, exposed /metrics on port 8080, and scraped menu_orders_total. Infra CPU graphs stayed; product now saw orders per second too.

Node exporter for hosts. App /metrics for business. Blackbox for probes. All scraped by Prometheus.
Node exporter for hosts. App /metrics for business. Blackbox for probes. All scraped by Prometheus.

Why

Host metrics do not know if checkout failed. App metrics do not know if the disk is full. You need both.

What

  • Exporter — A small process that turns system or software stats into Prometheus metrics (node_exporter, mysqld_exporter, and others).
  • /metrics — The usual HTTP path that returns Prometheus text format.
  • Instrumentation — Code in your app that increments counters and sets gauges.
  • blackbox_exporter — Probes URLs/TCP from outside and exposes probe success and latency.

How

  1. Run node_exporter on hosts (or use kube-prometheus-stack defaults on Kubernetes).
  2. Add a client library in your app language; expose /metrics.
  3. Add a scrape job (or ServiceMonitor) for that port.
  4. Confirm with curl before you trust Grafana.

Example 1: Curl an exporter

curl -s http://127.0.0.1:9100/metrics | head -n 5

Output

# HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.
# TYPE node_cpu_seconds_total counter
node_cpu_seconds_total{cpu="0",mode="idle"} 10422.87

What it shows: Prometheus text format: HELP, TYPE, then samples with labels.

Example 2: App counter line

# HELP menu_orders_total Total menu orders accepted.
# TYPE menu_orders_total counter
menu_orders_total{city="kolkata"} 1842

What it shows: Your app exported a business counter. Scrape it like any exporter.

Ravindra Bagale's Tip

Never put passwords or tokens in metric label values. Labels are stored forever and show up in UIs.

Quick quiz

Q1. What does node_exporter give you?

Host metrics such as CPU, memory and disk in Prometheus format.

Q2. What is instrumentation?

App code that exposes its own /metrics counters and gauges.

Q3. Why avoid secrets in labels?

Labels are stored and visible; they are not a secret store.

Did you understand? Let us try it once more.