Collection of Spring utilities supporting integration with Docker/Portainer. This is not an official Portainer.io project, yet.
To use services, endpoints and other utilities contained in this project please add following dependency to your pom.xml:
<dependency>
<groupId>eu.icole</groupId>
<artifactId>spring-utils</artifactId>
<version>0.0.3</version>
</dependency>
Currently the only endpoint offered is actuator/docker/health.
The purpose of this Actutator endpoint is to help you provide an status on the health of your application to the Docker engine, so it could be visualised by the Pointainer. First to enable the endpoint you need to add following line in your application.properties:
management.endpoints.web.exposure.include=docker
Then next step is to tell our endpoint which indicators shall be monitored.
icole.docker.health.indicators=diskSpace,portainerStatus
In our example we have choosen two: diskSpace and portainerStatus. If any of this indicators will fail, the Docker will be instructed to show unhealty status together with the output message generated by our failed indicator.
By default this endpoint have a value 'list' provided, so after accessing it by the browser you will see a list of all indicators offered by the Spring.
The other two values possible, beside the list of indicators provided by you, are: 'none' and 'all'. First will always return an healty status, the other will check all indicators offered by Spring for your application.
To make possible for Docker to check status of your Spring application you need to add following line in the Dockerfile.
For wget:
HEALTHCHECK --interval=15s --timeout=10s CMD wget -qO- --content-on-error=on http://localhost:8080/actuator/docker/health || exit 1
For curl:
HEALTHCHECK --interval=15s --timeout=10s CMD curl -f http://localhost:8080/actuator/docker/health || exit 1
The Polish readers can read my article published on Medium on the issue of monitoring the health of application by Docker: https://medium.com/@artur_87325/ciągłe-dostarczanie-sprawdzanie-zdrowia-aplikacji-939af5890b8c
Checking if telegraf process is running.
Checking if there is a connection to database.
Enjoy!