Prometheus集成SpringBoot1.5

Prometheus集成SpringBoot1.5

pom

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

<!-- Actuator (with security enabled) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<!-- Monitoring endpoint - Micrometer + Prometheus -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.0.3</version>
<exclusions>
<exclusion>
<artifactId>HdrHistogram</artifactId>
<groupId>org.hdrhistogram</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-spring-legacy</artifactId>
<version>1.0.3</version>
</dependency>

bootstrap.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
management:
endpoints:
web:
exposure:
include: '*'
jmx:
exposure:
include: '*'
shutdown:
enabled: true
metrics:
distribution:
percentiles-histogram[http.server.requests]: true
security:
enabled: false

application.java

1
2
3
4
5
6
7
@Bean
MeterRegistryCustomizer meterRegistryCustomizer(MeterRegistry meterRegistry) {
return meterRegistry1 -> {
meterRegistry.config()
.commonTags("application", "micrometer-web");
};
}

配置

prometheus.yml

1
2
3
4
- job_name: 'app-41'
metrics_path: '/mgmt/prometheus'
static_configs:
- targets: ['192.168.1.41:9915']

重启服务

1
2
3
docker ps

docker restart `prometheus-processid`

登录验证

1
2
prometheus 192.168.1.41:9090
grafana 192.168.1.41:3000 admin/admin
------ 本文结束------

本文标题:Prometheus集成SpringBoot1.5

文章作者:Perkins

发布时间:2019年08月02日

原始链接:https://perkins4j2.github.io/posts/42635/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。