DEV Community

Cover image for Prometheus architecture and use cases :
Rahul Kumar
Rahul Kumar

Posted on

Prometheus architecture and use cases :

What is Prometheus :

Prometheus is an open source automated monitoring and Alerting tool used for analyze the logs and send the alerts in case of any failure .

Why use Prometheus :

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 Components :

  • 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 .

  • Exporters :
    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 .

Prometheus Architecture :

Prometheus architecture

Prometheus server :

  1. Data retrieval worker
  2. Time series database
  3. 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 .

push gateway :

  • 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 .

Alert Manager :

Responsible for sending the alters in case of any failure in the system .

Alt Text

Prometheus web UI :

Prometheus have it's own UI to visualize the logs but can be configured with Grafana .


What does Prometheus monitor :

  • Linux/windows server
  • Web server
  • Stateless application
  • Statefull application

which units are monitored of those targets ?

  • It totally depends if we are analyzing log of an application or an operating system .

  • CPU states

  • Memory and disk usages

  • request count

  • request Duration

  • Exception count

These all are known as metrics which got saved into time series database which then can be visualized .

How does Prometheus collects the data :

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

Target endpoint and exporters :

  • 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 :

  • Client libraries have different language support for monitoring your application .

Data storage :

  • 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 .

remote data storage

Configuring Prometheus

  • 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 .

Top comments (0)