text/template, then render the result as Text or Markdown.
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 eventDescription, 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 asprig_ prefix so templates
can avoid naming conflicts when needed.
Use:
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 Rows
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 Gotext/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 asprig_ prefix. Sprig functions come from
Masterminds/sprig. Check that repository
for upstream function behavior.
Common examples:
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:
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 andsprig_
forms:
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.