
Prometheus Has a Free API: Here's How to Use It for Metrics Automation
Prometheus is the industry standard for metrics collection, and its HTTP API is completely free to use. You can query metrics, manage alerts, check targets, and build custom monitoring tools — all via simple HTTP calls. Why Use the Prometheus API? Query any metric with PromQL via HTTP Build custom dashboards without Grafana Automate alert management and silence rules Monitor scrape targets and their health status Getting Started Prometheus API runs on port 9090 by default: # Instant query curl -s "http://localhost:9090/api/v1/query?query=up" | jq '.data.result[] | {instance: .metric.instance, job: .metric.job, value: .value[1]}' # Range query (last hour, 15s steps) curl -s "http://localhost:9090/api/v1/query_range?query=rate(http_requests_total[5m])&start= $( date -d '1 hour ago' +%s ) &end= $( date +%s ) &step=15" | jq '.data.result[0].values | length' Python Client import requests from datetime import datetime , timedelta PROM_URL = " http://localhost:9090 " def query_instant ( promq
Continue reading on Dev.to
Opens in a new tab



