Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana-cloud/knowledge-graph/advanced-configuration/enable-prom-metrics-collection/application-frameworks/flask.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana-cloud/knowledge-graph/advanced-configuration/enable-prom-metrics-collection/application-frameworks/flask/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
Configure Flask to generate Prometheus metrics
Flask is a python module that you can enable for Prometheus metrics using Flask Exporter for Prometheus.
To configure Flask to generate Prometheus metrics, perform the following steps:
Add the following export code in the Python module.
from prometheus_flask_exporter import PrometheusMetricsTo enable custom metrics, follow the steps provided in prometheus_flask_exporter.
Verify the presence of the following metrics in Prometheus:
- flask_http_request_duration_seconds
- flask_http_request_total
Metrics
| Metric | Key Performance Indicator(KPI) |
|---|---|
Requests flask_http_request_duration_seconds_count | Request Rate rate(flask_http_request_duration_seconds_count[5m]) |
Errors flask_http_request_duration_seconds_count | Error Ratio rate(flask_http_request_duration_seconds_count{status=~“5..”}[5m])/ rate(flask_http_request_duration_seconds_count[5m]) |
Latency flask_http_request_duration_seconds_bucket flask_http_request_duration_seconds_count | Latency Average rate(flask_http_request_duration_seconds_count[5m])/ rate(flask_http_request_duration_seconds_count[5m]) Latency P99 |
Alerts
| KPI | Alerts |
|---|---|
| Request Rate | RequestRateAnomaly |
| Error Rate | ErrorRatioBreach ErrorBuildup based on a 99.9 SLO |
Latency Average Latency P99 | LatencyAverageBreach LatencyAverageAnomaly LatencyP99ErrorBuildup |
Service KPI dashboard
This dashboard has the following KPIs that include resource and requests metrics:
- Request Rate
- Latency Average
- Latency P99
- Error Rate
- CPU %
- CPU Cores Used
- CPU Throttle
- Memory %
- Memory Bytes
- Disk Usage
- Network Usage

You can include any custom dashboard from the community. For example, this dashboard shows Flask specific metrics directly as a custom dashboard for your service.

Was this page helpful?
Related resources from Grafana Labs


