Use Mustache Templates in Runbook Actions
Learn how to use Mustache templates in runbook actions for dynamic content in Harness AI SRE.
Mustache templates provide simple variable substitution in runbook actions. Use Mustache when you need to insert dynamic values from incidents, alerts, or previous action outputs into your runbook actions.
How to reference fields
When configuring runbook actions in the UI:
Click an action input field that supports dynamic values (marked with a data picker icon)
Click the data picker button (looks like a database icon)
Select the field source:
Incident - Fields from the current incident
Alert - Fields from the triggering alert
Runbook Inputs - Variables defined in the Input/Output section
Action Outputs - Results from previous actions
Select the specific field
The Mustache variable is automatically inserted:
{{incident.service}}
Alternatively, you can type Mustache syntax directly: {{incident.field_name}}
Example: Slack message with incident details
Action: Slack: Post Message
Channel: #incidents
Message (configured in form field):
Result: When the runbook runs, Mustache variables are replaced with actual values:
CEL alternative with conditional logic:
Example: Conditional routing for Slack
Use runbook triggers to create conditional behavior based on field values.
Pattern: Route P1 alerts to #critical-incidents, others to #incidents
Implementation:
Create two runbooks:
P1 Alert Handler:
Trigger: Alert created with
alert.priority equals p1_criticalAction: Slack post to
#critical-incidents
Standard Alert Handler:
Trigger: Alert created with
alert.priority in [p2_error, p3_warning, p4_info]Action: Slack post to
#incidents
Go to Create runbook triggers to configure conditional execution.
Example: Jira ticket with incident context
Action: Jira: Create Issue
Form Configuration:
Project:
INCIDENT(static value)Issue Type:
Incident(static value)Summary (form field with data picker):
Description (form field with data picker):
Priority (form field with data picker):
Result: Jira ticket is created with all incident context embedded.
CEL alternative with dynamic priority logic:
Summary field:
Description field:
Example: HTTP request with alert data
Action: HTTP Request
Form Configuration:
URL (form field):
Method:
POST(dropdown)Body (form field with data picker):
Example: Reference previous action outputs
Actions can reference outputs from previous actions in the same runbook.
Action 1: Zoom: Create Meeting
Outputs:
join_url,meeting_id,passcode
Action 2: Slack: Post Message
Message (referencing Action 1 output):
The data picker automatically shows available outputs from previous actions.
Next steps
Go to Use CEL in runbook actions to implement conditional logic and transformations.
Go to Use system fields in runbook actions to learn about available system fields.
Go to Best practices to review field usage guidelines.
Last updated
Was this helpful?