Setting up Prometheus and Grafana
Before using Prometheus and Grafana in our own application, let's take a look at how Prometheus works in principle.
Prometheus's basics
Unlike other monitoring solutions, Prometheus works by pulling data (called metrics in Prometheus jargon) from clients at regular intervals. This process is called scraping. Clients monitored by Prometheus have to implement an HTTP endpoint that can be scraped by Prometheus in a regular interval (by default, 1 minute). These metrics endpoints can then return application-specific metrics in a predefined format.
For example, an application could offer an HTTP endpoint at /metrics that responds to GET requests and returns the following body:
memory_consumption_bytes 6168432
http_requests_count{path="/events",method="get"} 241
http_requests_count{path="/events",method="post"} 5
http_requests_count{path="/events/:id",method="get"} 125 This document exposes two metrics—memory_consumption_bytes and http_requests_count. Each metric...