如何解决Spring Boot 千分尺常用标签
在我的 Spring Boot application
中,将 micrometer
与 influxdb
一起使用,并且我正在尝试为我在下面写的内容添加通用标记 -
@Configuration
public class MeterRegistryConfiguration {
@Bean
public MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
String hostname = "";
try {
hostname = InetAddress.getLocalHost().getHostName().toString();
} catch (UnkNownHostException e) {
hostname = "unkNown";
}
List<Tag> tags = new LinkedList<>();
tags.add(Tag.of("hostname",hostname));
tags.add(Tag.of("service","service-name"));
return registry -> registry.config().commonTags(tags);
}
}
我用它作为 -
private MeterRegistry meterRegistry;
@Autowired
public DemoController(DemoService demoService,MeterRegistry meterRegistry){
this.demoService = demoService;
this.meterRegistry = meterRegistry;
}
.....
Counter.builder("demo.metrics")
.tag("tag","tag-1")
.description("Simple Monitoring")
.register(meterRegistry)
.increment();
但是在 influxdb 中,我没有看到添加了常用标签。我在这里缺少添加常用标签的功能。
如何在通用配置中添加 MeterFilter
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。