Prometheus - Metrics Collection
Time-series database. Scrapes exporters every 15s, retains data for 30 days / 20 GB, then forwards to VictoriaMetrics via remote_write for long-term storage.
Access
Configuration
Files in ./prometheus/:
| File |
Purpose |
prometheus.yml |
Main scrape configuration |
web.yml |
Basic auth (bcrypt password hash) |
pinghosts.yaml |
Blackbox exporter targets (google.com, github.com) |
hosts |
Local DNS mappings for scraped hosts |
storage/ |
TSDB data (30d retention) |
Startup Parameters
--storage.tsdb.retention.time=30d
--storage.tsdb.retention.size=20GB
--web.config.file=/etc/prometheus/web.yml
Scrape Jobs
| Job |
Target |
Interval |
prometheus |
localhost:9090 (self-monitoring) |
5s |
node-exporter |
acemagic, rpi4, sebas-macpro, asustor-lan1, mycloud, crowdsec:6060 |
15s |
ping-exporter |
acemagic:9427 |
15s |
cadvisor |
cadvisor:8080 (Docker containers) |
15s |
home-assistant |
192.168.1.132:8123/api/prometheus |
10s |
traefik |
traefik:8080 |
5s |
pushgateway |
192.168.1.132:9091 (side-agent push metrics) |
5s |
postgres |
postgres-exporter:9187 |
15s |
smartctl |
smartctl-exporter:9633 (disk S.M.A.R.T.) |
15s |
mktxp |
mktxp:49090 (MikroTik router) |
30s |
wireguard |
172.17.0.1:9586 |
15s |
Remote write: all metrics replicated to http://victoriametrics:8428/api/v1/write.
Dependencies
| Service |
Role |
| VictoriaMetrics |
Long-term archive (remote_write) |
| Grafana |
Reads metrics (as Prometheus-Raw source) |
| Alertmanager |
Receives alerts (alertmanager:9093) |
| All exporters |
Metric sources |
Useful Commands
# Restart
docker compose restart prometheus
# Follow logs
docker compose logs -f prometheus
# Check active targets
curl -s http://localhost:29090/api/v1/targets | jq '.data.activeTargets[] | {job: .labels.job, health: .health}'
# Upgrade
./upgrade-container-by-name.sh prometheus