您好,登錄后才能下訂單哦!
一:Spring Boot Actuator
Spring-boot-actuator 可在將應用程序投入生產時監視和管理應用程序。可以選擇使用 HTTP 端點或 JMX 來管理和監控應用程序
Spring boot 應用中引入 Spring-boot-actuator
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
3.application.yml文件配置
# management management: endpoints: web: exposure: include: "*" endpoint: health: show-details: ALWAYS
4.Spring Boot Actuator內置Endpoints
二: Prometheus
將Micrometer Prometheus 注冊添加到Spring Boot應用。
<dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency>
2.Docker 拉取 Prometheus鏡像
docker pull prom/prometheus
3.
Prometheus 配置文件
# my global config global: 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=<job_name>` 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:9090'] - job_name: 'spring-actuator' metrics_path: '/mybatis/actuator/prometheus' scrape_interval: 5s static_configs: - targets: ['112.74.105.178:8888']
4.運行 Prometheus容器
docker run -d --name=prometheus -p 9090:9090 -v /mnt/demo/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml
5.查看 Prometheus運行情況
三:Grafana
Docker 運行Grafana鏡像
docker run -d --name=grafana -p 3000:3000 grafana/grafana
2. Grafana 配置 Prometheus數據源
3.監控dashboard
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。