Adding an endpoint for Prometheus
Let’s see how to add an endpoint to our existing Compose endpoints. The code base that will be used in this chapter will be the code base that we created in Chapter 5, Connecting Microservices. We should update the code base and add the endpoints that will enable Prometheus to scrap metrics from our applications.
Adding the metrics endpoint to the Task Manager
Adding Prometheus to an HTTP-based Go application is streamlined. By following the instructions online (https://prometheus.io/docs/guides/go-application), we can find the following go get
commands that will download the necessary libraries to use with our Go application:
$ go get github.com/prometheus/client_golang/prometheus $ go get github.com/prometheus/client_golang/prometheus/promauto $ go get github.com/prometheus/client_golang/prometheus/promhttp
The default way to add a Prometheus endpoint is by using the Go http
server:
func main() { ...