|
1 | 1 | --- |
2 | | -title: "Alert Rule Description Templates" |
| 2 | +title: "Description Template" |
3 | 3 | description: "Configure Go Template variables, related query results, and Sprig functions for Monitors alert rule descriptions." |
4 | 4 | keywords: ["Description templates", "alert rules", "Go Template", "Sprig", "related queries"] |
5 | 5 | --- |
6 | 6 |
|
7 | 7 | Use an alert rule **Description** to define the text shown on firing and recovery events. You can reference alert labels, query values, related query results, and safe Sprig functions with Go `text/template`, then render the result as Text or Markdown. |
8 | 8 |
|
| 9 | +<Warning> |
| 10 | +The template variables, Sprig function names, and behavior where label enrichment runs before `Description` rendering require monit-edge `v0.42.0` or later. On older versions, some variables or functions may be unavailable, and enrichment results may not be available inside Description templates. |
| 11 | +</Warning> |
| 12 | + |
9 | 13 | ## How It Works |
10 | 14 |
|
11 | | -When a rule fires or recovers, monit-edge passes the full alert event as the template root object and injects short variables for common fields. After rendering, monit-edge writes the result to the event `Description`, then runs label enrichment and sends the event. |
| 15 | +When a rule fires or recovers, monit-edge passes the full alert event as the template root object and injects short variables for common fields. After label enrichment completes, monit-edge renders the template with the enriched event, writes the result to the event `Description`, and then sends the event. |
12 | 16 |
|
13 | 17 | <Note> |
14 | 18 | For day-to-day templates, prefer `$labels`, `$values`, `$value`, `$relates`, `$status`, and `$checkMode`. Use the other short variables only for advanced templates or compatibility cases. |
@@ -224,7 +228,7 @@ community_posts.comment_count |
224 | 228 | | `contains substr text` | Checks whether `text` contains `substr`. | `{{ if contains "Unknown column" $msg }}...{{ end }}` | |
225 | 229 | | `hasPrefix prefix text` | Checks prefix. | `{{ hasPrefix "prod-" $name }}` | |
226 | 230 | | `hasSuffix suffix text` | Checks suffix. | `{{ hasSuffix ".log" $file }}` | |
227 | | -| `regexMatch pattern text` | Regex match. | `{{ regexMatch "error|failed" $msg }}` | |
| 231 | +| `regexMatch pattern text` | Regex match. | `{{ regexMatch "error\|failed" $msg }}` | |
228 | 232 | | `regexFind pattern text` | Returns the first full regex match. | `{{ regexFind "trace_id=[a-z0-9]+" $msg }}` | |
229 | 233 | | `regexFindAll pattern text n` | Returns up to `n` full regex matches. Use `-1` for all. | `{{ regexFindAll "id=[0-9]+" $msg -1 }}` | |
230 | 234 | | `regexReplaceAll pattern text repl` | Regex replacement. Argument order is `pattern`, `text`, `replacement`. | `{{ regexReplaceAll ".*id=([0-9]+).*" $msg "$1" }}` | |
|
0 commit comments