Notifications

Mail Notifications

Mail notifications will be delivered as HTML emails rendered using Thymeleaf templates. To enable Mail notifications, configure a JavaMailSender using spring-boot-starter-mail and set a recipient.

Sample Mail Notification
Sample Mail Notification
Figure 1. Sample Mail Notification
To prevent disclosure of sensitive information, the default mail template doesn’t show any metadata of the instance. If you want to you show some of the metadata you can use a custom template.
  1. Add spring-boot-starter-mail to your dependencies:

    pom.xml
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
  2. Configure a JavaMailSender

    application.properties
    spring.mail.host=smtp.example.com
    spring.boot.admin.notify.mail.to=admin@example.com
  3. Configure the mail with the options below

    Table 1. Mail notifications configuration options
    Property name Description Default value

    spring.boot.admin.notify.mail.enabled

    Enable mail notifications

    true

    spring.boot.admin.notify.mail.ignore-changes

    Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed.

    "UNKNOWN:UP"

    spring.boot.admin.notify.mail.template

    Resource path to the Thymeleaf template used for rendering.

    "classpath:/META-INF/spring-boot-admin-server/mail/status-changed.html"

    spring.boot.admin.notify.mail.to

    Comma-delimited list of mail recipients

    "root@localhost"

    spring.boot.admin.notify.mail.cc

    Comma-delimited list of carbon-copy recipients

    spring.boot.admin.notify.mail.from

    Mail sender

    "Spring Boot Admin <noreply@localhost>"

    spring.boot.admin.notify.mail.additional-properties

    Additional properties which can be accessed from the template

PagerDuty Notifications

To enable PagerDuty notifications you just have to add a generic service to your PagerDuty-account and set spring.boot.admin.notify.pagerduty.service-key to the service-key you received.

Table 2. PagerDuty notifications configuration options
Property name Description Default value

spring.boot.admin.notify.pagerduty.enabled

Enable mail notifications

true

spring.boot.admin.notify.pagerduty.ignore-changes

Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed.

"UNKNOWN:UP"

spring.boot.admin.notify.pagerduty.service-key

Service-key to use for PagerDuty

spring.boot.admin.notify.pagerduty.url

The Pagerduty-rest-api url

"https://events.pagerduty.com/generic/2010-04-15/create_event.json"

spring.boot.admin.notify.pagerduty.description

Description to use in the event. SpEL-expressions are supported

"#{instance.registration.name}/#{instance.id} is #{instance.statusInfo.status}"

spring.boot.admin.notify.pagerduty.client

Client-name to use in the event

spring.boot.admin.notify.pagerduty.client-url

Client-url to use in the event

OpsGenie Notifications

To enable OpsGenie notifications you just have to add a new JSON Rest API integration to your OpsGenie account and set spring.boot.admin.notify.opsgenie.api-key to the apiKey you received.

Table 3. OpsGenie notifications configuration options
Property name Description Default value

spring.boot.admin.notify.opsgenie.enabled

Enable OpsGenie notifications

true

spring.boot.admin.notify.opsgenie.ignore-changes

Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed.

"UNKNOWN:UP"

spring.boot.admin.notify.opsgenie.api-key

apiKey you received when creating the integration

spring.boot.admin.notify.opsgenie.url

OpsGenie Alert API url

"https://api.opsgenie.com/v2/alerts"

spring.boot.admin.notify.opsgenie.description

Description to use in the event. SpEL-expressions are supported

"#{instance.registration.name}/#{instance.id} is #{instance.statusInfo.status}"

spring.boot.admin.notify.opsgenie.actions

Comma separated list of actions that can be executed.

spring.boot.admin.notify.opsgenie.source

Field to specify source of alert. By default, it will be assigned to IP address of incoming request.

spring.boot.admin.notify.opsgenie.tags

Comma separated list of labels attached to the alert.

spring.boot.admin.notify.opsgenie.entity

The entity the alert is related to.

spring.boot.admin.notify.opsgenie.user

Default owner of the execution. If user is not specified, the system becomes owner of the execution.

Hipchat Notifications

To enable Hipchat notifications you need to create an API token on your Hipchat account and set the appropriate configuration properties.

Table 4. Hipchat notifications configuration options
Property name Description Default value

spring.boot.admin.notify.hipchat.enabled

Enable Hipchat notifications

true

spring.boot.admin.notify.hipchat.ignore-changes

Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed.

"UNKNOWN:UP"

spring.boot.admin.notify.hipchat.url

The HipChat REST API (V2) URL

spring.boot.admin.notify.hipchat.auth-token

The API token with access to the notification room

spring.boot.admin.notify.hipchat.room-id

The ID or url-encoded name of the room to send notifications to

spring.boot.admin.notify.hipchat.notify

Whether the message should trigger a user notification

false

spring.boot.admin.notify.hipchat.description

Description to use in the event. SpEL-expressions are supported

"<strong>#{instance.registration.name}</strong>/#{instance.id} is <strong>#{event.statusInfo.status}</strong>"

Slack Notifications

To enable Slack notifications you need to add a incoming Webhook under custom integrations on your Slack account and configure it appropriately.

Table 5. Slack notifications configuration options
Property name Description Default value

spring.boot.admin.notify.slack.enabled

Enable Slack notifications

true

spring.boot.admin.notify.slack.ignore-changes

Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed.

"UNKNOWN:UP"

spring.boot.admin.notify.slack.webhook-url

The Slack Webhook URL to send notifications to.

spring.boot.admin.notify.slack.channel

Optional channel name (without # at the beginning). If different than channel in Slack Webhooks settings

spring.boot.admin.notify.slack.icon

Optional icon name (without surrounding colons). If different than icon in Slack Webhooks settings

spring.boot.admin.notify.slack.username

Optional username to send notification if different than in Slack Webhooks settings

Spring Boot Admin

spring.boot.admin.notify.slack.message

Message to use in the event. SpEL-expressions and Slack markups are supported

"*#{instance.registration.name}* (#{instance.id}) is *#{event.statusInfo.status}*"

Let’s Chat Notifications

To enable Let’s Chat notifications you need to add the host url and add the API token and username from Let’s Chat

Table 6. Let’s Chat notifications configuration options
Property name Description Default value

spring.boot.admin.notify.letschat.enabled

Enable let´s Chat notifications

true

spring.boot.admin.notify.letschat.ignore-changes

Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed.

"UNKNOWN:UP"

spring.boot.admin.notify.letschat.url

The let´s Chat Host URL to send notifications

spring.boot.admin.notify.letschat.room

the room where to send the messages

spring.boot.admin.notify.letschat.token

the token to access the let´s Chat API

spring.boot.admin.notify.letschat.username

The username for which the token was created

Spring Boot Admin

spring.boot.admin.notify.letschat.message

Message to use in the event. SpEL-expressions are supported

"*#{instance.registration.name}* (#{instance.id}) is *#{event.statusInfo.status}*"

Microsoft Teams Notifications

To enable Microsoft Teams notifications you need to setup a connector webhook url and set the appropriate configuration property.

Table 7. Microsoft Teams notifications configuration options
Property name Description Default value

spring.boot.admin.notify.ms-teams.enabled

Enable Microsoft Teams notifications

true

spring.boot.admin.notify.ms-teams.webhook-url

The Microsoft Teams webhook url to send the notifications to.

spring.boot.admin.notify.ms-teams.deRegisteredTitle

Title of the Teams message when an app de-registers.

De-Registered

spring.boot.admin.notify.ms-teams.registeredTitle

Title of the Teams message when an app dregisters.

Registered

spring.boot.admin.notify.ms-teams.statusChangedTitle

Title of the Teams message when an app changes status.

Status Changed

spring.boot.admin.notify.ms-teams.messageSummary

Summary section of every Teams message originating from Spring Boot Admin.

Spring Boot Admin Notification

spring.boot.admin.notify.ms-teams.theme_color

Set the theme color. SpEL-expressions are supported.

#{event.type == 'STATUS_CHANGED' ? (event.statusInfo.status=='UP' ? '6db33f' : 'b32d36') : '439fe0'}

spring.boot.admin.notify.ms-teams.deregister_activity_subtitle

Subtitle of the Activity section of the Teams message when an app de-registers. SpEL-expressions are supported.

#{instance.registration.name} with id #{instance.id} has de-registered from Spring Boot Admin

spring.boot.admin.notify.ms-teams.register_activity_subtitle

Subtitle of the Activity section of the Teams message when an app registers. SpEL-expressions are supported.

#{instance.registration.name} with id #{instance.id} has registered with Spring Boot Admin

spring.boot.admin.notify.ms-teams.status_activity_subtitle

Subtitle of the Activity section of the Teams message when an app changes status. SpEL-expressions are supported.

#{instance.registration.name} with id #{instance.id} changed status from #{lastStatus} to #{event.statusInfo.status}

Telegram Notifications

To enable Telegram notifications you need to create and authorize a telegram bot and set the appropriate configuration properties for auth-token and chat-id.

Table 8. Telegram notifications configuration options
Property name Description Default value

spring.boot.admin.notify.telegram.enabled

Enable Telegram notifications

true

spring.boot.admin.notify.telegram.auth-token

The token identifying und authorizing your Telegram bot (e.g. 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11).

spring.boot.admin.notify.telegram.chat-id

Unique identifier for the target chat or username of the target channel

spring.boot.admin.notify.telegram.disable-notify

If true users will receive a notification with no sound.

false

spring.boot.admin.notify.telegram.parse_mode

The parsing mode for the sent message. Currently `HTML' and 'Markdown' are supported.

'HTML'

spring.boot.admin.notify.telegram.message

Text to send. SpEL-expressions are supported.

"<strong>#{instance.registration.name}</strong>/#{instance.id} is <strong>#{event.statusInfo.status}</strong>"

Discord Notifications

To enable Discord notifications you need to create a webhook and set the appropriate configuration property.

Table 9. Discord notifications configuration options
Property name Description Default value

spring.boot.admin.notify.discord.enabled

Enable Discord notifications

true

spring.boot.admin.notify.discord.webhook-url

The Discord webhook url to send the notifications to.

spring.boot.admin.notify.discord.username

Optional username.

Default set in Discord

spring.boot.admin.notify.discord.avatar-url

Optional URL to avatar.

Default set in Discord

spring.boot.admin.notify.discord.tts

If the message is a text to speech message.

false

spring.boot.admin.notify.discord.message

Text to send. SpEL-expressions are supported.

"*#{instance.registration.name}* (#{instance.id}) is *#{event.statusInfo.status}*"

Notification Proxy Settings

All Notifiers which are using a RestTemplate can be configured to use a proxy.

Table 10. Notification Proxy configuration options
Property name Description Default value

spring.boot.admin.notify.proxy.host

The proxy host

spring.boot.admin.notify.proxy.port

The proxy port

spring.boot.admin.notify.proxy.username

The proxy username (if proxy requires authentication)

spring.boot.admin.notify.proxy.password

The proxy password (if proxy requires authentication)

Notification Reminder

The RemindingNotifier sends reminders for down/offline applications, it delegates the sending of notifications to another notifier.

By default a reminder is triggered when a registered application changes to DOWN or OFFLINE. You can alter this behaviour via setReminderStatuses(). The reminder ends when either the status changes to a non-triggering status or the regarding application gets deregistered.

By default the reminders are sent every 10 minutes, to change this use setReminderPeriod(). The RemindingNotifier itself doesn’t start the background thread to send the reminders, you need to take care of this as shown in the given example below;

How to configure reminders
@Configuration
public class NotifierConfiguration {
    @Autowired
    private Notifier notifier;

    @Primary
    @Bean(initMethod = "start", destroyMethod = "stop")
    public RemindingNotifier remindingNotifier() {
        RemindingNotifier notifier = new RemindingNotifier(notifier, repository);
        notifier.setReminderPeriod(Duration.ofMinutes(10)); (1)
        notifier.setCheckReminderInverval(Duration.ofSeconds(10)); (2)
        return notifier;
    }
}
1 The reminders will be sent every 10 minutes.
2 Schedules sending of due reminders every 10 seconds.

Filtering Notifications

The FilteringNotifier allows you to filter certain notification based on rules you can add/remove at runtime. It delegates the sending of notifications to another notifier.

If you add a FilteringNotifier to your ApplicationContext a RESTful interface on notifications/filter gets available.

This notifier is useful if you don’t want receive notifications when deploying your applications. Before stopping the application you can add an (expiring) filter either via a POST request.

How to configure filtering
@Configuration(proxyBeanMethods = false)
public class NotifierConfig {

        private final InstanceRepository repository;

        private final ObjectProvider<List<Notifier>> otherNotifiers;

        public NotifierConfig(InstanceRepository repository, ObjectProvider<List<Notifier>> otherNotifiers) {
                this.repository = repository;
                this.otherNotifiers = otherNotifiers;
        }

        @Bean
        public FilteringNotifier filteringNotifier() { (1)
                CompositeNotifier delegate = new CompositeNotifier(this.otherNotifiers.getIfAvailable(Collections::emptyList));
                return new FilteringNotifier(delegate, this.repository);
        }

        @Primary
        @Bean(initMethod = "start", destroyMethod = "stop")
        public RemindingNotifier remindingNotifier() { (2)
                RemindingNotifier notifier = new RemindingNotifier(filteringNotifier(), this.repository);
                notifier.setReminderPeriod(Duration.ofMinutes(10));
                notifier.setCheckReminderInverval(Duration.ofSeconds(10));
                return notifier;
        }

}
1 Add the FilteringNotifier bean using a delegate (e.g. MailNotifier when configured)
2 Add the RemindingNotifier as primary bean using the FilteringNotifier as delegate.
This example combines the reminding and filtering notifiers. This allows you to get notifications after the deployed application hasn’t restarted in a certain amount of time (until the filter expires).

DingTalk Notifications

To enable DingTalk notifications you need to create and authorize a dingtalk bot and set the appropriate configuration properties for webhookUrl and secret.

Table 11. DingTalk notifications configuration options
Property name Description Default value

spring.boot.admin.notify.dingtalk.enabled

Enable DingTalk notifications.

true

spring.boot.admin.notify.dingtalk.webhook-url

The DingTalk webhook url to send the notifications to.

spring.boot.admin.notify.dingtalk.secret

The secret to get message sign.

spring.boot.admin.notify.dingtalk.message

Text to send. SpEL-expressions are supported.

"#{instance.registration.name} #{instance.id} is #{event.statusInfo.status} "