[英]Micrometer metrics & Application Insights java agent - Metrics accumulate although they shouldn't (or am I missing something)
We have a Java EE JAX-RS application (Java EE 8 hosted on WildFly 20), in which we have configured Micrometer (v1.6.4) as a metrics framework.我们有一个 Java EE JAX-RS 应用程序(Java EE 8 托管在 WildFly 20 上),其中我们将 Micrometer (v1.6.4) 配置为度量框架。 We are trying to connect it with Azure Application Insights so that metrics are made available to the relevant Application Insights resource (and then add alerts etc.).
我们正在尝试将其与 Azure Application Insights 连接,以便相关 Application Insights 资源可以使用指标(然后添加警报等)。
In order to do so, we have attached the codeless Application Insights agent (v3.0.2), which automatically publishes Micrometer metrics without any code changes.为此,我们附加了无代码 Application Insights 代理 (v3.0.2),该代理无需任何代码更改即可自动发布 Micrometer 指标。 On top of that, we have added a PrometheusMeterRegistry in the globalRegistry, only for debugging purposes (we do not use Prometheus).
最重要的是,我们在 globalRegistry 中添加了一个 PrometheusMeterRegistry,仅用于调试目的(我们不使用 Prometheus)。
Metrics.globalRegistry.add(new PrometheusMeterRegistry(PrometheusConfig.DEFAULT));
On top of that, we have configured an endpoint which returns the Prometheus data using the following snippet:最重要的是,我们配置了一个端点,它使用以下代码片段返回 Prometheus 数据:
PrometheusMeterRegistry promRegistry = (PrometheusMeterRegistry) registry;
result = promRegistry.scrape();
The agent has a configuration file attached to it in which only the connectionString and role name of the application are set.代理附加了一个配置文件,其中仅设置了应用程序的连接字符串和角色名称。
The agent starts correctly, and data are published in the Application Insights resource.代理正确启动,并且数据在 Application Insights 资源中发布。 Custom metrics are available for selection in the Monitoring -> Metrics area of the resource.
自定义指标可在资源的 Monitoring -> Metrics 区域中选择。
The issue we are facing is that the metrics data accumulate over time although they shouldn't.我们面临的问题是指标数据会随着时间的推移而累积,尽管它们不应该如此。 And to give an example:
并举个例子:
...
Builder timerBuilder = Timer.builder(timerName);
Timer timer = timerBuilder.register(metricsProducer.getMetricsRegistry());
return timer.record(() -> {
try {
return ctx.proceed();
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
});
Assume that we call the operation that is bound to the Counter only once.假设我们只调用一次绑定到 Counter 的操作。 We expect that the Counter value is 1, which is something that we confirm with logging.
我们期望 Counter 值为 1,这是我们通过日志记录确认的。 Assume also that we call the operation that is bound to the Timer only once.
还假设我们只调用一次绑定到 Timer 的操作。 We expect that only this triggering gets measured and recorded.
我们期望只有这种触发被测量和记录。
In the Application Insights resource, we see that the metric information gets updated every time the agent publishes information, and modifies the values without though any trigger in the backend.在 Application Insights 资源中,我们看到每次代理发布信息时都会更新指标信息,并在后端没有任何触发器的情况下修改值。 In particular, both of the metrics increase the Count aggregated value, but since for the Timer the duration does not change, the Average falls (suggesting that a metric value is passed with duration 0).
特别是,这两个指标都会增加 Count 聚合值,但由于 Timer 的持续时间不会改变,因此平均值会下降(表明通过持续时间 0 的指标值)。
On the other hand, when calling the Prometheus scraping endpoint, data are returned correctly, ie Count for both of the metrics stays to 1 and data are the expected ones.另一方面,当调用 Prometheus 抓取端点时,数据被正确返回,即两个指标的 Count 都保持为 1,并且数据是预期的。
I have tried the same using SpringBoot as the underlying framework, again with the same results.我已经尝试过使用 SpringBoot 作为底层框架,再次获得相同的结果。
Any thoughts?有什么想法吗? Am I missing something?
我错过了什么吗?
Thank you谢谢
Vangelis万吉利斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.