Use Mustache Templates in Webhooks
Map webhook payload fields with Mustache templates.
Use Mustache templates to map webhook payload fields to alert fields in Harness AI SRE.
When to use Mustache in webhooks
Mustache templates are used for field mapping (populating alert field values) after a webhook is accepted. This is different from CEL expressions, which are used for filtering (deciding whether to create an alert).
Use Mustache for:
Mapping webhook payload fields to alert fields
Simple variable substitution
Transforming webhook data into alert data
Use CEL for:
Filtering which webhooks create alerts
Conditional logic before alert creation
Complex boolean expressions
Note: CEL is used for filtering (deciding whether to create an alert), while Mustache is used for mapping (populating alert field values). They serve different purposes in the webhook processing pipeline.
Field mapping with Mustache
After parsing your webhook payload in the visual builder, reference fields using Mustache templates:
Map basic fields
Nested field access
Example: map a Datadog webhook
Example: custom application webhook
Best practices
1. Use descriptive field names
2. Provide fallback values
If your webhook payload might not always include certain fields, test with sample payloads to ensure the mapping works correctly.
3. Map all required fields
Ensure you map all required alert fields from your webhook payload:
title: Alert title.
severity: Alert severity level.
service: Affected service (if applicable).
4. Test your mappings
Validate each mapping before you rely on it in production:
Send a test webhook payload
Verify alert fields are populated correctly
Check for missing or incorrectly mapped values
Adjust mappings as needed
Combine Mustache with CEL filters
You can use CEL for filtering and Mustache for mapping in the same webhook:
Step 1: CEL filters the webhook
Step 2: Mustache maps accepted webhooks to alerts
Common patterns
Pattern 1: monitoring tool integration
Pattern 2: track application errors
Pattern 3: monitor infrastructure
Complete payload and mapping examples
Example 1: generic alert format
Incoming webhook payload:
Field mapping:
Result: Creates an alert with title "High CPU Usage", description "CPU usage above 90%", severity "critical", service "payment-api", environment "production".
Example 2: monitoring system format
Incoming webhook payload:
Field mapping:
Result: Creates an alert with title "kubernetes_pod payments-prod-api alert", service "payments-prod-api", environment "production", severity "P1".
Example 3: custom application format
Incoming webhook payload:
Field mapping:
Result: Creates an alert with title "business_logic error in order-service", description "Database connection timeout - Impact: Order processing delayed", service "order-service".
Next steps
Go to Use CEL in Webhooks for webhook filtering with CEL expressions
Go to Ingest Alerts to learn about webhook setup
Go to Configure Ingest Alerts for native integration options
Last updated
Was this helpful?