๐ Application Monitoring
Monitoring System Performance with Prometheus & Grafana¶
Do you want to gain more insight into the performance of your system? With Prometheus and Grafana, it's easy to monitor key metrics and get a comprehensive view of what is occurring within your system.
We are using Prometheus, a time-series database and monitoring solution, and Grafana, a user-friendly dashboard, to collect and visualize important metrics. The Panini built-in Prometheus Monitoring Middleware is used to collect message rate by subject, request status, and request latency. After collecting, it periodically sends these metrics to the Prometheus Gateway, which is reflected directly in your Grafana dashboard.
Initializing the Monitoring¶
Firstly, ensure that you have Prometheus and Grafana up and running. Next, add the Prometheus Monitoring Middleware to the app:
from panini.middleware.prometheus_middleware import PrometheusMonitoringMiddleware
app.add_middleware(PrometheusMonitoringMiddleware)
# you could also specify some custom parameters (see details in middleware constructor):
# app.add_middleware(PrometheusMonitoringMiddleware, PROMETHEUS_GATEWAY, frequency=30)
PrometheusMonitoringMiddleware parameters:
- pushgateway_url: str = "localhost:9091" - url to Prometheus PushGateway
- app = None - panini App
When this is done, application activity will be stored in Prometheus and reflected in the Grafana dashboard.
Using Grafana & Prometheus¶
You can use our dashboard template or create your own. To get started, check out this screenshot of the dashboard
To learn more about setting up Grafana & Prometheus, take a look at our guide.