{"id":20907,"library":"aioprometheus","title":"aioprometheus","description":"A Prometheus Python client library for asyncio-based applications. Version 23.12.0. Supports creating metrics (Counter, Gauge, Histogram, Summary) and exposing them via an async HTTP server or pushing to Pushgateway. Compatible with Python 3.8+. Released regularly on PyPI.","status":"active","version":"23.12.0","language":"python","source_language":"en","source_url":"https://github.com/claws/aioprometheus","tags":["prometheus","asyncio","metrics","monitoring"],"install":[{"cmd":"pip install aioprometheus","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"Counter","correct":"from aioprometheus import Counter"},{"note":"","wrong":"","symbol":"Gauge","correct":"from aioprometheus import Gauge"},{"note":"","wrong":"","symbol":"Histogram","correct":"from aioprometheus import Histogram"},{"note":"","wrong":"","symbol":"Summary","correct":"from aioprometheus import Summary"},{"note":"Old import path removed in 21.x","wrong":"from aioprometheus.middleware import MetricsMiddleware","symbol":"MetricsMiddleware","correct":"from aioprometheus import MetricsMiddleware"},{"note":"","wrong":"","symbol":"Service","correct":"from aioprometheus import Service"},{"note":"Renderer was refactored; use top-level render","wrong":"from aioprometheus.renderer import render","symbol":"render","correct":"from aioprometheus import render"}],"quickstart":{"code":"from aioprometheus import Counter, Service\nimport asyncio\n\nasync def main():\n    counter = Counter(\"requests_total\", \"Total requests\")\n    counter.inc({\"endpoint\": \"/\"})\n    service = Service()\n    service.prometheus_metrics.add_collector(counter)\n    await service.start(addr=\"0.0.0.0\", port=8080)\n    try:\n        await asyncio.Event().wait()\n    finally:\n        await service.stop()\n\nasyncio.run(main())","lang":"python","description":"Create a Counter, register it with a Service, and expose metrics on port 8080."},"warnings":[{"fix":"Update all imports to `from aioprometheus import ...`.","message":"Version 21.x removed the old submodule import paths. Use top-level imports: `from aioprometheus import Counter`, not `from aioprometheus.metrics import Counter`.","severity":"breaking","affected_versions":">=21.0.0"},{"fix":"Pass `accept` as keyword argument if needed.","message":"The `render` function signature changed in 22.x. Previously `render(metrics, accept_header)` now `render(metrics, accept=None)`. Defaults to text format.","severity":"deprecated","affected_versions":">=22.0.0"},{"fix":"Always add the metric to the service's collector: `service.prometheus_metrics.add_collector(my_metric)`.","message":"Metrics must be registered with a collector registry before they are exposed. Not doing so results in empty /metrics output.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from aioprometheus import Counter` instead.","cause":"Importing from old submodules removed in version 21.","error":"ModuleNotFoundError: No module named 'aioprometheus.metrics'"},{"fix":"Pass labels as a dictionary: `counter.inc({\"endpoint\": \"/\"})`.","cause":"Passing labels as keyword arguments or non-dict.","error":"ValueError: The 'labels' argument must be a dict"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}