Alert with spring boot admin server

Hi folks,

In my previous post, I explained about how to monitor spring boot application with spring boot admin server. In today’s post I will explain about how we can send alert notifcation from spring boot admin server if any application goes down/up.

Spring boot admin server supports multiple notification mechanism as below:

  • Reminder
  • Mail
  • Hipchat
  • Slack
  • Telegram
  • etc.

In today’s tutorial I will cover, how to send mail notifcation with spring boot admin server. To read into more detail follow this.

Let’s start with the implemenation.

Changes in admin server

Add following dependency in pom.xml:

   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>

After adding this dependency, it will enable mail notification for the project. Now add following properties in application.properties file:

server.port=9001

## Host for the email server
spring.mail.host=smtp.gmail.com

## Email server port
spring.mail.port = 587

## Comma separated list of email ids to which email notification should be sent
spring.boot.admin.notify.mail.to=xxx@gmail.com

## Whether enable email notification or not
spring.boot.admin.notify.mail.enabled=true

# Username of the email
spring.mail.username=xxx@abc.com

## Password of the sender's email
spring.mail.password=xxxx

## Protocal for the email server
spring.mail.protocol=smtp

## Whether email connection has to test on application startup or not
spring.mail.test-connection=true

spring.mail.properties.mail.smtp.starttls.enable=true

Just start the admin server and register a client application, created in previous post, with admin server and then close the client application. If everythings goes well it will send an email of application down status according to the email configuration as explained in following demo video:

Admin server mail notification

As you have seen in above video, when I stop my client application then admin server automatically sends an email to my configured email id.

That’s all about how to send mail notification from spring boot admin server.

Demo project can be found here for admin-server and for admin-client.

One thought on “Alert with spring boot admin server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s