Monitoring applications
There are a variety of ways to monitor Go applications. One of the easiest ways is to set up Prometheus, a monitoring application written in Go (https://prometheus.io). This is an application that polls an endpoint based on your configuration file and collects a lot of information about your app, including the number of goroutines, memory usage, and much more. This app will use the techniques from the previous recipe to set up a Docker environment to host Prometheus and connect to it.
Getting ready
Configure your environment according to these steps:
- Refer to the Getting ready section of the Using containerization with Docker recipe.
- Run the
go get github.com/prometheus/client_golang/prometheus/promhttp
command.
How to do it...
These steps cover writing and running your application:
- From your terminal/console application, create the
chapter10/monitoring
directory and navigate to it. - Copy tests from https://github.com/agtorre/go-cookbook/tree/master/chapter10/monitoring or...