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 Name | Type | Required? | Description |
---|---|---|---|
receivers | list of json | yes | Selector 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. | |||
data | json | yes | any data that we want to pass to the message. The data will populate the corresponding template or content variables. |
template | string | no | template 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. |
labels | json | no | If 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:
data:
text: |-
New Paid Time Off request from <example.com|Fred Enriquez>
<https://example.com|View request>
template: sample-slack-msg
- CLI
- HTTP
$ siren notifications send --file payload.yaml
$ curl --request POST
--url http://localhost:8080/v1beta1/notifications
--header 'content-type: application/json'
--data-raw '{
"payload": {
"data": {
"text": "New Paid Time Off request from <example.com|Fred Enriquez>
<https://example.com|View request>"
}
}
}'
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.