Summary
In this chapter, we described what metrics are and how they compare with logs. We described how metrics are useful to analyze the general state of the system, while logs describe specific tasks, being more difficult to describe the aggregated situation.
We enumerated different kinds of metrics that can be produced and described Prometheus, a common metrics system that uses the pull approach on how to capture metrics.
We set an example of how to generate metrics automatically in Django by installing and configuring the django-prometheus
module, and how to start a Prometheus server that scrapes the generated metrics.
Keep in mind that you can also generate your own custom metrics, not having to only rely on the ones in an external module. Check the Prometheus client to see how, for example, for Python: https://github.com/prometheus/client_python.
Next, we described how to query metrics in Prometheus, introducing PromQL, and showed some common examples...