diff --git a/hugo/content/en/monitors/configuration/_index.md b/hugo/content/en/monitors/configuration/_index.md index 3079eb273398..a733bc642d77 100644 --- a/hugo/content/en/monitors/configuration/_index.md +++ b/hugo/content/en/monitors/configuration/_index.md @@ -140,7 +140,9 @@ For more information, see the guide on how to [Customize monitor evaluation freq ### Thresholds -Use thresholds to set a numeric value for triggering an alert. Depending on your chosen metric, the editor displays the unit used (`byte`, `kibibyte`, `gibibyte`, etc). +Use thresholds to define when a monitor triggers an alert. A static threshold compares the evaluated value to a fixed number. Metric monitors also support [relative thresholds (Preview)](#relative-thresholds), which adapt to a historical baseline. Depending on your chosen metric, the editor displays the unit used (`byte`, `kibibyte`, `gibibyte`, etc). + +#### Static thresholds Datadog has two types of notifications (alert and warning). Monitors recover automatically based on the alert or warning threshold but additional conditions can be specified. For additional information on recovery thresholds, see [What are recovery thresholds?][5]. For example, if a monitor alerts when the metric is above `3` and recovery thresholds are not specified, the monitor recovers once the metric value goes back below `3`. @@ -157,6 +159,27 @@ As you change a threshold, the preview graph in the editor displays a marker sho **Note**: When entering decimal values for thresholds, if your value is `<1`, add a leading `0` to the number. For example, use `0.5`, not `.5`. +#### Relative thresholds + +{{< callout url="#" btn_hidden="true" header="Preview" >}} +Relative thresholds are in Preview for metric monitors. +{{< /callout >}} + +A relative threshold uses historical data from the same monitor query as its baseline. Datadog applies an optional multiplier to the aggregated baseline to calculate the threshold. For monitors grouped by tags, each group has its own baseline and threshold. + +To configure a relative threshold in **Set alert conditions**: + +1. Select a relative threshold and choose the alert direction. +2. Select a historical aggregation and a lookback window from 1 week to 6 months. The historical window must be at least as long as the monitor's evaluation window. +3. Set the multiplier and, optionally, a critical recovery threshold. For example, alert above `1.5x` the historical average and recover at or below `1.2x` that average. + +The evaluation and historical aggregations can differ, including percentile and average aggregations for distribution metrics. With a `p95:` metric variable, `.rollup("percentile")` calculates the p95 across the window's distribution data, while `.rollup("avg")` averages the p95 timeseries values. See [Percentile queries][8] for examples. + +Historical thresholds are recalculated daily at midnight UTC and remain constant between updates. The monitor's evaluation frequency continues to control how often Datadog compares current values to those thresholds. + +Relative thresholds support critical threshold queries and critical recovery threshold queries. Relative warning thresholds are not supported in Preview, and static and relative thresholds cannot be combined in the same monitor. + +For configuration examples, query syntax, and limitations, see the [Relative Thresholds guide][7]. [1]: /monitors/guide/monitor_aggregators/ [2]: /monitors/guide/as-count-in-monitor-evaluations/ @@ -164,6 +187,8 @@ As you change a threshold, the preview graph in the editor displays a marker sho [4]: /monitors/guide/custom_schedules [5]: /monitors/guide/recovery-thresholds/ [6]: /monitors/types/log/ +[7]: /monitors/guide/relative-thresholds/ +[8]: /monitors/guide/relative-thresholds/#percentile-queries {{% /tab %}} {{% tab "Check alert" %}} diff --git a/hugo/content/en/monitors/guide/_index.md b/hugo/content/en/monitors/guide/_index.md index ae1896496752..957b16d49e64 100644 --- a/hugo/content/en/monitors/guide/_index.md +++ b/hugo/content/en/monitors/guide/_index.md @@ -33,6 +33,7 @@ cascade: {{< whatsnext desc="Monitor configuration:" >}} {{< nextlink href="monitors/guide/best-practices-for-live-process-monitoring" >}}Best practices for Live Process Monitoring{{< /nextlink >}} {{< nextlink href="monitors/guide/non_static_thresholds" >}}How to monitor non-static thresholds{{< /nextlink >}} + {{< nextlink href="monitors/guide/relative-thresholds" >}}Relative thresholds (Preview){{< /nextlink >}} {{< nextlink href="monitors/guide/anomaly-monitor" >}}Anomaly monitors{{< /nextlink >}} {{< nextlink href="monitors/guide/monitoring-sparse-metrics" >}}Monitoring Sparse Metrics{{< /nextlink >}} {{< nextlink href="monitors/guide/monitor-arithmetic-and-sparse-metrics" >}}Monitor arithmetic and sparse metrics{{< /nextlink >}} diff --git a/hugo/content/en/monitors/guide/non_static_thresholds.md b/hugo/content/en/monitors/guide/non_static_thresholds.md index 66fce7da5fb6..32cfd24e8356 100644 --- a/hugo/content/en/monitors/guide/non_static_thresholds.md +++ b/hugo/content/en/monitors/guide/non_static_thresholds.md @@ -1,6 +1,6 @@ --- title: How to monitor non-static thresholds -description: "Monitor variable thresholds using seasonal patterns, reference metrics, and composite monitors for dynamic alerting scenarios." +description: "Monitor variable thresholds using relative thresholds (Preview), seasonal patterns, reference metrics, and composite monitors." further_reading: - link: "/monitors/types/composite/" tag: "Documentation" @@ -16,10 +16,27 @@ A typical metric monitor triggers an alert if a single metric goes above a speci Watchdog powered monitors (namely [anomaly][1] and [outlier][2]) are particularly useful when there isn't an explicit definition of your metric being off-track. However, when possible, you should use regular monitors with tailored alert conditions to maximize precision and minimize time-to-alert for your specific use case. -This guide covers common use cases for alerting on non-static thresholds: +Choose an approach based on the comparison you need: + - [Use a **relative threshold (Preview)** to compare a metric to its historical baseline](#relative-thresholds) - [Alert on a metric that goes off track outside of **seasonal variations**](#seasonal-threshold) - [Alert based on the value of another **reference** metric](#reference-threshold) +## Relative thresholds + +{{< callout url="#" btn_hidden="true" header="Preview" >}} +Relative thresholds are in Preview for metric monitors. +{{< /callout >}} + +A relative threshold compares the evaluated value of a metric monitor to a historical baseline from the same query. Datadog calculates a separate threshold for each group, so one monitor can cover resources with different normal values. + +For example, alert when the average job duration over five minutes exceeds `1.5x` its average over the last week. + +The current value and historical baseline can use different aggregations. For distribution metrics, compare a percentile to a historical percentile or to a historical average. With a `p95:` metric variable, an `avg` rollup averages the p95 timeseries values. See [Percentile queries][7] for all three comparison examples. + +Choose a historical aggregation and a lookback window from 1 week to 6 months. Historical thresholds are recalculated daily at midnight UTC and remain constant between updates. The monitor continues evaluating current values at its configured evaluation frequency. + +For configuration steps, query syntax, critical recovery thresholds, and Preview limitations, see the [Relative Thresholds guide][6]. + ## Seasonal threshold ### Context @@ -187,3 +204,5 @@ The last monitor is a Composite monitor, which sends an alert only if the two pr [3]: /integrations/nginx/?tab=host#data-collected [4]: /account_management/billing/usage_metrics/#types-of-usage [5]: /logs/log_configuration/logs_to_metrics/#logs-usage-metrics +[6]: /monitors/guide/relative-thresholds/ +[7]: /monitors/guide/relative-thresholds/#percentile-queries diff --git a/hugo/content/en/monitors/guide/relative-thresholds.md b/hugo/content/en/monitors/guide/relative-thresholds.md new file mode 100644 index 000000000000..db01de6de90e --- /dev/null +++ b/hugo/content/en/monitors/guide/relative-thresholds.md @@ -0,0 +1,332 @@ +--- +title: Relative Thresholds +description: "Configure relative thresholds (Preview) to compare metric values with historical baselines, including percentile queries, recovery thresholds, and limitations." +--- + +## Overview + +{{< callout url="#" btn_hidden="true" header="Preview" >}} +Relative thresholds are in Preview and are available for metric monitors. +{{< /callout >}} + +Relative thresholds let you alert when a metric deviates from its historical behavior, without choosing a fixed threshold. + +Instead of alerting when a metric exceeds a specific value, such as 100 ms, alert when it exceeds a multiple of its historical baseline. For example, alert when a metric exceeds `1.5x` its average over the past week. + +Relative thresholds are useful for metrics whose normal values vary between services, hosts, or other groups, or gradually change over time. They provide an alternative to static thresholds and anomaly detection when you want to detect a known degree of change. + +## How relative thresholds work + +A relative threshold compares two values: + +- **Current value:** The metric value calculated over the monitor's evaluation window, such as the average over the last 5 minutes. +- **Historical threshold:** A threshold calculated from historical metric data, optionally multiplied by a factor. + +For example, configure a monitor to alert when: + +`Average over the last 5 minutes > 1.5x the average over the last week` + +If a service's historical average request latency is 200 ms, its alert threshold is 300 ms. If the historical average later increases to 250 ms, its alert threshold becomes 375 ms. + +Unlike a static threshold, the threshold adapts to the metric's historical behavior. + +### Historical baseline + +The historical threshold is calculated using an aggregation over a longer time window. The aggregation and time window determine how the baseline responds to past behavior. + +Relative thresholds support historical windows from 1 week to 6 months. + +**Historical thresholds are recalculated daily at midnight UTC.** The calculated threshold remains constant between updates, while the monitor continues evaluating current metric values at its configured evaluation frequency. + +This provides a stable baseline that adjusts to longer-term changes without reacting immediately to every short-term fluctuation. + +### Grouped monitors + +For monitors grouped by dimensions such as `service`, `host`, or `region`, Datadog calculates a separate historical threshold for each group. + +For example, a monitor grouped by `service` might have the following values: + +| Service | Historical average | Multiplier | Alert threshold | +|---|---:|---:|---:| +| Service A | 100 ms | `1.5x` | 150 ms | +| Service B | 400 ms | `1.5x` | 600 ms | +| Service C | 800 ms | `1.5x` | 1200 ms | + +Each service is evaluated independently against its own threshold. + +This allows a single monitor to cover services with different normal operating characteristics without requiring separate static thresholds. + +## Configure a relative threshold + +To configure a relative threshold: + +1. Create or edit a [metric monitor][1]. +2. Define the metric and its evaluation window. +3. In the alert conditions, select a relative threshold. +4. Select the threshold aggregation and lookback window. +5. Set a multiplier that determines how much the current value can deviate from the historical baseline. This can be smaller than one (less than the baseline) or larger than one (greater than the baseline). +6. Optionally, configure a recovery threshold. +7. Review the resulting thresholds and monitor behavior before saving. + +For example, set the alert threshold to `1.5x` the historical baseline to detect an increase. Set it to `0.7x` and choose the below direction to detect a drop. + +### Query syntax + +Relative thresholds are supported in metric monitors using Formulas and Functions queries. + +The monitor query uses `threshold` as a placeholder for the calculated threshold: + +```text +formula("query1").rollup("avg").last("5m") > threshold +``` + +The historical threshold is defined in `options.thresholds.critical_query`: + +```text +formula("query1").rollup("avg").last("1w").multiplier(1.5) +``` + +The historical query has the following structure: + +```text +formula("").rollup("").last("").multiplier() +``` + +- `formula`: A formula referencing the metric query variables. Formulas can contain arithmetic expressions. +- `rollup`: The aggregation used to calculate the historical value, such as `avg` or `percentile`. The monitor query and historical query can use different aggregations. +- `last`: The historical lookback window, such as `1w` or `1mo`. +- `multiplier`: An optional numeric multiplier applied to the aggregated historical value. + +The multiplier applies to the result of the historical aggregation, rather than to individual datapoints. For a `1.5x` threshold, use `.multiplier(1.5)` in the query. + +Define the optional recovery query in `options.thresholds.critical_recovery_query` using the same syntax as `options.thresholds.critical_query`. + +### API example + +The following example alerts when the average job duration over 5 minutes exceeds `1.5x` its historical weekly average, grouped by job. + +```json +{ + "name": "Job duration above historical baseline", + "type": "query alert", + "query": "formula(\"query1\").rollup(\"avg\").last(\"5m\") > threshold", + "message": "Job duration is above its historical baseline.", + "options": { + "thresholds": { + "critical_query": "formula(\"query1\").rollup(\"avg\").last(\"1w\").multiplier(1.5)", + "critical_recovery_query": "formula(\"query1\").rollup(\"avg\").last(\"1w\").multiplier(1.2)" + }, + "variables": [ + { + "name": "query1", + "data_source": "metrics", + "query": "avg:example.job.duration{env:prod} by {job}" + } + ] + } +} +``` + +Replace `example.job.duration` with your metric. + +In this example: + +- The monitor enters `ALERT` when the current average duration exceeds `1.5x` the historical weekly average. +- The monitor recovers when the current average falls to or below `1.2x` the historical weekly average. +- Each job has its own calculated threshold. + +See the [Monitors API][2] for additional configuration options. + +### Percentile queries + +Relative thresholds support percentile aggregations on [distribution metrics][6] with percentiles enabled. Choose the aggregation for the monitor's evaluation window independently from the aggregation for the historical window. + +For a metric variable such as `p95:example.request.duration{env:prod} by {service}`: + +- The `p95:` prefix selects the 95th percentile. The percentile rank comes from the metric variable. +- `.rollup("percentile")` calculates that percentile across the distribution data in the window specified by `.last(...)`. +- `.rollup("avg")` averages the query's timeseries values over that window. With a `p95:` variable, this is the average of the p95 values in the timeseries. + +**Note:** An average of p95 values and a p95 calculated across the full window's distribution data can differ. Using `.rollup("avg")` with a `p95:` variable does not change the variable to `avg:`. + +The following examples use the same `p95:` variable for both windows. Each service has its own threshold, and the `1.5x` multiplier applies after the historical aggregation. + +| Comparison | Current value over 5 minutes | Historical threshold over 1 week | +|---|---|---| +| Percentile vs. percentile | p95 of the distribution data | `1.5x` the p95 of the distribution data | +| Percentile vs. average | p95 of the distribution data | `1.5x` the average of the p95 timeseries values | +| Average vs. percentile | Average of the p95 timeseries values | `1.5x` the p95 of the distribution data | + +Replace `example.request.duration` with a distribution metric that has percentiles enabled. + +{{< tabs >}} +{{% tab "Percentile vs. percentile" %}} + +Alert when the p95 request duration over five minutes exceeds `1.5x` the historical weekly p95. + +```json +{ + "name": "Request duration p95 above historical p95", + "type": "query alert", + "query": "formula(\"query1\").rollup(\"percentile\").last(\"5m\") > threshold", + "message": "Request duration p95 is above its historical baseline.", + "options": { + "thresholds": { + "critical_query": "formula(\"query1\").rollup(\"percentile\").last(\"1w\").multiplier(1.5)" + }, + "variables": [ + { + "name": "query1", + "data_source": "metrics", + "query": "p95:example.request.duration{env:prod} by {service}" + } + ] + } +} +``` + +{{% /tab %}} +{{% tab "Percentile vs. average" %}} + +Alert when the p95 request duration over five minutes exceeds `1.5x` the average of the p95 timeseries values over the last week. + +```json +{ + "name": "Request duration p95 above historical average of p95", + "type": "query alert", + "query": "formula(\"query1\").rollup(\"percentile\").last(\"5m\") > threshold", + "message": "Request duration p95 is above its historical baseline.", + "options": { + "thresholds": { + "critical_query": "formula(\"query1\").rollup(\"avg\").last(\"1w\").multiplier(1.5)" + }, + "variables": [ + { + "name": "query1", + "data_source": "metrics", + "query": "p95:example.request.duration{env:prod} by {service}" + } + ] + } +} +``` + +{{% /tab %}} +{{% tab "Average vs. percentile" %}} + +Alert when the average of the p95 request-duration timeseries values over five minutes exceeds `1.5x` the historical weekly p95. + +```json +{ + "name": "Average request duration p95 above historical p95", + "type": "query alert", + "query": "formula(\"query1\").rollup(\"avg\").last(\"5m\") > threshold", + "message": "Average request duration p95 is above its historical baseline.", + "options": { + "thresholds": { + "critical_query": "formula(\"query1\").rollup(\"percentile\").last(\"1w\").multiplier(1.5)" + }, + "variables": [ + { + "name": "query1", + "data_source": "metrics", + "query": "p95:example.request.duration{env:prod} by {service}" + } + ] + } +} +``` + +{{% /tab %}} +{{< /tabs >}} + +## Limitations + +Relative thresholds have the following restrictions: + +| Restriction | Description | +|---|---| +| Monitor types | Supported for metric monitors using Formulas and Functions queries. | +| Historical window | Must be between 1 week and 6 months and at least as long as the monitor's evaluation window. | +| Threshold types | Supports critical threshold queries and critical recovery threshold queries. Relative warning thresholds are not supported in this Preview. | +| Static thresholds | Relative and static thresholds cannot be combined in the same monitor. | +| Query result | The threshold query must produce a numeric threshold for each matching group that can be compared with the current evaluated value. | +| Historical data | Sufficient historical data must be available to calculate the threshold for a group. | +| Update frequency | Historical thresholds are recalculated daily rather than on every monitor evaluation. | + +The monitor and historical queries must produce compatible results for comparison. If Datadog cannot calculate a historical threshold for a group, the monitor cannot perform the comparison for that group. For example, a group might have no matching historical data. + +When historical data is unavailable, the monitor's [missing-data behavior][3] determines how the absence of an evaluable result is handled. + +## When to use relative thresholds + +Use relative thresholds to detect a meaningful change from an established baseline. The expected change should be expressible as a ratio. + +### Detect gradual performance degradation + +Monitor metrics such as request latency, processing duration, or queue processing time. + +For example, alert when a job's execution time exceeds `1.5x` its historical average. This allows you to detect regressions even if different jobs have different execution times. + +### Monitor resources with different baselines + +Monitor a fleet of services or hosts without choosing individual thresholds for each resource. + +For example, one service might normally consume 10% CPU while another consumes 60%. A relative threshold can identify increases from each service's normal behavior using a single grouped monitor. + +### Detect changes in workloads that grow over time + +Monitor metrics where the expected value increases or decreases gradually as a business or service evolves. + +For example, alert when the duration of a regularly scheduled data processing job increases significantly compared to its historical average. + +Because the threshold adapts over time, you don't need to repeatedly adjust a static threshold as normal operating conditions change. + +## When not to use relative thresholds + +Relative thresholds are not appropriate for every monitoring scenario. + +### When there is a known absolute limit + +If a metric has a clear failure boundary, use a static threshold. + +For example, alerting when disk usage exceeds 90% is usually more appropriate than alerting when disk usage exceeds `1.5x` its historical average. + +A relative threshold can rise alongside sustained degradation, potentially allowing an unhealthy value to become part of the baseline. + +### When the historical baseline is near zero + +Relative comparisons can be misleading when historical values are zero or small. + +For example, increasing from one error per hour to three errors per hour is a 200% increase, but might not represent a meaningful incident. + +Consider using an absolute threshold when small changes in low-volume metrics should not trigger alerts. + +### When data has strong daily or weekly seasonality + +Relative thresholds aggregate historical data over a longer period rather than modeling expected behavior for a particular time of day or day of week. + +For example, request volume might consistently be lower overnight than during business hours. Comparing overnight traffic against an entire week's average could produce unwanted alerts. + +For metrics with strong recurring patterns, consider an [anomaly detection monitor][4] or a [change alert][5]. + +### When groups are short-lived or data is extremely sparse + +Relative thresholds require sufficient historical data to calculate a meaningful baseline. + +New services, temporary resources, or infrequently reporting metrics might not have enough historical observations. This can prevent evaluation or produce baselines that do not accurately represent normal behavior. + +For these cases, consider a static threshold or a monitor designed around the expected frequency of the data. + +### When you need immediate adaptation + +Historical thresholds update daily and are intended to detect deviations from longer-term behavior. + +If the expected range needs to adapt continuously to changing conditions, consider another detection method, such as anomaly detection. + +[1]: /monitors/types/metric/ +[2]: /api/latest/monitors/#create-a-monitor +[3]: /monitors/configuration/?tab=thresholdalert#no-data +[4]: /monitors/types/anomaly/ +[5]: /monitors/types/change-alert/ +[6]: /metrics/distributions/#enabling-advanced-query-functionality diff --git a/hugo/content/en/monitors/types/metric.md b/hugo/content/en/monitors/types/metric.md index da6e5b5ab3e7..529bff09d4e9 100644 --- a/hugo/content/en/monitors/types/metric.md +++ b/hugo/content/en/monitors/types/metric.md @@ -31,13 +31,20 @@ To create a metric monitor in Datadog, navigate to [{{< ui >}}Monitors{{< /ui >} {{< tabs >}} {{% tab "Threshold" %}} -A threshold alert compares metric values to a static threshold. +A threshold alert compares metric values to a static threshold or a relative threshold (Preview). A static threshold is a fixed number. A relative threshold adapts to a historical baseline from the same query. On each alert evaluation, Datadog calculates the average, minimum, maximum, or sum over the selected period and checks if it is above, below, equal to, or not equal to the threshold. This is for standard alert cases where you know the expected values. The [distribution metric type][1] offers the additional threshold option of calculating percentiles over the selected period. For more information, see the [Set alert conditions](#set-alert-conditions) section. +{{< callout url="#" btn_hidden="true" header="Preview" >}} +Relative thresholds are in Preview. +{{< /callout >}} + +Relative thresholds can use different aggregations for the evaluation and historical windows, including percentile aggregations for distribution metrics. For examples and Preview limitations, see [Relative thresholds][2]. + [1]: /metrics/distributions/ +[2]: /monitors/guide/relative-thresholds/ {{% /tab %}} {{% tab "Change" %}} @@ -165,6 +172,8 @@ Trigger when the metric is one of the following: If the value is between zero and one, a leading zero is required. For example, `0.3`. +For static and relative threshold (Preview) settings, see [Thresholds in monitor configuration][9]. + ### Advanced alert conditions #### Data window @@ -223,3 +232,4 @@ For instructions on the {{< ui >}}Configure notifications and automations{{< /ui [6]: /monitors/configuration/#advanced-alert-conditions [7]: /monitors/notify/ [8]: /monitors/configuration/?tab=thresholdalert#configure-notifications-and-automations +[9]: /monitors/configuration/?tab=thresholdalert#thresholds