Spring Boot Admin does not send email when services goes offline

4/25/2019

I have an environment with different services. I use Spring Boot Admin in order to monitor them therefor I wanted to implement an email notification when any services goes offline. I have followed the official documentation: http://codecentric.github.io/spring-boot-admin/1.4.6/#mail-notifications

This is the pom of my Spring Admin Boot:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.3.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<groupId>com.vocento.ekos</groupId>
<artifactId>admin-server</artifactId>
<version>0.0.1</version>
<name>admin-server</name>
<description>Demo project for Spring Boot</description>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>11</java.version>
</properties>

<dependencies>
    <!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server -->
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-server</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server-ui</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server-ui-login</artifactId>
        <version>1.5.7</version>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-dependencies</artifactId>
            <version>2.1.3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

And this is my properties file:

server:
port: ${admin-server.port:8086}
tomcat:
   remote-ip-header: x-forwarded-for
   protocol-header: x-forwarded-proto
spring:
   application:
     name: admin-server
   security:
     user:
       name: ****
       password: ****
boot:
   admin:
     client:
        url: ${admin-server.client:http://localhost:8086}
        username: ${spring.security.user.name}
        password: ${spring.security.user.password}
        instance:
          metadata:
            user:
              name: ${spring.security.user.name}
              password: ${spring.security.user.password}
     notify:
       mail:
          to: ****@gmail.com
 mail:
    host: smtp.gmail.com
    port: 587
    username: ****@*****.com (It is a company's mail but using gmail)
    password: *****

I firstly tried with port, username and password in the properties file as stated in the documentation.

With this configuration I am facing this issue:

  • The email is not sent when the service goes offline, not even a traces is shown on the logs.

What am I missing here?

-- NeoChiri
java
javamail
kubernetes
spring-boot
spring-boot-admin

0 Answers