Notification Templates
What are Notification Templates?
Notification Templates define the format and content of notifications sent to different destinations. They allow customization of messages based on the notification type.
You create Notification Templates for email, Slack, PagerDuty, and webhook notifications. These templates can be used when configuring notifications alongside Notification Targets.
Note: Notification Templates are Optional when configuring Notifications.
Using Notification Templates
Notification Templates can be referenced while configuring notifications for Notifiable Objects using Spyctl. You can either specify a Notification Target or a Notification Template that map specific targets to templates like below.
Example usage with Spyctl:
Example:
Usage:
The $spyctl notifications configure
command allows notifications to be sent using either Custom templates with Targets or directly via Targets (using Default Template).
Types:
Note: Below examples shows YAML Templates, but they can also be generated in JSON format.
Email
Email Notification Templates define the subject and body format for email notifications.
Note: Users must populate subject, body_html, and body_text using placeholders to customize the email content.
Slack
Slack Notification Templates define the message structure for Slack notifications. Notification templates can be generated in YAML or JSON format as desired.
After populating template:
Webhook
Webhook Notification Templates define the payload structure for webhook notifications.
After populating template:
PagerDuty
PagerDuty Notification Templates define the format for alerts sent to PagerDuty.
After populating template:
Use these templates to ensure consistent and structured notifications across different channels.
Placeholder Fields and Dynamic Variables
Some fields in Notification Templates are dynamically calculated and replaced at runtime using placeholders. These placeholders allow real-time data insertion into notification messages.
Understanding Placeholder Fields
Placeholder fields allow dynamic values to be inserted into notification templates. These fields are replaced with actual data when a notification is sent.
They're represent with syntax: __field__
Some Common Spyderbat Internal Placeholder Fields are:
{{ __source__ }} - Source of the event
{{ __cluster__ }} - Cluster where the event occurred
{{ __hr_time__ }} - Human-readable timestamp
{{ __linkback__ }} - Link to view the event in Spyderbat
{{ __time_int__ }} - Timestamp in integer format
{{ __origin__ }} - Origin of the event
{{ __hostname__ }} - Hostname where the event occurred
{{ __percent__ }} - Percentage value related to the event
{{ __pd_severity__ }} - Severity level formatted for PagerDuty
{{ __query_name__ }} - Name of the saved query that triggered the event
Example Usage in Email Body:
Dereferencing Values from the Object:
Static fields or regular placeholders ({{ severity }}, {{ description }}) are fields that are passed directly from the model object. Static text remains unchanged and does not need placeholders.
{{ severity }} - Severity level of the event
{{ description }} - Description of the event
By customizing Notification Templates with placeholders, users can ensure notifications provide meaningful and actionable information tailored to their needs.
To learn more about Placeholder fields and Constructing templates Read this
Conclusion
By following this guide, you can create well-structured, dynamic Notification Templates for different destinations. Using placeholders correctly ensures your notifications contain relevant, real-time data.
Manage Notification Templates Using Spyctl
To start creating Templates follow our tutorial using Spyctl : Manage Notification Templates Using Spyctl
Quick Start Tutorial
To quickly get started using using Spyderbat Notifications follow our tutorial using spyctl.
Last updated
Was this helpful?