Nightingale v9 message templates: define the title and body of alert notifications using Go template syntax. The platform includes 30+ built-in templates covering mainstream IM / SMS / Webhook channels, and supports deep customization based on event fields.

Overview

Message templates = the definition of what the notification finally looks like when sent to IM / email / Webhook.

Sidebar path: Notification → Message Templates, URL /notification-templates.

Its relationship with notification channels:

  • Notification channel = answers “how to send” — which SMTP / Webhook to use to deliver the message;
  • Message template = answers “what content to send” — title, body, HTML style, variable references;
  • Notification rule = answers “who to send to” + select channel + select template.

The platform includes 30+ built-in templates for common channels (covering DingTalk, WeCom, Feishu, Lark, Email, PagerDuty, etc.); for most scenarios you can use them directly. For personalization (company logo, corporate wording, additional fields), clone a built-in template and modify it.

Page Layout

Two-column layout:

  • Left: template list + search box + new button
    • Each entry shows: template identifier (e.g., Email / Dingtalk / Wecom) + visibility (public / private / specified team)
  • Right: details of the selected template
    • Header: identifier, channel type, edit / copy / delete buttons;
    • Middle: field identifier area (e.g., content, subject, title) — what fields a channel needs is defined by it;
    • Editor: Markdown / HTML / Text content in Go template syntax;
    • AI Generate” button: use an LLM to directly generate a template snippet (requires first configuring LLM Management);
    • Bottom: save and preview template content;
    • Bottom right: available fields quick reference (including full $event.* field table).

Built-in Templates at a Glance

Built-in templates by channel:

Channel Type Built-in Templates
Enterprise IM Dingtalk, Wecom, Feishu, FeishuCard, Lark, LarkCard, Telegram, Discord, SlackBot, SlackWebhook, Mm, MattermostBot, MattermostWebhook
Email / SMS / Voice Email, Tencent SMS, Tencent Voice, Aliyun SMS, Aliyun Voice
Ops Platform Callback, JSMAlert, Jira
Featured Templates Polaris DingTalk/Feishu/WeCom messages, Firefighting Diagram DingTalk/Feishu/WeCom cards

A freshly deployed environment comes with these out of the box; no manual creation needed. Just select them in Notification Rules.

Field Identifier: the Contract Between Template ↔ Channel

Key concept: the field names defined in the message template (e.g., subject, content, title) must match one-to-one with the field names referenced in the body of notification channels.

Example: DingTalk channel body looks like:

{
  "msgtype": "markdown",
  "markdown": {
    "title": "{{$tpl.title}}",
    "text": "{{$tpl.content}}"
  }
}

It references $tpl.title and $tpl.content — so the DingTalk message template must have title and content as field identifiers. Otherwise the title/content sent will be empty.

If you add a new field (e.g., to include a “Recommended Actions” section), remember to change both — add the field in the template + reference it in the channel body.

Quick Recap of Template Syntax

Templates use Go template syntax and can reference all fields of the alert event (AlertCurEvent).

Minimal Template Example

Severity status: S{{$event.Severity}} {{if $event.IsRecovered}}Recovered{{else}}Triggered{{end}}
Rule name: {{$event.RuleName}}{{if $event.RuleNote}}
Rule note: {{$event.RuleNote}}{{end}}
Monitoring metric: {{$event.TagsJSON}}
{{if $event.IsRecovered}}Recovery time: {{timeformat $event.LastEvalTime}}{{else}}Trigger time: {{timeformat $event.TriggerTime}}
Trigger value: {{$event.TriggerValue}}{{end}}
Send time: {{timestamp}}
{{$domain := "http://your-n9e-domain"}}
Event details: {{$domain}}/alert-his-events/{{$event.Id}}

Common Control Syntax

Usage Example
Conditional {{if eq $event.Severity 1}}🚨 Urgent{{else if eq $event.Severity 2}}⚠️ Warning{{else}}ℹ️ Info{{end}}
Loop {{range $i, $tag := $event.TagsJSON}}- {{$tag}}{{"\n"}}{{end}}
Variable assignment {{$dashboard_url := printf "%s/alert-his-events/%d" $domain $event.Id}}
Function call {{timeformat $event.LastEvalTime}}, {{timestamp}}
Reference labels {{$event.TagsMap.instance}}, {{$event.TagsMap.service}}
Reference annotations {{$event.AnnotationsJSON.summary}}

Common Event Fields

Field Meaning
$event.RuleName Alert rule name
$event.RuleNote Rule note
$event.Severity 1/2/3 three levels
$event.IsRecovered true = recovery event
$event.TagsJSON Label array
$event.TagsMap.<key> Single label value
$event.TriggerValue Trigger instantaneous value
$event.TriggerTime Trigger timestamp
$event.LastEvalTime Most recent evaluation timestamp
$event.GroupName Business group name
$event.TargetIdent Target device identifier
$event.Cluster Data source name
$event.AnnotationsJSON.<key> Annotation value

The full field table and template function list can be found in the “Available Fields Reference” area at the bottom right (the field quick-reference table embedded in the page). For template function implementation, see tplx.go in ccfos/nightingale and the Template Functions documentation.

Hands-on: Clone + Modify a Template

Do not modify built-in templates directly (upgrades will overwrite them). Recommended flow:

  1. Select the reference template in the left list, e.g., Dingtalk;
  2. Click the “Copy” button at the top right — automatically creates a Dingtalk_copy duplicate;
  3. Modify the copy: give it a new identifier (e.g., Dingtalk-ops for an ops-specific version), modify the content;
  4. Preview Template Content” button: use a sample event to render and see the effect;
  5. Save once satisfied;
  6. Go to Notification Rules and switch rules that should use this style to the new template.

AI Generation of Templates

The “AI Generate” button calls the default LLM configured in LLM Management and uses natural language to generate template snippets. Typical prompt examples:

  • “Generate a DingTalk markdown alert template with emojis and colors by severity”
  • “Generate a concise email subject that includes the severity and rule name”

The generated content is automatically filled into the editor and can be further manually adjusted. The prerequisite is that LLM Management has at least one enabled + default LLM configuration.

FAQ

Q1: After saving the template, the notification didn’t take effect?

A: Check these 3 points:

  1. Cache: templates are cached for a few seconds, wait 10-30 seconds before triggering the alert;
  2. Correct selection: in the “Message Template” column of the notification rule, is the new template selected;
  3. Field identifier match: the field names in the template (content, subject, etc.) must exactly match the $tpl.xxx referenced in the notification channel body.

Q2: Preview looks correct, but the sent message is full of <no value>?

A: The template uses fields the event doesn’t have. For example, $event.TagsMap.dept, but the actual event labels don’t have the dept key. Two ways to handle:

  • Use conditional: {{if $event.TagsMap.dept}}{{$event.TagsMap.dept}}{{else}}Unknown{{end}};
  • Or ensure the label is mandatory (use label dictionary to inject default values).

Q3: Want to send WeCom / DingTalk images or link cards, but no built-in template found?

A:

  • DingTalk group robots have a “card message” format — use the Dingtalk template, change content to DingTalk ActionCard format;
  • Feishu / Lark use the FeishuCard / LarkCard templates, which are already in card style;
  • For fully customized content, use the Callback template + generic callback channel, and assemble the JSON forwarding yourself.

References

快猫星云 联系方式 快猫星云 联系方式
快猫星云 联系方式
快猫星云 联系方式
快猫星云 联系方式
快猫星云