aiohttp_prometheus adds support for exporting prometheus metrics to
aiohttp applications. It is implemented as a
aiohttp middleware.
Currently, it exports the following metrics via the /metrics endpoint:
request_latency_seconds: Latency of a request in seconds.- Labels exported:
endpoint,app_name
- Labels exported:
requests_total: Request count.- Labels exported:
app_name,method(HTTP method),endpoint,http_status(HTTP status)
- Labels exported:
requests_in_progress_total: In progress requests.- Labels exported:
app_name,endpoint,method(HTTP method)
- Labels exported:
I will be publishing to PyPI soon, but for now specifying the following in your requirements.txt file will
install the master version of the package from github:
git+http://github.com/amitsaha/aiohttp-prometheus.git#egg=aiohttp_prometheus
The aiohttp_prometheus package exports a single function setup_metrics(app, 'app_name')
which takes in the following arguments:
app: The application object returned viaweb.Application()- The second argument is the web application name which identifies the web application and
used to set the
app_namelabel above
Briefly, the following is all you need to do to measure and export prometheus
metrics from your aiohttp web application:
from aiohttp_prometheus import setup_metrics from aiohttp import web app = web.Application() setup_metrics(app, "mywebapp")
For complete examples, please see examples.
Please file a issue to file a comment, report an issue or make a suggestion.