Skip to main content
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.
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.

How It Works

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.
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.

Sprig Function Names

monit-edge registers safe Sprig functions with their standard Sprig names. The same supported functions are also registered with a sprig_ prefix so templates can avoid naming conflicts when needed. Use:
The prefixed form is also valid:
If a standard Sprig name conflicts with a monit-edge custom function, the monit-edge custom function keeps the standard name and the Sprig function remains available through the sprig_ prefix.

Built-in Variables

Example:

Root Object Fields

Access root object fields with .FieldName. Query objects in .Queries have .Name, .Expr, .LabelFields, .ValueFields, and .Args. RelateQuery objects in .RelateQueries have .Name, .Expr, and .Args. Related query results are available through $relates. The map key is the related query name, such as R1. Example:

Go Template Built-in Functions

These functions are provided by Go text/template.

monit-edge Custom Functions

These functions are registered by monit-edge without a prefix.

Sprig Functions

monit-edge registers safe Sprig functions with standard Sprig names and also with a sprig_ prefix. Sprig functions come from Masterminds/sprig. Check that repository for upstream function behavior. Common examples:
Important regex note: regexFind and sprig_regexFind return the full matched substring. They do not return a capture group. To extract a capture group, use regexReplaceAll or sprig_regexReplaceAll:
The result is:

Common Sprig Functions

The same functions can also be called with sprig_ prefixes, such as sprig_contains and sprig_regexReplaceAll.

Disabled Sprig Functions

For predictable and safe alert rendering, monit-edge does not register Sprig functions that can read process environment variables, perform DNS lookup, generate random output, create credentials or certificates, encrypt or decrypt data, or intentionally fail rendering. The following Sprig functions are unavailable in both standard and sprig_ forms:
If a template uses one of these functions, parsing fails with an error like function "env" not defined or function "sprig_env" not defined.

Complete Example: Extract MySQL Unknown Column

Troubleshooting

function "contains" not defined means the rule is running on an older monit-edge build that has not enabled standard Sprig names. Upgrade monit-edge, or use sprig_contains as a compatibility workaround if that build supports the prefixed form. function "env" not defined or function "sprig_env" not defined means the template used a disabled Sprig function. Remove it or replace it with deterministic template logic. regexFind or sprig_regexFind returning Unknown column 'x' instead of x is expected. Use regexReplaceAll or sprig_regexReplaceAll to extract capture groups.