0

我想汇总一些指标。在我的监控应用程序中,我使用 HTTP 请求向所有微服务发送请求。微服务(在其他 JVM 中)报告指标,使用 dropwizard 和执行器,它运行良好,

在 for 循环中,我会这样调用:

String metricsQuery = queryHTTPMetrics(application);//String in json format, from dropwizard
JsonNode node = mapper.readTree(metricsQuery);
save(application, node);

然后前端使用 JsonNode,但现在我想重用保存的 JsonNode 将它们发送到 logstash 并避免请求所有微服务的新时间。

我可以为当前 JVM 中的当前 metricRegistry 制作一个 Slf4jReporter,但是如何与我在 HTTP 请求中寻址的远程 JVM 做同样的事情?我想注入我保存的所有 JsonNode :-/

final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
              .outputTo(LoggerFactory.getLogger("metrics"))
              .convertRatesTo(TimeUnit.SECONDS)
              .convertDurationsTo(TimeUnit.MILLISECONDS)
              .prefixedWith("monitoringApp")
              .build();
      reporter.start(monitoringProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);

我的记录器“指标”连接到 logstash appender 并且可以工作。

4

0 回答 0