Prometheus has several components which help in the overall monitoring of your application. These components of the architecture are:
Prometheus Server
The server is the brain of any web or mobile application. The scraping and storing of metrics are handled by the Prometheus server.
It collects multi-dimensional data in time series and then analyzes and aggregates the collected data.
Push Gateway
Although Prometheus is largely a pull-based monitoring system,
it includes a "Pushgateway" component that allows metrics from other applications and services to be pushed in.
The Pushgateway is useful for gathering metrics from systems that aren't compatible with the rest of the infrastructure, which is pull-based.
Alert Manager
Alertmanager is responsible for managing the alerts sent by the clients.
It checks for supplication, groups the signals, and routes them to the correct application like email, Pagerduty, Opsgenie, etc.
It also checks for when it should keep alerts off and when not.
Prometheus Targets
Prometheus targets represent how Prometheus extracts metrics from a different resource. In many cases, the metrics are exposed by the services themselves, such as Kubernetes.
In this case, Prometheus collects metrics directly. But in some instances, like in unexposed services, Prometheus has to use exporters.
Client Libraries
As we all know, Prometheus collects data in time-series formats that are multi-dimensional.
So clients are always asked to send in this form specifically.
But in most cases, metrics rules are not automatically written; instead, you need to add them manually.
So for making metrics in Prometheus-compatible formats, there are two ways. It can be done manually on the client-side or use third-party exporters to convert data in Prometheus formats.
When you control the client’s source code, you can go ahead with the first option; otherwise, second.
Prometheus Exporters
Exporters are third-party tools that help scrape metrics when it is not feasible to extract metrics directly.
Libraries and servers that assist in the exporting of existing metrics from third-party systems as Prometheus metrics are exporters.
When directly instrumenting a system with Prometheus is not practicable, exporters come in handy.
Exporters can be thought of as "single-purpose monitoring agents" that collect metrics from a specific third-party system and make them available for collection by Prometheus servers.
Service Discovery
In the Prometheus Targets section, we discussed using static-config files to configure the dependencies manually.
This process is ok when you have simple uses with the config file, but what if you have to do this in a large amount?
Service discovery helps in providing Prometheus the information of what to escape in whichever database you want.
Prometheus’ common service discovery resources are Consul, Amazon’s EC2, and Kubernetes out of the box.
Data Visualization
The Prometheus web app offers a built-in function called an "expression browser," which allows users to directly enter any expression and see the output in a table or graph over time.
However, Grafana or Prometheus Console templates are advised for actual graphs; this is advertised as mostly useful for ad-hoc searches and debugging.