Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Memo 2: Spring Boot Actuator+Prometheus+Grafana

Shulou Source: shulou.com Published: 2022-06-03 02:07:08 10月03日 Update

One: Spring Boot Actuator

Spring-boot-actuator can monitor and manage applications as they are put into production. You can choose to use HTTP endpoints or JMX to manage and monitor applications

Introducing Spring-boot-actuator into Spring boot applications

Org.springframework.boot spring-boot-starter-actuator

3.application.yml file configuration

# managementmanagement: endpoints: web: exposure: include: "*" endpoint: health: show-details: ALWAYS

4.Spring Boot Actuator built-in Endpoints

Two: Prometheus

Add Micrometer Prometheus registration to the Spring Boot application.

Io.micrometer micrometer-registry-prometheus

2.Docker pulls Prometheus image

Docker pull prom/prometheus

3. Prometheus configuration file

# my global configglobal: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. Evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.rule_files: #-"first_rules.yml" #-"second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape:# Here it's Prometheus itself.scrape_configs: # The job name is added as a label `job= `to any timeseries scraped from this config. -job_name: 'prometheus' # metrics_path defaults to' / metrics' # scheme defaults to 'http'. Static_configs:-targets: ['127.0.0.1 job_name 9090']-job_name:' spring-actuator' metrics_path:'/ mybatis/actuator/prometheus' scrape_interval: 5s static_configs:-targets: ['112.74.105.178spring-actuator' metrics_path']

4. Run the Prometheus container

Docker run-d-- name=prometheus-p 9090V / mnt/demo/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus-- config.file=/etc/prometheus/prometheus.yml

5. View the operation of Prometheus

Three: Grafana

Docker runs Grafana image

Docker run-d-- name=grafana-p 3000UR 3000 grafana/grafana

2. Grafana configure Prometheus data source

3. Monitoring dashboard

Tags: Applications applications programs runs configurations files mirrors monitoring management available in containers conditions data data sources endpoints inputs production monitoring selection memos Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Docker Apple OPPO Reno Shulou Information