Skip to main content

Default channel types

Several default alert channel implementations are provided out-of-the-box by the alertingImpl component in the alerting-component-default expansion resource (which is also included in the alerting-component resource). As these implementations are addons that process routed alerts, it just has to be added as a dependency of the application. No other component should depend on alertingImpl. All resolution of the channels is implemented by the expanders based on the presence of these channel types in the application.

EmailChannel


The email channel type implemented by alertingImpl::EmailChannel is a channel type that sends alerts over email to a recipient. Every recipient email address is considered to be an individual channel. The implementation of this channel type uses the default JEE mailing system, so the majority of the configuration of the email server is done in the tomee.xml file of the application server as data sources. The resolution of this configuration is done dynamically based on the resource name. So multiple email servers can be configured if needed. This channel has full support for UTF-8 in email body, sender name and recipient name.

The name field is the functional key of this channel and used to reference it from SubscriptionRoute. The config field has the option alert.configName, so it is used to store the key for the config properties group in the alerting.ns.properties file. The emailAddress field (required) contains the email address of the recipient and the recipientName field (required) contains the name of the recipient.

The properties for this channel have the following keys:

  • from.email (required): Sender email address.
  • from.name (required): Sender name.
  • mailSession (required): Identifier of the mail session resource in tomee.xml that should be used.
  • template (optional): The string template that should be used to generate the body of the email. (Default: /net/democritus/alerting/impl/alerts/alert_email_body.stg)
Example properties
alerts.emailChannel.default.from.email=noreply@example.com
alerts.emailChannel.default.from.name=Spammer1337
alerts.emailChannel.default.mailSession=mailSession_1

To use this properties group, the config field of a channel would have the value default.

Templating

An alternative template can be supplied by setting the template property to the resource path of a new stg file. Aside from the default mappings, the EmailChannel also adds the following mappings:

  • channel.recipient: Maps to the name of the recipient as set in EmailChannel.recipientName.

Default template

The default email template will look something like this:

Default email template example

Depending on the alert priority, the color of the header will change:

  • NONE
  • LOW
  • MEDIUM
  • HIGH
  • CRITICAL

SlackChannel


The Slack channel type implemented by alertingImpl::SlackChannel is a channel type that sends alerts over Slack to a channel (a channel can also be a user channel). All configuration of this channel type is done through the alerting.ns.proprties file and the DataElement itself.

The name field is the functional key of this channel and used to reference it from SubscriptionRoute. The config field has the option alert.configName, so it is used to store the key for the config properties group in the alerting.ns.properties file. The channel field (required) contains the channel identifier of the Slack channel that the alert should be sent to. The channel identifier can be found by opening the channel details page for a channel, where the identifier is shown at the bottom. To send a notification to a user, use their member ID instead. This can be found in the additional options menu on their profile.

The properties for this channel have the following keys:

  • apiToken (required): The Slack API token for the Slack application to send notifications with. This should be a bot token, which starts with xoxb-.
  • template (optional): The string template that should be used to generate the body of the email. (Default: /net/democritus/alerting/impl/alerts/alert_slack.stg)
Example properties
alerts.slackChannel.default.apiToken=xoxb-my-token-here

To use this properties group, the config field of a channel would have the value default.

Templating

An alternative template can be supplied by setting the template property to the resource path of a new stg file. Aside from the default mappings, the SlackChannel does not any additional mappings.

Default template

The default Slack template will look something like this:

Default Slack template exampleDefault Slack template example

PushoverChannel


The Pushover channel type implemented by alertingImpl::PushoverChannel is a channel type that sends alerts over the Pushover notification service, which is a service to send push notifications to a mobile app using a web API. All configuration of this channel type is done through the alerting.ns.proprties file and the DataElement itself.

The name field is the functional key of this channel and used to reference it from SubscriptionRoute. The config field has the option alert.configName, so it is used to store the key for the config properties group in the alerting.ns.properties file. The targetKey field (required) contains the key of the Pushover channel which an alert should be sent to. This can be either a user key to directly push to a user or a group key to push to a delivery group.

The properties for this channel have the following keys:

  • appToken (required): The application token that is generated by Pushover for the application that must be registered to send push notifications through the API. Each application should be registered separately, so notifications from different applications can easily be identified.
Example properties
alerts.pushoverChannel.default.appToken=123thisIs4tOken

To use this properties group, the config field of a channel would have the value default.

Implementation

The PushoverChannel does not currently use the templating engine, as Pushover offers an API with specific fields to provide. Though the message itself can be formatted, this was excluded for simplicity.

The alert priorities are mapped to Pushover priorities as follows:

AlertPriorityPushover
CRITICALEMERGENCY
HIGHHIGH
MEDIUMNORMAL
LOWLOW
NONELOWEST

LoggingChannel


The Pushover channel type implemented by alertingImpl::LoggingChannel is a very simple channel type that writes alerts to logs. This is mainly intended to test and debug the setup of the alerting component. It has no configuration other than the channel name fields, which is the functional key of this channel and used to reference it from SubscriptionRoute.

Implementation

The alert priorities are mapped to logging severities as follows:

AlertPrioritySeverity
CRITICALERROR
HIGHERROR
MEDIUMWARNING
LOWINFO
NONEDEBUG