Dul*_*ter 7 java metrics spring-boot spring-boot-actuator prometheus
我已经激活了弹簧执行器prometheus endpont /actuator/prometheus.通过添加千分尺和执行器的依赖关系并启用prometheus endpont.我如何获得自定义指标?
ahu*_*us1 11
您需要使用Micrometer Registry注册您的指标.
以下示例在构造函数中创建度量标准.Micrometer注册表作为构造函数参数注入:
@Component
public class MyComponent {
private final Counter myCounter;
public MyComponent(MeterRegistry registry) {
myCounter = Counter
.builder("mycustomcounter")
.description("this is my custom counter")
.register(registry);
}
public String countedCall() {
myCounter.increment();
}
}
Run Code Online (Sandbox Code Playgroud)
一旦可用,您将在/ prometheus URL 中的注册表中获得指标mycustomcounter_total.添加后缀"total"以符合Prometheus命名约定.
| 归档时间: |
|
| 查看次数: |
4636 次 |
| 最近记录: |