[英]Spring Boot 2 Actuator Micrometer setup
我有一個 Spring 引導應用程序,我有這個依賴:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.1.7.RELEASE</version> // From Parent
</dependency>
我還配置了我的application.yml
文件以公開指標:
management:
endpoints:
web:
exposure:
include: info, health, metrics
我還為 Kafka 創建了一個 Metrics bean:
@Bean
public KafkaConsumerMetrics kafkaConsumerMetrics() {
return new KafkaConsumerMetrics();
}
但是當我點擊端點GET http://localhost:8080/actuator/metrics
時,我收到404 Page Not Found
錯誤。
其他端點(信息/健康)有效: http://localhost:8080/actuator/info和http://localhost:8080/actuator/health
我缺少什么來獲取千分尺數據?
您可以嘗試從配置中啟用指標,但默認情況下應該啟用它
management:
endpoint:
metrics:
enabled: true
有關執行器屬性的更多詳細信息https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#actuator-properties
對於指標、bean 等受限endpoints
:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
在你的 yml 中:
management:
security:
enabled: true
security:
basic:
enabled: true
然后配置 class 像:
@EnableWebSecurity
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("admin").
password("admin").roles("ADMIN");
auth.inMemoryAuthentication().withUser("admin").
password("admin").roles("ACTUATOR");
}
}
然后啟用受限的執行器端點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.