Prometheus Flashcards
Main components of prometheus ecosystem
- the main Prometheus server which scrapes and stores time series data
- client libraries for instrumenting application code
- a push gateway for supporting short-lived jobs
- special-purpose exporters for services like HAProxy, StatsD, Graphite, etc.
- an alertmanager to handle alerts
- various support tools
PromQL datatypes
- Instance vector
- Range vector
- Scalar
- String
Instance vector
a set of time series containing a single sample for each time series, all sharing the same timestamp
Range vector
a set of time series containing a range of data points over time for each time series
Range vector time selection:
The range is a closed interval, i.e. samples with timestamps coinciding with either boundary of the range are still included in the selection.
Offset modifier
- allows changing the time offset for individual instant and range vectors in a query.
- always needs to follow the selector immediately
@ modifier
- allows changing the evaluation time for individual instant and range vectors in a query. (unix timestamp)
- always needs to follow the selector immediately
vector1 unless vector2
- a vector consisting of the elements of vector1 for which there are no elements in vector2 with exactly matching label sets.
- all matching elements in both vectors are dropped
Binary operations precedence
- *, /, %, atan2
- +, -
- ==, !=, <=, <, >=, >
- and, unless
- or
One-to-one vector matches
- finds a unique pair of entries from each side of the operation.
One-to.one vector match: on / ignoring
- The ignoring keyword allows ignoring certain labels when matching
- the on keyword allows reducing the set of considered labels to a provided list
Aggregation operators: without clause
removes the listed labels from the result vector, while all other labels are preserved in the output.
Aggregation operators: by clause
drops labels that are not listed
Types of rules in prometheus
- recording rules
- alerting rules
To quickly check whether a rule file is syntactically correct
promtool check rules /path/to/example.rules.yml
Recording rules
- allow you to precompute frequently needed or computationally expensive expressions and save their result as a new set of time series
- especially useful for dashboards
Recording / alerting groups
Rules within a group are run sequentially at a regular interval, with the same evaluation time.
Elements of recording rules
- record
- expr
- labels: [ <labelname>: <labelvalue> ]</labelvalue></labelname>
Elements of alerts
- alert (name of alert)
- for: <duration> Alerts are considered firing once they have been returned, otherwise pending</duration>
- keep_firing_for: <duration></duration>
- labels:
- annotations
LIMITING ALERTS AND SERIES
A limit for alerts produced by alerting rules and series produced recording rules can be configured per-group. When the limit is exceeded, all series produced by the rule are discarded, and if it’s an alerting rule, all alerts for the rule, active, pending, or inactive, are cleared as well.
Alertmanager
- handles alerts sent by client applications such as the Prometheus server.
- takes care of deduplicating, grouping, and routing them to the correct receiver integration such as email, PagerDuty, or OpsGenie
- takes care of silencing and inhibition of alerts.
Core concepts of alert manager
- Grouping
- Inhibition
- Silences
- Client behavior
- High Availability