Introduction
Prometheus
Prometheus is a metrics engine that ingest data and lets query them in order to get data aggregations and statistics. It stores metrics inside a time series database and persists them on local disk. Through the dashboard, we can get all the values collected by Prometheus and makes different aggregations.
The Prometheus server, which acts as the system’s “brain” by collecting various metrics and storing them in a time-series database. Unlike other systems monitoring tools that wait passively to receive information, Prometheus actively scrapes metrics from applications and services (e.g. Docker containers) at designated intervals using the Prometheus client libraries.
Grafana
Beside of Prometheus, for displaying metrics and data in a human-readable format. In addition to native Prometheus visualization, many Prometheus users integrate the tool with Grafana, an open-source web application for analytics and data visualization.
Grafana enables you to query, visualize, alert on, and explore your metrics, logs, and traces wherever they are stored. Grafana provides you with tools to turn your time-series database (Prometheus in this case) data into insightful graphs and visualizations.
Pushgateway
As discussed above, Prometheus scrapes data from your applications and services at regular intervals. but what if those intervals are still too slow to capture valuable information? Many short-lived and batch jobs complete so quickly that their lifespans are shorter than the Prometheus scrape interval itself, making it tricky or impossible to capture metrics from them at runtime.
Or maybe what if the source doesn’t have a valid address to scrape by prometheus, then we will need to send metrics from the source instead.
Prometheus Pushgateway sounds like a tremendously useful tool for capturing data from jobs that are difficult to scrape.
Setup using Docker Compose
💡 You can find the source code in the Github repository
- Create the working directory
|
|
- Create the
docker-compose.yml
|
|
- Create the Promethus config file
|
|
And make this file within the directory:
|
|
- Deploy the
docker-compose.yml
file
|
|
- Now you must have the enpoints up and running. Lets test and make sure:
- Prometheus: http://localhost:3000
- Pushgateway: http://localhost:3001
- Grafana: http://localhost:3002
Sending metrics to Pushgateway
We can send metrics to Pushgateway using http requests. for a simple one we can POST
to the endpoin in this format:
|
|
Using cURL
|
|
Using Axiso in Javascript
|
|
Done 🙂