On this page
Prometheus Operations Manual
Prometheus is a time-series database combined with a monitoring and alerting engine. Core concepts: target (collection target), metric (indicator), label (dimension), rule (recording rule + alerting rule), TSDB (time-series storage).
Target
# API query target status
|
# health: "up" = normal, "down" = collection failed
# lastError: reason for the last failure (timeout/connection refused/format error)
# Check which instances have an up metric of 0 (unreachable)
|
# Web UI: http://localhost:9090/targets
# → You can see each target's labels, last scrape time, scrape duration, errors
Configuration and Hot Reload
# Check configuration syntax
# Hot reload (no restart, no data loss, only reloads rules + targets)
# Or: curl -X POST http://localhost:9090/-/reload
Typical prometheus.yml structure:
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- /etc/prometheus/rules/*.yml
scrape_configs:
- job_name: node
static_configs:
- targets:
labels:
TSDB Management
# Data directory (a block directory is generated every 2 hours)
# TSDB status (number of series, memory usage, number of blocks)
|
# headStats.numSeries: number of currently active series (> 1M needs attention)
# headStats.chunkCount: number of chunks in memory
# Delete old data (requires --web.enable-admin-api startup parameter, disabled by default)
# After marking for deletion, clean_tombstones is required
# Snapshot (full data backup)
# → /var/lib/prometheus/data/snapshots/<timestamp>/
# Snapshots can be copied directly to another Prometheus instance
Query Debugging
# Instant query
|
# Range query (step = sampling interval)
|
# List all label values
|
|
Troubleshooting
# Target down
# → timeout → firewall/systemd/port binding issue
# → 200 but empty → exporter is running but has no data
# High memory usage
# → High cardinality labels (e.g., request_id, user_id) create a new series for each unique value
# → Check: curl http://localhost:9090/api/v1/status/tsdb | jq '.data.headStats.numSeries'
# → Over 1 million → consider reducing label dimensions or using recording rules for pre-aggregation
# Slow queries/timeouts
# → Check the query's range and step: larger range + smaller step → more data points
# → Use recording rules to pre-calculate common queries