Skip to main content

Add Notifications

You can add your own Notifiers by adding Spring Beans which implement the Notifier interface, at best by extendingAbstractEventNotifier or AbstractStatusChangeNotifier.

CustomNotifier.java
public class CustomNotifier extends AbstractEventNotifier {

private static final Logger LOGGER = LoggerFactory.getLogger(LoggingNotifier.class);

public CustomNotifier(InstanceRepository repository) {
super(repository);
}

@Override
protected Mono<Void> doNotify(InstanceEvent event, Instance instance) {
return Mono.fromRunnable(() -> {
if (event instanceof InstanceStatusChangedEvent) {
LOGGER.info("Instance {} ({}) is {}", instance.getRegistration().getName(), event.getInstance(),
((InstanceStatusChangedEvent) event).getStatusInfo().getStatus());
}
else {
LOGGER.info("Instance {} ({}) {}", instance.getRegistration().getName(), event.getInstance(),
event.getType());
}
});
}
}

Notification

Hipchat Notifications

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

Hipchat notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.hipchat.enabledEnable Hipchat notificationstrue
spring.boot.admin.notify.hipchat.ignore-changesComma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed."UNKNOWN:UP"
spring.boot.admin.notify.hipchat.urlThe HipChat REST API (V2) URL
spring.boot.admin.notify.hipchat.auth-tokenThe API token with access to the notification room
spring.boot.admin.notify.hipchat.room-idThe ID or url-encoded name of the room to send notifications to
spring.boot.admin.notify.hipchat.notifyWhether the message should trigger a user notificationfalse
spring.boot.admin.notify.hipchat.descriptionDescription 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 an incoming Webhook under custom integrations on your Slack account and configure it appropriately.

Slack notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.slack.enabledEnable Slack notificationstrue
spring.boot.admin.notify.slack.ignore-changesComma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed."UNKNOWN:UP"
spring.boot.admin.notify.slack.webhook-urlThe Slack Webhook URL to send notifications to.
spring.boot.admin.notify.slack.channelOptional channel name (without # at the beginning). If different from channel in Slack Webhooks settings
spring.boot.admin.notify.slack.iconOptional icon name (without surrounding colons). If different from icon in Slack Webhooks settings
spring.boot.admin.notify.slack.usernameOptional username to send notification if different from in Slack Webhooks settingsSpring Boot Admin
spring.boot.admin.notify.slack.messageMessage 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

Let’s Chat notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.letschat.enabledEnable let´s Chat notificationstrue
spring.boot.admin.notify.letschat.ignore-changesComma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed."UNKNOWN:UP"
spring.boot.admin.notify.letschat.urlThe let´s Chat Host URL to send notifications
spring.boot.admin.notify.letschat.roomthe room where to send the messages
spring.boot.admin.notify.letschat.tokenthe token to access the let´s Chat API
spring.boot.admin.notify.letschat.usernameThe username for which the token was createdSpring Boot Admin
spring.boot.admin.notify.letschat.messageMessage 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 set up a connector webhook url and set the appropriate configuration property.

Microsoft Teams notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.ms-teams.enabledEnable Microsoft Teams notificationstrue
spring.boot.admin.notify.ms-teams.webhook-urlThe Microsoft Teams webhook url to send the notifications to.
spring.boot.admin.notify.ms-teams.deRegisteredTitleTitle of the Teams message when an app de-registers.De-Registered
spring.boot.admin.notify.ms-teams.registeredTitleTitle of the Teams message when an app dregisters.Registered
spring.boot.admin.notify.ms-teams.statusChangedTitleTitle of the Teams message when an app changes status.Status Changed
spring.boot.admin.notify.ms-teams.messageSummarySummary section of every Teams message originating from Spring Boot Admin.Spring Boot Admin Notification
spring.boot.admin.notify.ms-teams.theme_colorSet 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_subtitleSubtitle 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_subtitleSubtitle 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_subtitleSubtitle 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.

Telegram notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.telegram.enabledEnable Telegram notificationstrue
spring.boot.admin.notify.telegram.auth-tokenThe token identifying und authorizing your Telegram bot (e.g. 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11).
spring.boot.admin.notify.telegram.chat-idUnique identifier for the target chat or username of the target channel
spring.boot.admin.notify.telegram.disable-notifyIf true users will receive a notification with no sound.false
spring.boot.admin.notify.telegram.parse_modeThe parsing mode for the sent message. Currently, `HTML' and 'Markdown' are supported.'HTML'
spring.boot.admin.notify.telegram.messageText to send. SpEL-expressions are supported."<strong>#{instance.registration.name}</strong>/#{instance.id} is <strong>#{event.statusInfo.status}</strong>"

Webex Notifications

To enable Webex notifications, you need to set the appropriate configuration properties for auth-token and room-id.

Webex notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.webex.enabledEnable Webex notificationstrue
spring.boot.admin.notify.webex.urlThe Webex server url to send the notifications to."https://webexapis.com/v1/messages"
spring.boot.admin.notify.webex.auth-tokenThe authentication token for your Webex account (e.g. 123456-ascbhuwbtzzk-abtabhixta-788654).
spring.boot.admin.notify.webex.room-idUnique identifier for the target room in Webex.
spring.boot.admin.notify.webex.messageText to send. SpEL-expressions are supported. By default, messages will be sent as Markdown, so you can include Markdown formatting."#{instance.registration.name} (#{instance.id}) is #{event.statusInfo.status}"

Discord Notifications

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

Discord notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.discord.enabledEnable Discord notificationstrue
spring.boot.admin.notify.discord.webhook-urlThe Discord webhook url to send the notifications to.
spring.boot.admin.notify.discord.usernameOptional username.Default set in Discord
spring.boot.admin.notify.discord.avatar-urlOptional URL to avatar.Default set in Discord
spring.boot.admin.notify.discord.ttsIf the message is a text to speech message.false
spring.boot.admin.notify.discord.messageText 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.

Notification Proxy configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.proxy.hostThe proxy host
spring.boot.admin.notify.proxy.portThe proxy port
spring.boot.admin.notify.proxy.usernameThe proxy username (if proxy requires authentication)
spring.boot.admin.notify.proxy.passwordThe 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

NotifierConfiguration.java
@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. The restful interface provides the following methods for getting, adding, and deleting notification filters:

  • GET notifications/filter
    • Returns a list of all registered notification filters. Each containing the attributes id, applicationName, expiry, and expired.
  • POST notifications/filters?instanceId=<yourInstanceId>&applicationName=<yourApplicationName>&ttl=<yourInstant>
    • Posts a new notification filter for the application/instance of the given instanceId or applicationName. Either instanceId or applicationName must be set. The parameter ttl is optional and represents the expiration of the filter as an instant (the number of seconds from the epoch of 1970-01-01T00:00:00Z).
  • DELETE notifications/filters/{id}
    • Deletes the notification filter with the requested id from the filters.

You may as well access all notification filter configurations via the main applications view inside SBA client, as seen in the screenshot below.

Sample notification filters

A FilteringNotifier might be useful, for instance, if you don’t want to receive notifications when deploying your applications. Before stopping the application, you can add an (expiring) filter via a POST request.

How to configure filtering

NotifierConfig.java
@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.
tip

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.

DingTalk notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.dingtalk.enabledEnable DingTalk notifications.true
spring.boot.admin.notify.dingtalk.webhook-urlThe DingTalk webhook url to send the notifications to.
spring.boot.admin.notify.dingtalk.secretThe secret to get message sign.
spring.boot.admin.notify.dingtalk.messageText to send. SpEL-expressions are supported."#{instance.registration.name} #{instance.id} is #{event.statusInfo.status} "

RocketChat Notifications

To enable Rocket.Chat notifications you need a personal token access and create a room to send message with this token

Table 10. RocketChat notifications configuration options

Property nameDescriptionDefault value
spring.boot.admin.notify.rocketchat.enabledEnable RocketChat notifications.true
spring.boot.admin.notify.rocketchat.urlThe RocketChat server url to send the notifications to.
spring.boot.admin.notify.rocketchat.userIdUser id user
spring.boot.admin.notify.rocketchat.tokenGenerated token user
spring.boot.admin.notify.rocketchat.roomIdThe room id to send the message
spring.boot.admin.notify.rocketchat.messageText to send. SpEL-expressions are supported."#{instance.registration.name} (#{instance.id}) is #{event.statusInfo.status}"