0

I want to aggregate some metrics. In my monitoring application, i send requests on all microservices with HTTP request. The microservices(in other JVM) report metrics, with dropwizard and actuator, it's work well,

in a for loop, i make calls like that :

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

Then the frontend use the JsonNode, but now i want to reuse the save JsonNode to send them in logstash and avoid to request a new time all microservices.

I can make a Slf4jReporter wich work for the current metricRegistry in the current JVM, but how to make the same with distant JVM I adress in HTTP request ? I want to inject all JsonNode I have saved :-/

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);

My logger "metrics" is connected to a logstash appender and works.

Jérémie
  • 91
  • 1
  • 7
  • If you check [this list](http://modules.dropwizard.io/thirdparty/) - "The Dropwizard GELF provides an AppenderFactory which is automatically registered in Dropwizard and will send log messages directly to your configured GELF-enabled server." - https://github.com/gini/dropwizard-gelf – zloster Apr 16 '17 at 14:24
  • Thanks for that 3rd party, but i've already manage to send metrics to logstash, it's not my problem. I have to send metrics from different JVM. i can't modify all microservices, i'll have to aggregate by adressing them with REST calls. Your addon cant make that :( – Jérémie Apr 18 '17 at 10:18
  • IMO "aggregate" is not the correct word than for what you are trying to do. Do a web search for "aggregate metrics" and you will see what I mean. – zloster Apr 19 '17 at 08:03
  • You're right ! i'm not really fluent in english, but i've search for hours and i havent found something like that. :( – Jérémie Apr 19 '17 at 11:48
  • Your (or the company) approach to the metrics collection is not good from a scaling perspective - when you start to have a good deal of instances you will notice that it becomes very hard to keep the data updated at your single point that is sending requests to collect the metrics. I suspect this is the reason why it's hard to find information. – zloster Apr 19 '17 at 13:04
  • I agree, but we can't modify our approach now, i'm a little surprise that nobody encounter that problem. the REST api should be use if actuator propose it, don't you think ? – Jérémie Apr 19 '17 at 16:28
  • That's a topic for another discussion. Back to your problem: basically you need to forward the already gathered metrics to logstash. If you can't find a ready made solution, you'll have to implement it by writing something similar to the `Slf4jReporter` but without the MetricRegistry object to get the data for the report (the data is already available as String/JsonNode). – zloster Apr 19 '17 at 19:22

0 Answers0