Prometheus Introduction and fundamentals (Part 1)

Prometheus Introduction and fundamentals (Part 1)

Prometheus is an open-source monitoring system and a Time Series Database (TSDB). The project is established by an engineer (former Google engineer) at SoundCloud. Prometheus was inspired by Google’s BorgMon monitoring system. Currently Prometheus has contributed to CNCF as an incubating project (2016-). Prometheus is second only to Kubernates in terms of popularity.

Prometheus Introduction 簡報

Prometheus has the following features:

  • Multi-dimensional data model
  1. Time series data distinguished by metric name and key/value pairs.
  2. All metrics could be configured as any multi-dimensional labels.
  3. Flexible data model, no need to split with special characters (ex: ,) on purpose.
  4. Data model can be aggregated, sliced and diced
  5. Supporting double-precision floating-point format. Labels can be set as Unicode.
  • Flexible query language (PromQL). Easy to conduct addition, subtraction, multiplication, and division.
  • Not depending on distributed storage. Because Prometheus Server is a single binary file, it could be run at any individual service nodes.
  • Using pull model over HTTP to collect time series data.
  • Data can be pushed via Push Gateway.
  • Supporting multiple dashboard modes visualization, such as Grafana.
  • Using Service Discovery or static configuration to obtain monitored targets.

Prometheus ecosystem contains multiple components (Some of them are optional) as follows:

  • Prometheus Server: Collect and save time series data, and provide support for PromQL query language.
  • Client Library: Provide language development to develop and generate Metrics and expose Prometheus Serve. When Prometheus Server pulls, it returns directly to the metrics of real-time state.
  • Pushgateway: Is mainly used at the ephemeral job pushing. These jobs exist very short. They may disappear when Prometheus pulls, therefore it utilizes a gateway to push.
  • Exporter: is used to expose existing metrics of third-party service to Prometheus Server, which is the HTTP server developed by Client Library. A simple example such as Openstack Exporter, or official reference Exporters and integrations
  • AlertManager: Receive the alert events from Prometheus Server, and send out alerts based on defined Notification configuration, such as e-mail, Pagerduty, OpenGenie, and Webhook.

Prometheus Operations

  1. Prometheus Server pulls metrics periodically from configured jobs or exporters, receives metrics sent from Pushgateway, or pulls metrics from another Prometheus Servers.
  2. Prometheus Server stores received metrics locally, and executes defined alert.rules. And then record new time series or send alert to AlertManager,
  3. AlertManager processes the received events based on the configuration file and send an alert,
  4. Presenting received data in the graphical interface.

Prometheus server pulls the exporter data, queries by using PromQL syntax, and then sends data to Web UI dashboard.

Prometheus triggers Alert Definition defined events, and send them to AlertManager.

AlertManager sends alerts to e-mail and Slack based on configuration.

Prometheus Data Models and Metrics Types

本節將介紹 Prometheus 的資料模型與 Metrics 類型。

Data Model

The stored data of Prometheus are time series data. They mainly consist of metrics name and a series of labels (key-value). Different labels represent different time series. Model information is shown below:

  • Metrics name: This name usually indicates metric functionalities. For example: http_requests_total, which represents the total HTTP request number. Metrics name contains ASCII characters, numbers, English, underscores and colons, and must satisfies the regular expression:  [a-zA-Z_:][a-zA-Z0-9_:]*.
  • Label: This is used to identify the same time series with different dimensions. For example: http_requests_total{method=”Get”} represents all the number of HTTP Get Request. When method=”Post”, it is another new metrics. Label needs to satisfy the regular expression [a-zA-Z_:][a-zA-Z0-9_:]*.
  • Sample: This is an actual time series. Each series include a float64 value and a millisecond time stamp.
  • Format: <metric name>{<label name>=<label value>, …}, for example: http_requests_total{method=”POST”,endpoint=”/api/tracks”}.

Metric Types

Prometheus Client Library supports four major metric types:

  • Counter: an accumulated metrics. This metrics is either increased or reset to 0. For example: number of a HTTP GET errors
  • Gauge: It’s a metric that is irrelevant to time, and can go up and down arbitrarily. For example: memory usage
  • Histogram: Mainly used to indicate data sampling within a certain time period, such as a histogram.
  • Summary: similar to Histogram. Used to indicate total data sampling for a certain period of time.


By 白凱仁 迎棧科技資深工程師


Select list(s)*