Architecture
Comon exporter with metrics
In Prometheus, exporters are used to expose metrics from various systems, services, or applications in a format that Prometheus can scrape. The metrics follow the Prometheus exposition format, typically accessible via an HTTP endpoint (e.g., /metrics).
Common Prometheus Exporters and Their Metrics
Here’s a list of some widely used exporters along with the types of metrics they provide:
1. Node Exporter (System Metrics)
Exporter URL:
/metricsMetrics:
node_cpu_seconds_total(CPU usage)node_memory_MemTotal_bytes(Total memory)node_memory_MemAvailable_bytes(Available memory)node_filesystem_size_bytes(Disk size)node_network_receive_bytes_total(Network receive bytes)node_network_transmit_bytes_total(Network transmit bytes)
2. cAdvisor (Container Metrics)
Exporter URL:
/metricsMetrics:
container_cpu_usage_seconds_total(CPU usage per container)container_memory_usage_bytes(Memory usage per container)container_network_receive_bytes_total(Network receive per container)container_network_transmit_bytes_total(Network transmit per container)
3. Blackbox Exporter (Probing HTTP, TCP, DNS, ICMP)
Exporter URL:
/probeMetrics:
probe_http_status_code(HTTP status code of probed endpoint)probe_duration_seconds(Response time)probe_success(Boolean for success/failure)
4. Nginx Exporter
Exporter URL:
/metricsMetrics:
nginx_connections_active(Active connections)nginx_connections_accepted(Accepted connections)nginx_http_requests_total(Total HTTP requests)
5. PostgreSQL Exporter
Exporter URL:
/metricsMetrics:
pg_stat_database_xact_commit(Transactions committed)pg_stat_database_xact_rollback(Transactions rolled back)pg_stat_activity_count(Active connections)pg_stat_bgwriter_buffers_alloc(Buffers allocated by background writer)
6. MySQL Exporter
Exporter URL:
/metricsMetrics:
mysql_global_status_queries(Total queries executed)mysql_global_status_threads_connected(Current connections)mysql_global_status_innodb_buffer_pool_reads(Buffer pool reads)mysql_global_status_slow_queries(Slow queries)
7. Redis Exporter
Exporter URL:
/metricsMetrics:
redis_up(1 if Redis is up, 0 if down)redis_memory_used_bytes(Memory used)redis_commands_processed_total(Total commands processed)redis_connected_clients(Number of connected clients)
8. Kubernetes Metrics Server (kube-state-metrics)
Exporter URL:
/metricsMetrics:
kube_pod_status_phase(Pod status: Running, Pending, etc.)kube_node_status_condition(Node health status)kube_deployment_status_replicas_available(Available replicas)kube_persistentvolume_status_phase(PV status: Bound, Released, etc.)
These are just a few of the many available exporters. Do you need help setting up a specific exporter for your use case? 🚀
Metrics Exporter
Prometheus exporters are used to collect and expose metrics from various systems, services, and hardware components. Here’s a comprehensive list of all major Prometheus exporters, categorized based on their use cases.
🔹 System & Hardware Monitoring
1️⃣ Node Exporter – Monitors CPU, memory, disk, and network usage.
prometheus-node-exporter👉 Default system monitoring exporter.
2️⃣ Process Exporter – Collects metrics about specific system processes.
process-exporter3️⃣ Blackbox Exporter – Monitors endpoints (HTTP, DNS, TCP, ICMP).
blackbox_exporter👉 Useful for uptime and SSL certificate expiration checks.
4️⃣ SNMP Exporter – Monitors network devices using SNMP.
snmp_exporter5️⃣ Windows Exporter – Monitors Windows servers (formerly wmi_exporter).
windows_exporter6️⃣ GPU Exporter – Monitors GPU usage (NVIDIA).
dcgm-exporter # For NVIDIA GPUs7️⃣ UPS Exporter – Monitors Uninterruptible Power Supply (UPS) systems.
nut_exporter🔹 Container & Orchestration Monitoring
8️⃣ cAdvisor – Monitors running Docker containers.
google/cadvisor9️⃣ Kube State Metrics – Exposes Kubernetes cluster state metrics.
kube-state-metrics🔟 Kubelet Metrics – Built-in metrics from Kubernetes nodes.
👉 Exposed at: http://<node-ip>:10255/metrics
1️⃣1️⃣ Istio Exporter – Monitors Istio service mesh.
istio-mixer🔹 Database Monitoring
1️⃣2️⃣ PostgreSQL Exporter – Monitors PostgreSQL performance.
postgres_exporter1️⃣3️⃣ MySQL Exporter – Monitors MySQL and MariaDB performance.
mysqld_exporter1️⃣4️⃣ MongoDB Exporter – Monitors MongoDB databases.
mongodb_exporter1️⃣5️⃣ Redis Exporter – Monitors Redis memory, latency, and performance.
redis_exporter1️⃣6️⃣ Elasticsearch Exporter – Monitors Elasticsearch cluster health.
elasticsearch_exporter🔹 Message Queue & Streaming Monitoring
1️⃣7️⃣ Kafka Exporter – Monitors Kafka brokers and topics.
kafka_exporter1️⃣8️⃣ RabbitMQ Exporter – Monitors RabbitMQ queues and messages.
rabbitmq_exporter1️⃣9️⃣ NATS Exporter – Monitors NATS messaging system.
nats_exporter🔹 Web Servers & Proxies Monitoring
2️⃣0️⃣ NGINX Exporter – Monitors NGINX request rates, connections.
nginx-prometheus-exporter2️⃣1️⃣ Apache Exporter – Monitors Apache HTTP server metrics.
apache_exporter2️⃣2️⃣ HAProxy Exporter – Monitors HAProxy load balancer.
haproxy_exporter2️⃣3️⃣ Envoy Proxy Exporter – Monitors Envoy service mesh.
👉 Envoy has built-in /stats/prometheus endpoint.
🔹 Storage & Filesystem Monitoring
2️⃣4️⃣ Ceph Exporter – Monitors Ceph distributed storage.
ceph_exporter2️⃣5️⃣ GlusterFS Exporter – Monitors GlusterFS storage.
gluster_exporter2️⃣6️⃣ NFS Exporter – Monitors NFS server statistics.
nfs_exporter🔹 Network Monitoring
2️⃣7️⃣ Cilium Exporter – Monitors Cilium eBPF-based networking.
cilium-agent2️⃣8️⃣ IPTables Exporter – Monitors Linux firewall rules.
iptables_exporter2️⃣9️⃣ Netdata – A real-time monitoring system with Prometheus support.
netdata🔹 Cloud & SaaS Monitoring
3️⃣0️⃣ AWS CloudWatch Exporter – Pulls AWS CloudWatch metrics.
cloudwatch_exporter3️⃣1️⃣ GCP Stackdriver Exporter – Pulls GCP Stackdriver metrics.
stackdriver_exporter3️⃣2️⃣ Azure Monitor Exporter – Pulls Azure metrics.
azure_metrics_exporter🔹 How to Use an Exporter
Install the exporter on your system (
apt install,docker run, orsystemctl).Start the exporter, which runs on a specific port (
9100,9115, etc.).Configure Prometheus to scrape the exporter’s metrics. Example Prometheus configuration for Node Exporter:
scrape_configs: - job_name: 'node' static_configs: - targets: ['192.168.1.100:9100']
🔹 Conclusion
Exporters help monitor different systems, databases, proxies, and cloud services.
Each exporter runs on a separate port, exposing
/metricsfor Prometheus to scrape.You can combine multiple exporters in your Prometheus setup for full-stack monitoring.
🚀 Now you have the ultimate list of Prometheus exporters! 🔥
Custom Metrics
Custom Metrics for Applications in Python, React, and Rust with Prometheus
If you're building an application and want custom metrics for monitoring, you can expose them using Prometheus client libraries. Here's how to implement it in Python, React (Frontend & Backend), and Rust.
🔹 1. Custom Metrics in Python
Use the prometheus_client library to expose metrics in a Flask/Django/FastAPI app.
📌 Install Prometheus Client
pip install prometheus_client📌 Example: Flask App with Prometheus Metrics
from flask import Flask
from prometheus_client import Counter, Gauge, Histogram, Summary, generate_latest
app = Flask(__name__)
# Define Metrics
REQUEST_COUNT = Counter("http_requests_total", "Total HTTP Requests", ["method", "endpoint"])
RESPONSE_TIME = Histogram("http_request_duration_seconds", "Histogram for response time")
@app.route("/")
def home():
REQUEST_COUNT.labels(method="GET", endpoint="/").inc()
with RESPONSE_TIME.time():
return "Hello, Prometheus!"
@app.route("/metrics")
def metrics():
return generate_latest(), 200
if __name__ == "__main__":
app.run(port=5000)👉 Access Metrics at http://localhost:5000/metrics
🔹 2. Custom Metrics in React (Frontend)
Since React is frontend, it does not expose metrics directly. Instead, you send custom events to a backend (e.g., Node.js, Python) which exposes them.
📌 Example: Tracking Page Load Time
useEffect(() => {
const start = performance.now();
return () => {
const duration = performance.now() - start;
fetch("/track-metrics", {
method: "POST",
body: JSON.stringify({ page_load_time: duration }),
headers: { "Content-Type": "application/json" }
});
};
}, []);👉 Backend processes this data and exposes it via Prometheus.
🔹 3. Custom Metrics in Node.js (React Backend)
Use the prom-client package in an Express.js backend.
📌 Install Dependencies
npm install express prom-client📌 Example: Expose Custom Metrics
const express = require("express");
const client = require("prom-client");
const app = express();
const collectDefaultMetrics = client.collectDefaultMetrics;
collectDefaultMetrics();
const httpRequestDurationMicroseconds = new client.Histogram({
name: 'http_request_duration_seconds',
help: 'Duration of HTTP requests in seconds',
labelNames: ['method', 'route', 'code'],
buckets: [0.1, 0.3, 1.5, 10]
});
app.use((req, res, next) => {
const end = httpRequestDurationMicroseconds.startTimer();
res.on('finish', () => {
end({ method: req.method, route: req.path, code: res.statusCode });
});
next();
});
app.get("/", (req, res) => res.send("Hello, Prometheus!"));
app.get("/metrics", async (req, res) => {
res.set("Content-Type", client.register.contentType);
res.send(await client.register.metrics());
});
app.listen(5000, () => console.log("Server running on port 5000"));👉 Access Metrics at http://localhost:5000/metrics
🔹 4. Custom Metrics in Rust
Rust uses the prometheus crate for metrics.
📌 Install Dependencies
[dependencies]
prometheus = "0.13"
warp = "0.3"
tokio = { version = "1", features = ["full"] }📌 Example: Expose Metrics in a Warp Web Server
use prometheus::{Encoder, TextEncoder, Counter, Gauge, Registry};
use warp::Filter;
#[tokio::main]
async fn main() {
let registry = Registry::new();
let counter = Counter::new("requests_total", "Total number of requests").unwrap();
let gauge = Gauge::new("in_progress_requests", "Requests in progress").unwrap();
registry.register(Box::new(counter.clone())).unwrap();
registry.register(Box::new(gauge.clone())).unwrap();
let metrics = warp::path("metrics").map(move || {
let mut buffer = Vec::new();
let encoder = TextEncoder::new();
encoder.encode(®istry.gather(), &mut buffer).unwrap();
warp::reply::with_header(buffer, "Content-Type", encoder.format_type())
});
let routes = warp::path("hello").map(|| {
counter.inc();
gauge.set(1.0);
warp::reply::html("Hello, Prometheus!")
});
warp::serve(metrics.or(routes)).run(([0, 0, 0, 0], 3030)).await;
}👉 Access Metrics at http://localhost:3030/metrics
Custom Metrics for Java Applications with Prometheus
If you're developing a Java application and want to expose custom metrics, you can use the Prometheus Java client library (io.prometheus), typically in a Spring Boot or Jakarta EE application.
🔹 1. Setting Up Prometheus in Java (Spring Boot Example)
📌 Add Dependencies (Maven)
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>0.16.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<version>0.16.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_httpserver</artifactId>
<version>0.16.0</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>👉 If using Gradle, add:
dependencies {
implementation 'io.prometheus:simpleclient:0.16.0'
implementation 'io.prometheus:simpleclient_hotspot:0.16.0'
implementation 'io.prometheus:simpleclient_httpserver:0.16.0'
implementation 'io.micrometer:micrometer-registry-prometheus'
}🔹 2. Expose Basic Metrics
📌 Create a Prometheus Endpoint
import io.prometheus.client.Counter;
import io.prometheus.client.exporter.HTTPServer;
import io.prometheus.client.hotspot.DefaultExports;
import java.io.IOException;
public class PrometheusMetrics {
private static final Counter requestCounter = Counter.build()
.name("http_requests_total")
.help("Total HTTP Requests")
.labelNames("method", "endpoint")
.register();
public static void main(String[] args) throws IOException {
// Start Prometheus HTTP server on port 9091
HTTPServer server = new HTTPServer(9091);
// Expose default JVM metrics
DefaultExports.initialize();
// Simulate a request
handleRequest("GET", "/home");
}
private static void handleRequest(String method, String endpoint) {
requestCounter.labels(method, endpoint).inc();
}
}👉 Access metrics at: http://localhost:9091/metrics
🔹 3. Advanced Metrics
📌 Gauge (For Current Values)
import io.prometheus.client.Gauge;
public class ExampleGauge {
private static final Gauge activeUsers = Gauge.build()
.name("active_users")
.help("Number of active users")
.register();
public static void main(String[] args) {
activeUsers.inc(); // Increase user count
activeUsers.dec(); // Decrease user count
}
}📌 Histogram (For Response Time)
import io.prometheus.client.Histogram;
public class ExampleHistogram {
private static final Histogram responseTime = Histogram.build()
.name("http_request_duration_seconds")
.help("Histogram for response time")
.buckets(0.1, 0.5, 1, 2, 5)
.register();
public static void main(String[] args) {
Histogram.Timer timer = responseTime.startTimer();
try {
simulateRequest();
} finally {
timer.observeDuration();
}
}
private static void simulateRequest() {
try {
Thread.sleep(500); // Simulate 500ms request
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}🔹 4. Spring Boot Integration (Auto-Expose Metrics)
If you're using Spring Boot, it has built-in Prometheus support with micrometer.
📌 Add Actuator Dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>📌 Enable Prometheus in application.properties
application.propertiesmanagement.endpoints.web.exposure.include=metrics,prometheus
management.metrics.export.prometheus.enabled=true👉 Access metrics at: http://localhost:8080/actuator/prometheus
🔹 5. Exposing Custom Metrics in Spring Boot
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class CustomMetrics {
private final MeterRegistry registry;
public CustomMetrics(MeterRegistry registry) {
this.registry = registry;
}
@PostConstruct
public void initMetrics() {
registry.counter("custom_requests_total", "type", "demo").increment();
}
}🔹 Summary
✅ Basic Metrics – Use Counter, Gauge, Histogram for tracking requests.
✅ JVM Monitoring – DefaultExports.initialize(); to track CPU, memory.
✅ Spring Boot – micrometer exposes metrics automatically via /actuator/prometheus.
✅ Expose Custom Metrics – Use Prometheus client to track users, response time, or request count.
🚀 With this setup, you can monitor your Java app efficiently with Prometheus!
🔹 Summary
Python – Use
prometheus_clientin Flask/FastAPI/Django.React (Frontend) – Send custom events to a backend.
Node.js (Backend) – Use
prom-clientin an Express app.Rust – Use
prometheuscrate withwarporactix-web.
🚀 With this, you can monitor your apps like a pro using Prometheus!
Last updated