Prometheus 如何配置弹簧测微计标记
这篇博文提到 但是,它没有提供一个足够的示例,说明如何在Spring引导应用程序中设置相关的标记 现在,我正在使用SpringBoot2的测微计接口来提供Prometheus就绪的输出,而无需进行任何基于Java的配置。例如,设置“主机”标记是否需要我编写一些代码?那会是什么样子 以下是我的整个配置:Prometheus 如何配置弹簧测微计标记,prometheus,spring-boot-actuator,spring-micrometer,Prometheus,Spring Boot Actuator,Spring Micrometer,这篇博文提到 但是,它没有提供一个足够的示例,说明如何在Spring引导应用程序中设置相关的标记 现在,我正在使用SpringBoot2的测微计接口来提供Prometheus就绪的输出,而无需进行任何基于Java的配置。例如,设置“主机”标记是否需要我编写一些代码?那会是什么样子 以下是我的整个配置: management: metrics: export: prometheus: enabled: true endpoints: web:
management:
metrics:
export:
prometheus:
enabled: true
endpoints:
web:
exposure:
include: info,health,metrics,prometheus
有一个相关的例子,改编如下:
@Bean
MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
return registry -> {
String hostname = "unknown";
try { hostname = InetAddress.getLocalHost().getHostName(); }
catch (Exception e) {}
registry.config().commonTags("host", hostname);
};
}
@Bean
MeterRegistryCustomizer metricsCommonTags(){
返回注册表->{
字符串hostname=“未知”;
请尝试{hostname=InetAddress.getLocalHost().getHostName();}
捕获(例外e){}
registry.config().commonTags(“主机”,主机名);
};
}
还有这里:还有这里: