今天带来:基于Prometheus的微服务应用监控。
本篇文章我们基于Prometheus和Grafana实现微服务应用监控。

SpringCloud aliabab微服务
KubeSphere平台本身提供了监控功能,包括节点状态、集群资源使用率、ETCD、APIServer等监控,不过缺少了应用级别的监控。
在应用中引入监控所需要的jar包,包含prometheus和actuator
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>io.micrometer</groupId>
- <artifactId>micrometer-registry-prometheus</artifactId>
- </dependency>
引入这2个包以后就通过prometheus抓取到应用的监控信息
- management:
- endpoints:
- web:
- exposure:
- include: "*"
- base-path: /
- metrics:
- tags:
- application: ${spring.application.name}
management.server.port:启用独立的端口来提供监控,未配置的情况下共用应用端口;
management.metrics.tags.xxx:在统计信息中添加自定义的标签;
management.endpoints.web.exposure.include:用于包含我们要公开的端点列表 , 我们这里设置为* 代表所有。
management.endpoints.web.base-path:用于设置promethues的监控路径,默认是通过/actuator/prometheus访问,这样配置以后只需要通过/prometheus访问<