Understanding PromQL

Understanding PromQL

An introduction to the PromQL query language

Course Description

PromQL is one of the core features of Prometheus, allowing for powerful analysis and processing of time series.

Although QL is in the name, it is not related to SQL. Relational algebra doesn't work too well for typical calculations on multi-dimensional time series. Syntax wise, PromQL is closest to expressions in the C family of languages.

This course looks at each of the components of PromQL in turn, building up to real life use cases. This course is targeted towards Prometheus 2.0, though most of the material will also apply to older versions.

Table of Contents

1. Using this Training Environment

2. PromQL Theory: Selectors

  • Types of Expressions
  • Vector vs Range Vector
  • Selectors
  • Selector Safety
  • Instant Vector Staleness
  • Range Vectors
  • Time from when?
  • Exercise: Use Selectors

3. PromQL Theory: Functions

  • Functions
  • Math Functions
  • Clamping
  • Timestamps
  • Time and Dates
  • Gauge Range Vectors
  • Counter Range Vectors
  • Aggregating Across Time
  • Subqueries
  • Histograms
  • Switching Types
  • Altering Labels
  • Sorting
  • Missing values
  • Other Functions
  • Quiz

4. Aggregators and Operators

  • Aggregators
  • Choosing Output Labels
  • Operators
  • Arithmetic
  • Simple Binary Operator Matching
  • Matching Your Time Series
  • Many to One
  • Comparison Operators
  • Bool vs Filtering
  • Logical/Set Operators
  • Quiz

5. PromQL in Practice

  • From Theory to Practice
  • Common Query Patterns in PromQL
  • Pitfalls When Aggregating
  • Machine Role Labels
  • Threshold from a Metric
  • Combining Alert Conditions
  • Finding Big Metrics

6. Accessing PromQL

  • Accessing PromQL
  • HTTP API
  • Query Range Computational Model
  • Getting Data Aligned to a Day
  • Recording Rules
  • When to use rules?
  • Rule Naming
  • Using Rules
  • Rule Anti-Patterns

 

Prerequisites

We also recommend taking the [Prometheus Data Model](www.academy.sysdig.com) course before this one.

Credits

This course is based on one developed by Robust Perception and is used with their permission. If you want to learn more about Prometheus and PromQL, you may wish to refer to Prometheus: Up & Running by Brian Brazil of Robust Perception.

Curriculum

  • Understanding PromQL
  • Next Steps
  • A 1 minute survey
  • What's next?

Course Description

PromQL is one of the core features of Prometheus, allowing for powerful analysis and processing of time series.

Although QL is in the name, it is not related to SQL. Relational algebra doesn't work too well for typical calculations on multi-dimensional time series. Syntax wise, PromQL is closest to expressions in the C family of languages.

This course looks at each of the components of PromQL in turn, building up to real life use cases. This course is targeted towards Prometheus 2.0, though most of the material will also apply to older versions.

Table of Contents

1. Using this Training Environment

2. PromQL Theory: Selectors

  • Types of Expressions
  • Vector vs Range Vector
  • Selectors
  • Selector Safety
  • Instant Vector Staleness
  • Range Vectors
  • Time from when?
  • Exercise: Use Selectors

3. PromQL Theory: Functions

  • Functions
  • Math Functions
  • Clamping
  • Timestamps
  • Time and Dates
  • Gauge Range Vectors
  • Counter Range Vectors
  • Aggregating Across Time
  • Subqueries
  • Histograms
  • Switching Types
  • Altering Labels
  • Sorting
  • Missing values
  • Other Functions
  • Quiz

4. Aggregators and Operators

  • Aggregators
  • Choosing Output Labels
  • Operators
  • Arithmetic
  • Simple Binary Operator Matching
  • Matching Your Time Series
  • Many to One
  • Comparison Operators
  • Bool vs Filtering
  • Logical/Set Operators
  • Quiz

5. PromQL in Practice

  • From Theory to Practice
  • Common Query Patterns in PromQL
  • Pitfalls When Aggregating
  • Machine Role Labels
  • Threshold from a Metric
  • Combining Alert Conditions
  • Finding Big Metrics

6. Accessing PromQL

  • Accessing PromQL
  • HTTP API
  • Query Range Computational Model
  • Getting Data Aligned to a Day
  • Recording Rules
  • When to use rules?
  • Rule Naming
  • Using Rules
  • Rule Anti-Patterns

 

Prerequisites

We also recommend taking the [Prometheus Data Model](www.academy.sysdig.com) course before this one.

Credits

This course is based on one developed by Robust Perception and is used with their permission. If you want to learn more about Prometheus and PromQL, you may wish to refer to Prometheus: Up & Running by Brian Brazil of Robust Perception.

Curriculum

  • Understanding PromQL
  • Next Steps
  • A 1 minute survey
  • What's next?