Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Prometheus 如何配置弹簧测微计标记_Prometheus_Spring Boot Actuator_Spring Micrometer - Fatal编程技术网

Prometheus 如何配置弹簧测微计标记

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:

这篇博文提到

但是,它没有提供一个足够的示例,说明如何在Spring引导应用程序中设置相关的标记

现在,我正在使用SpringBoot2的测微计接口来提供Prometheus就绪的输出,而无需进行任何基于Java的配置。例如,设置“主机”标记是否需要我编写一些代码?那会是什么样子

以下是我的整个配置:

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(“主机”,主机名);
};
}
还有这里:还有这里: