Day 79 - Prometheus 🔥

3 min read

Cover Image for Day 79 - Prometheus 🔥

It's an open-source system for monitoring services and alerts based on a time series data model. Prometheus collects data and metrics from different services and stores them according to a unique identifier—the metric name—and a time stamp.

1. Architecture of Prometheus Monitoring: Prometheus follows a pull-based model for collecting metrics from monitored targets. The basic architecture consists of the following components:

  • Prometheus Server: This is the core component responsible for collecting, storing, and querying metrics data. It periodically scrapes metrics from configured targets (e.g., applications, services, or system components) using HTTP, HTTPS, or other protocols.

  • Exporters: Exporters are agents or libraries that expose metrics from various services and systems in a format that Prometheus can scrape. For example, the Node Exporter collects metrics from Linux systems, and the Blackbox Exporter collects network-related metrics.

  • Targets: Targets are the entities or endpoints that Prometheus scrapes metrics from. These can be application instances, databases, or any system-generating metrics.

  • Alertmanager: The Alertmanager is responsible for handling alerts generated by Prometheus. It can group, deduplicate, and route alerts to various notification channels (e.g., email, Slack, PagerDuty) based on defined rules.

  • Grafana (Optional): While not a part of Prometheus itself, Grafana is often used alongside Prometheus for data visualization and dashboarding. It connects to Prometheus to create rich, customizable dashboards.

2. Features of Prometheus: Prometheus offers several key features, including:

  • Multi-dimensional Data Model: Prometheus uses a data model with key-value pairs, allowing for flexible queries and aggregation over time series data.

  • PromQL Query Language: It provides a powerful query language (PromQL) for extracting and analyzing metrics data.

  • Alerting: Prometheus supports alerting based on user-defined rules and conditions, with integration into the Alertmanager for notifications.

  • Scalability: Prometheus is horizontally scalable, allowing you to deploy multiple Prometheus servers and federate data from various sources.

  • Service Discovery: It supports dynamic service discovery to automatically discover and monitor new instances as they come online.

  • Retention and Data Storage: Prometheus retains metrics data for a configurable retention period, making it suitable for both short-term and long-term monitoring.

3. Components of Prometheus: As mentioned earlier, the core components of Prometheus include the Prometheus server, exporters, targets, and the Alertmanager. Additionally, there are several other components and libraries available in the Prometheus ecosystem, such as the Pushgateway (for pushing metrics), the Prometheus Operator (for managing Prometheus deployments), and various exporters for different services and platforms.

4. Database used by Prometheus: Prometheus uses its custom time-series database for storing metrics data. It doesn't rely on external databases like MySQL, PostgreSQL, or NoSQL databases. The Prometheus database is optimized for the high-frequency, high-cardinality, and time-series nature of monitoring data.

5. Default Data Retention Period in Prometheus: The default data retention period in Prometheus is 15 days. After this period, Prometheus automatically prunes (deletes) older data to maintain the configured retention window. You can adjust the retention period by configuring the --storage.tsdb.retention.time flag when starting the Prometheus server.