Linux Format

Collect and graph metrics with Python

We collect metrics because we want to explore and understand a situation. This is usually because there’s a need to improve the performance of a system and eliminate bottlenecks. Therefore, when collecting metrics, always bear in mind the problem that needs solving or the system that we want to understand better, else the amount of metrics you could collect would become overwhelming! It’s a good idea to have a scenario in mind and then try to collect the appropriate metrics.

This tutorial will explain how to use Python 3 to collect metrics and enable Prometheus to pull and store them, using practical scenarios that include Linux System metrics, and metrics from the timing of database servers.

Prometheus has basic visualisation capabilities that are only useful for debugging purposes. As a result, there’s no point in keeping metrics in Prometheus or any other data storage if you’re not going to visualise them in another piece of software. In this tutorial we’ll visualise the metrics in Grafana, but feel free to use any visualisation software you’re comfortable with.

Docker-compose

For the purposes of this tutorial, we are going to use a docker-compose.yml file to run and use and . Later on, we’re going to add more Docker images,) shows the initial version docker-compose.yml – this version is for running and only because these are the essential parts of the process. The prometheus directory is where the configuration file (prometheus.yml) is stored.

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format1 min read
Running The Risc
It can’t be denied that I am a bit of a Raspberry Pi supporter (and shareholder!). Much of the press and the wider Linux community failed to notice something different about the latest Pico. Rather than featuring a pure Broadcom ARM-based CPU, it inc
Linux Format1 min read
Linux Format
Editor-in-chief Neil Mohr Art editor Fraser McDermott Production editor Katharine Davies Content director Marc Chacksfield Group art director Warren Brown Editorial contributors Mike Bedford, David Bolton, Neil Bothwick, Stuart Burns, Rob Clymo, Barr
Linux Format1 min read
Nvidia fixes Wayland
Nvidia’s latest Linux driver, v560.35.03, released on 21st August, addresses some persistent issues with Wayland, enhancing system stability and performance. Notable fixes include resolving KDE Plasma Shell freezes when running in Wayland compositor

Related