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
Video Stars
Italo Vignoli is one of the founders of LibreOffice and the Document Foundation. “LibreOffice 24.8 was announced in August, and at the same time the documentation team released the Getting Started Guide. This was the first time the manual was immedia
Linux Format3 min read
Ubuntu Unity 24.10
The Unity interface was originally developed as an alternative to Gnome 2 by Canonical and included in Ubuntu from April 2011. Ultimately, Canonical abandoned Unity in favour of switching back to Gnome. This decision didn’t sit well with Ubuntu devel
Linux Format3 min read
Stay Alert With System Email Warnings!
Within Linux, lots of jobs send output to various log files and emails to users. Thing is, forwarding this important information to the appropriate users is more complicated than needed. It used to involve setting up sendmail servers and all sorts of

Related Books & Audiobooks