Skip to main content

Notification

To understand more concepts of notification in Siren, you can visit this page.

Sending a message/notification

We could send a notification with POST /notifications API to a specific receiver by passing receiver labels information in the receivers field in the body. The payload format needs to follow receiver type contract.

Field NameTypeRequired?Description
receiverslist of jsonyesSelector of receivers using receiver labels
[
{
"id": 3,
},
{
"type": "slack_channel",
"team": "de-infra"
},
{
"type": "email",
"team": "de-experience"
}
]
This will fetch all receivers that have the labels.
datajsonyesany data that we want to pass to the message. The data will populate the corresponding template or content variables.
templatestringnotemplate name that will be used to populate the message. default template will be used if this value is empty. errors might be thrown if there are errors when parsing template.
labelsjsonnoIf populated, labels would be used by subscription matchers to find the subscribers that listen to specific labels. e.g.
{
"team": "de-infra",
"severity": "CRITICAL"
}

Example: Sending Notification to Slack

Assuming there is a slack receiver registered in Siren with ID 51. Sending to that receiver would require us to have a payload.data that have the same format as the expected slack payload format.

payload.yaml
payload:
data:
text: |-
New Paid Time Off request from <example.com|Fred Enriquez>

<https://example.com|View request>
template: sample-slack-msg
$ siren notifications send --file payload.yaml

Above end the message to channel name #siren-devs with payload.data in slack payload format.

Alerts Notification

For all incoming alerts via Siren hook API, notifications are also generated and published via subscriptions. Siren will match labels from the alerts with label matchers in subscriptions. The assigned receivers for all matched subscriptions will get the notifications. More details are explained here.

Siren has a default template for alerts notification for each receiver. Go to the Receivers section to explore the default template defined by Siren.