[release-11.6.1] docs(alerting): clarify how Math expressions operate on multiple series (#104352)

docs(alerting): clarify how Math expressions operate on multiple series (#104316)

(cherry picked from commit 6abe6499c4)
pull/104467/head
Pepe Cano 2 months ago committed by GitHub
parent 044fb387c6
commit 2d4d7cf869
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 21
      docs/sources/alerting/fundamentals/alert-rules/queries-conditions.md

@ -32,6 +32,11 @@ refs:
destination: /docs/grafana/<GRAFANA_VERSION>/panels-visualizations/query-transform-data/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana-cloud/visualizations/panels-visualizations/query-transform-data/
math-operation:
- pattern: /docs/grafana/
destination: /docs/grafana/<GRAFANA_VERSION>/panels-visualizations/query-transform-data/expression-queries/#math
- pattern: /docs/grafana-cloud/
destination: /docs/grafana-cloud/visualizations/panels-visualizations/query-transform-data/expression-queries/#math
---
# Queries and conditions
@ -88,15 +93,23 @@ The following aggregations functions are included: `Min`, `Max`, `Mean`, `Mediam
### Math
Performs free-form math functions/operations on time series data and numbers. For instance, `$A + 1` or `$A * 100`.
Performs free-form math functions/operations on time series data and numbers. For example, `$A + 1` or `$A * 100`.
If queries being compared have **multiple series in their results**, series from different queries are matched(joined) if they have the same labels. For example:
- `$A` returns series `{host=web01} 30` and `{host=web02} 20`
- `$B` returns series `{host=web01} 10` and `{host=web02} 0`
- `$A + $B` returns `{host=web01} 40` and `{host=web02} 20`.
You can also use a Math expression to define the alert condition for numbers. For example:
In this case, only series with matching labels are joined, and the operation is calculated between them.
For additional scenarios on how Math handles different data types, refer to the [Math documentation](ref:math-operation).
You can also use a Math expression to define the **alert condition**. For example:
- `$B > 70` should fire if the value of B (query or expression) is more than 70.
- `$B < $C * 100` should fire if the value of B is less than the value of C multiplied by 100.
If queries being compared have multiple series in their results, series from different queries are matched if they have the same labels or one is a subset of the other.
### Resample
Realigns a time range to a new set of timestamps, this is useful when comparing time series data from different data sources where the timestamps would otherwise not align.

Loading…
Cancel
Save