prometheus-client (Python)

Official Python client for Prometheus metrics. Provides Counter, Gauge, Histogram, and Summary metric types with a built-in HTTP /metrics endpoint for Prometheus scraping. Integrates with WSGI (Flask, Django) and ASGI (FastAPI) applications. Standard library for Python service instrumentation in Prometheus-based monitoring stacks.

Evaluated Mar 06, 2026 (0d ago) v0.20+
Homepage ↗ Repo ↗ Developer Tools prometheus metrics monitoring counter gauge histogram python open-source
⚙ Agent Friendliness
66
/ 100
Can an agent use this?
🔒 Security
83
/ 100
Is it safe for agents?
⚡ Reliability
86
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
82
Error Messages
75
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
82
Auth Strength
80
Scope Granularity
80
Dep. Hygiene
88
Secret Handling
85

/metrics endpoint should be protected — add auth middleware or restrict to internal network. Avoid exposing sensitive data in metric labels. Default metrics include Python runtime info which is acceptable.

⚡ Reliability

Uptime/SLA
88
Version Stability
88
Breaking Changes
85
Error Recovery
82
AF Security Reliability

Best When

Your infrastructure runs Prometheus/Grafana and you need to instrument Python services with standard metrics (requests, errors, latency, custom business metrics).

Avoid When

You don't run Prometheus — use OpenTelemetry with a different metrics backend or a vendor APM SDK.

Use Cases

  • Expose /metrics HTTP endpoint for Prometheus to scrape application metrics (request count, latency, error rate)
  • Track custom business metrics (orders processed, AI completions, queue depth) as Prometheus counters and gauges
  • Measure request latency distribution with Histogram metrics for SLO/SLA tracking
  • Push metrics to Prometheus Pushgateway for short-lived batch jobs that aren't scraped directly
  • Integrate with Grafana dashboards via Prometheus data source for real-time service visualization

Not For

  • Distributed tracing — use OpenTelemetry for traces; prometheus-client is metrics-only
  • Long-term metrics storage — Prometheus handles retention; for extended history use Thanos or Cortex
  • Log-based metrics — use log aggregation pipelines (ELK, Loki) for log-derived metrics

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Library with no auth requirement. /metrics endpoint authentication is application responsibility (add basic auth or IP allowlist in your reverse proxy).

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Free and open source, part of the official Prometheus project.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Metrics with labels have unbounded cardinality risk — using user IDs or request paths as label values causes memory explosion; label values must have low cardinality
  • The default CollectorRegistry is global — tests that register metrics will conflict across test runs; use CollectorRegistry(auto_describe=True) per test
  • WSGI integration (make_wsgi_app()) and ASGI (make_asgi_app()) require separate setup for async frameworks — the standard start_http_server() blocks in async contexts
  • Histogram buckets default to [.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10] seconds — customize buckets to match your actual latency distribution for useful percentiles
  • multiprocess mode (for Gunicorn/uWSGI workers) requires setting PROMETHEUS_MULTIPROC_DIR env var and using MultiProcessCollector — single-process default doesn't work with multiple workers
  • Counter and Histogram metrics cannot be decremented — use Gauge for values that go up and down (queue depth, active connections)

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for prometheus-client (Python).

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered