一、SpringBoot配置.
①、引入依赖
org.springframework.bootspring-boot-starter-actuator
io.micrometermicrometer-registry-prometheus
②、开启监控
management:endpoints:web:exposure:include: prometheus
③、启动服务,查看监控采集:
http://test.code.com/skywalk/actuator/prometheus
二、定义Prometheus监控任务.
①、prometheus.yml
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: ["localhost:9090"]- job_name: 'Windows'static_configs:- targets: ['192.168.1.6:9182']labels:instance: Windows# 新添加的采集目标- job_name: "skywalk-boot"metrics_path: '/skywalk/actuator/prometheus'static_configs:- targets: ["192.168.1.6:80"]
②、启动prometheus
③、 查看界面
三、启动Grafana
①、直接启动即可.
springboot监控面板,推荐第一个非常不错.
Dashboards | Grafana Labs
设置时间段:
【附录】
例如Kafka的监控收集指标,封装了一整套的采集-发送框架,可扩展各种中间件监控,对于自研一套内部的业务采集监控指标很有参考意义.