DEV Community

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

Posted on

6 4

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 .

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 .

Billboard image

Monitor more than uptime.

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay