Prometheus中Monitor添加对SpringBoot Actuator的Basic认证

背景

一般地,我们使用Prometheus对SpringBoot应用进行监控时,没有做任何认证,监控接口是完全开放的,我们直接访问暴露出来的指标接口http://localhost:8081/actuator/prometheus就可以拿到指标接口,这在某些程度上不安全。。

我们需要给我们的监控指标接口添加一个Base认证。

应用添加Basic认证

我这里是SpringBoot2.3.9版本,在添加spring-boot-starter-actuator和micrometer-registry-prometheus做指标暴露外,还在此基础之上还需要添加spring-boot-starter-security包。


ycyin大约 3 分钟云原生PrometheusSpring Boot