Now lets try to see how we can monitor our springboot appication running on tomcat using Prometheus.
We are using following technolgies
1- Maven as build tool
2- Spring boot as an microservice
3- Tomcat as an web server.
4- Prometheus window installation as an monitoring and alerting tools.
5- Spring boot with micrometer to convert actuator data into format that is under stable by Prometheus.
‘- Lets first create a simple springboot application Hello World using maven
we are using STS as an IDE. Please follow below step to create a simple hello world Spring book application.
Add following decencies in the project
Web , Spring Boot Actuator and micrometer Prometheus
Click finish and spring boot application with given decencies will be created.
Now lets run this spring boot application and check if we are able to execute it properly.
If you can see the actuator open only few of the link
To make all its url open use below line in the application.properties files
management.endpoints.web.exposure.include=*
Note:- dont try in production as it will expose your application information to the open world.
As shown above it will expose your Prometheus metric of spring boot application which can be now directly scrap by the Prometheus.
Now let configure prometheus.yml in our prometheus for springboot application so that we can scrap the data exposed by this url
http://localhost:8080/actuator/prometheus
Add following entries in prometheus.yml
- job_name: ‘my-springboot-application’
metrics_path: ‘/actuator/prometheus’
scheme: ‘http’
scrape_interval: 5s static_configs:- targets: [‘localhost:8080’]
Now Run the spring boot application and Prometheus window server and check target in it
Finally, see the graph in Prometheus.
No comments:
Post a Comment