Pull type monitoring system. OSS. A system that can monitor memory and CPU usage.
Normal surveillance systems (Meckerel, Sensu, etc.) Install an agent on the monitoring side and send information to the monitoring server.
On the contrary, the Pull type acquires information from the side monitored by the monitoring server.
Push type
[merit] ・ Easy to install the app on the monitoring target -There are few changes in server settings even if the number of monitoring targets increases.
[Demerit] -When the amount of monitoring increases, the load on the monitoring server increases.
Pull type
[merit] ・ It is easier to see that the monitoring target is down than the Push type. -The load on the monitoring server is lower than Push
[Demerit] -You have to set the endpoint to be monitored. It's not just a simple installation. ・ When the number of monitoring targets increases, it is necessary to set each time.
In Spring application, link data to Promethus, Display nicely with Grafana.
Added Spring Actuator from Spring Initializr [https://start.spring.io/]. Spring Actuator will be able to check Spring dumps and health checks.
Set Micrometer Registry Prometheus as a dependency. [ https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus ]
Open the endpoint from the property file.
application.properties
#Full open
management.endpoints.web.exposure.include=*
Start the application and confirm that the endpoint is created.
http://localhost:8080/actuator/prometheus
Can be set with the following YML
prometheus.yml
global:
#Frequency of target acquisition
scrape_interval: 10s
evaluation_interval: 10s
#Monitoring target settings
scrape_configs:
#Spring Boot App Exporter monitoring settings
- job_name: 'springboot'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['web:8080']
labels:
group: 'docker-springboot'
Start with Docker Compose.
docker-compose.yml
version: '3.1'
services:
web:
build: app/
ports:
- "8080:8080"
monitor:
build: prometheus/
ports:
- "9090:9090"
depends_on:
- "web"
grafana:
image: grafana/grafana
ports:
- "3000:3000"
▼ Screen to confirm the monitoring target
http://54.238.228.193:9090/targets
▼ Graph confirmation screen
http://54.238.228.193:9090/graph
However, the UI of the graph is not good enough. So look at Grafana.
URL: http://localhost:3000 ID: admin (initial) PASS: admin (initial)
▼ Select a data source
Set the URL as below
▼ Dashboard creation
Select Add Query
After that, set it to your liking
・ Promethuns endpoint classes set in Spring can be inherited and customized independently.
・ Notification settings may be difficult for Promethuns and Grafana
Recommended Posts