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.
Start your free 30 days