Linux Format

Metrics & visuals in Go

OUR EXPERT

 Mihalis Tsoukalos is a DataOps engineer and a technical writer. He’s the author of Go Systems Programming and Mastering Go, 2nd edition.

The subject of this tutorial is two-fold. First, it’s about creating a Go application that exports metrics to Prometheus, which stores them Second, Grafana reads the data from Prometheus and generates beautiful visualisations. The environment used in this tutorial is constructed using Docker containers. So we’re going to need a Docker image for the Go application, another one for Prometheus and a third one for Grafana.

The Go application will obtain the output of the uptime command and extract the three load averages as well as the number of users in the Linux machine. This means we’re going to send four counters to Prometheus. Because we’re going to execute the Go app as a Docker container, the number of users will be 0.

Bear in mind that the reason the Go application, and all work with HTTP is because Docker images are usually served using a web server such as Nginx or Caddy. This adds the HTTPS layer and forwards connections to the insecure HTTP applications. For reasons of simplicity, we’re not going to include an HTTPS layer in our scenario.

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

More from Linux Format

Linux Format1 min read
Vector Vexations
Why does MySQL not support vectors in its community edition? Generative AI is the hot topic in tech. GenAI relies on vector data. Yet Oracle has no plans to support vectors in the community edition of MySQL. If you want to try out vector data with ot
Linux Format5 min read
Tips For Managing Docker Containers
Everyone knows how containers revolutionised application building and deployment. Using a E disposable stack of containers that make up an app that aren’t using the docker-compose command to manage the stack are missing a trick. It allows the shippin
Linux Format1 min read
Wine For Wayland
2023 was a great year for the Wayland driver for Wine. The goal was to move forward from the experimental phase and make the driver a proper upstream component. A year later, after several merge requests, many people are now already able to use the l

Related Books & Audiobooks