IBM Cloud Docs
Event Streams Notification Template

Event Streams Notification Template

Event Streams is a message bus that is built by using Apache Kafka.In Event Streams, applications can send data by creating messages and sending to a topic. To receive messages, the application subscribes to a topic and can choose to receive all the messages of the topic or share the messages between them.

For more information on the Event Streams destination, see here.

Constructing an Event Streams notification template

Construct the template block. Make sure the template is a well-formed JSON that adheres to the Handlebars template syntax and semantics.

Handlebars is a templating language that allows for dynamic content generation within templates.Handlebars can be used to customize notification messages using template variables and conditional logic.

If the UI is used to create the template , Handlebars is used to create the payload for the body of the template. If API/CLI is used to create the template the payload must be encoded to the Base64 format. Refer the sample template for UI or AI/CLI.

UI Event Streams notification template example

{
  {{#equal data.alert_definition.severity "Critical"}}
		"severity": 1,
	{{/equal}}
  {{#equal data.alert_definition.severity "Info"}}
		"severity": 2,
	{{/equal}}
  {{#equal data.alert_definition.severity "Error"}}
		"severity": 2,
	{{/equal}}
  "console": "toc",
  "version": "1.0",
  "crn": {
    "version": "v1",
    "ctype": "public",
    "cname": "bluemix",
    "resource_type": "object",
    "resource": "event-notifications",
    "service_name": "event-notifications"
    },
  "alert_id": "{{data.alert_definition.id}}",
  "tribe_name": "Mobile",
  "disable_pager": "false",
  "source": "{{source}}",
  "tip_msg_type": "create.notice",
  "situation": "{{ibmendefaultshort}}",
  "customer_impacting": "false",
  "runbook_toc_enabled": "false",
  "short_description": "{{ibmendefaultshort}}",
  "product_ready_compliance": "true",
  "long_description": "{{data.alert_definition.description}}",
  "timestamp": "{{time}}",
  "alert_ui_url": "{{data.links.view_alert}}",
  "runbook_url": "{{data.alert_definition.meta_labels.runbook}}"
}

API or CLI Event Streams notification template example

    {
	"name": "Template for ",
	"params": {
		"body": "ewogIHt7I2VxdWFsIGRhdGEuYWxlcnRfZGVmaW5pdGlvbi5zZXZlcml0eSAiQ3JpdGljYWwifX0KCQkic2V2ZXJpdHkiOiAxLAoJe3svZXF1YWx9fQogIHt7I2VxdWFsIGRhdGEuYWxlcnRfZGVmaW5pdGlvbi5zZXZlcml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CI6ICJ7e2RhdGEubGlua3Mudmlld19hbGVydH19IiwKICAicnVuYm9va191cmwiOiAie3tkYXRhLmFsZXJ0X2RlZmluaXRpb24ubWV0YV9sYWJlbHMucnVuYm9va319Igp9"
	},
	"type": "eventstreams.notification"
    }