Prometheus is an open source automated monitoring and Alerting tool used for analyze the logs and send the alerts in case of any failure .
As we all know monitoring our application as well as the infrastructure is really an essence and monitoring distributed applications is a real challenge .
- Prometheus helps us in that area where it scrapes the metrics data from the endpoint using query language(PromQL).
- Can be configured with Grafana which is a data visualization tool used for analyze the metrics data .
- Trigger the alters in case of any misconfiguration in our application .
- And the best part that it is free so community support is good .
Prometheus server :
Is the core component of Prometheus consists of three components .
Client Libraries :
Provides language support for monitoring different applications .
Push gateway :
Push all the collected data to the database but only for short-lived jobs .
It is a script needed for configuration like exposing the /metrics endpoint .
Alert Manager :
Send alerts in case of misconfiguration to different channels like slack, email, notification .
- Data retrieval worker
- Time series database
- HTTP server
- Data retriever helps us to retrieve the data from the application endpoint .
- Time series database stores the metrics data so later they can be retrieved and analyzed .
- HTTP server accepts PromQL query language push the collected data to the dashboard for visualization purpose .
- In case of pull mechanism data retrieval worker pull all the metrics data from the endpoint .
- As a result multiple Prometheus instances can pull metrics data .
- But for short lived jobs like batch jobs which can be pushed to the Prometheus database . In that can we can use the push gateway .
Responsible for sending the alters in case of any failure in the system .
Prometheus have it's own UI to visualize the logs but can be configured with Grafana .
- Linux/windows server
- Web server
- Stateless application
- Statefull application
It totally depends if we are analyzing log of an application or an operating system .
Memory and disk usages
These all are known as metrics which got saved into time series database which then can be visualized .
The third component in our Prometheus server which is a HTTP server which uses PromQL query language and then scrapes the metric data form worker nodes through a HTTP endpoint - hostaddress/metrics
- Some services are exposing to /metrics endpoint by default but many services have not .
- exporter is a script and that fetches metric from the target so that Prometheus can understand that .
Example of a Linux server exporter :
- download node expoter
- untar and execute
- converts metrics of the server
- exposes /metrics endpoint
- configure Prometheus to scrape this endpoint
- Client libraries have different language support for monitoring your application .
- Prometheus stores its on-disk time series data under the directory specified by the flag storage.local.path.
- But can be configured to store the data on a remote location .
In Prometheus.yaml file you can define your desired configuration .
global config defines how often Prometheus will scrape it's targets .
rules for aggregating metric values or creating alerts when condition met .
Scrape config for what resources Prometheus monitor .