Grafana Dashboard for Prometheus official Python client with Flask App metrics

I’ve just open-sourced my Grafana dashboard. The dashboard designed for a Flask web application that exposes metrics with my flask_prometheus_metrics Flask extension.

Dashboard aimed at the apps deployed with Kubernetes, although it can be easily tweaked to be infrastructure-agnostic.

Grfana dashboard: RPS and latency panels

12 dasboard’s panels covers the following metrics:

  • Requests per second per host, endpoint, HTTP method etc.
  • Latency
  • Percentiles (latency within which certain percent of requests served)
  • Number of 4xx, 5xx errors per second
  • Error count by endpoint
  • CPU usage per host
  • Memory usage per host
  • Open file descriptors per host
  • App’s uptime per host
  • App’s version per host
  • App’s deployment environment (e.g. development, staging, production) per host
  • Python interpretor version per host
Grfana dashboard: errors and resource usage

Dashboard also provides variables:

  • Prometheus datasource
  • Time interval
  • Kubernetes pod name
  • App’s endpoint
  • HTTP method
  • Percentile
  • HTTP status code for errors
Grfana dashboard: app's information

The variables allow to change some panels charts grouing, intervals, labels selection.

Usage is easy:

  1. Install flask_prometheus_metrics exporter to your Flask application
  2. Make Prometheus scraping your app’s /metrics endpoint
  3. Import flask-web-app.json at https://<your-grafana-domain>.tld/dashboard/import

If you do not deploy your app in Kubernetes you may need to tweak flask-web-app.json pod labels to meet your needs. Instead of pod you may use instance or hostname or other label name depending on how your Prometheus handle your app’s hostname.