0

I am using Spring Boot with auto-configure enabled (@EnableAutoConfiguration) and trying to send my Spring MVC metrics to Librato. Right now only my own created metrics are arriving to Librato but auto-configured metrics (CPU, file descriptors, etc) are not sent to my reporter.

If I access a metric endpoint I can see the info generated there, for instance http://localhost:8081/actuator/metrics/system.cpu.count

I based my code on this post for ConsoleReporter. so I have this:

public static MeterRegistry libratoRegistry() {
    MetricRegistry dropwizardRegistry = new MetricRegistry();

    String libratoApiAccount = "xx";
    String libratoApiKey = "yy";
    String libratoPrefix = "zz";

    LibratoReporter reporter = Librato
            .reporter(dropwizardRegistry, libratoApiAccount, libratoApiKey)
            .setPrefix(libratoPrefix)
            .build();
    reporter.start(60, TimeUnit.SECONDS);

    DropwizardConfig dropwizardConfig = new DropwizardConfig() {
        @Override
        public String prefix() {
            return "myprefix";
        }

        @Override
        public String get(String key) {
            return null;
        }
    };

    return new DropwizardMeterRegistry(dropwizardConfig, dropwizardRegistry, HierarchicalNameMapper.DEFAULT, Clock.SYSTEM) {
        @Override
        protected Double nullGaugeValue() {
            return null;
        }
    };
}

and at my main function I added Metrics.addRegistry(SpringReporter.libratoRegistry());

For the Librato library I am using in my compile("com.librato.metrics:metrics-librato:5.1.2") build.gradle. Documentation here. I used this library before without any problem.

If I use the ConsoleReporter as in this post the same thing happens, only my own created metrics are printed to the console.

Any thoughts on what am I doing wrong? or what am I missing?

Also, I enabled debug mode to see the "CONDITIONS EVALUATION REPORT" printed in the console but not sure what to look for in there.

diegoubi
  • 1,101
  • 13
  • 17

1 Answers1

2

Try to make your MeterRegistry for Librato reporter as a Spring @Bean and let me know whether it works.


UPDATED:

I tested with ConsoleReporter you mentioned and confirmed it's working with a sample. Note that the sample is on the branch console-reporter, not the master branch. See the sample for details.

Johnny Lim
  • 5,623
  • 8
  • 38
  • 53
  • Hi, I updated your sample to add the ConsoleReporter and same thing happening: my created counter is printed in console but auto-configured metrics (cpu, endpoint timings, etc) are not printed, You can see the updated sample here: https://github.com/diego-carvallo-tx/sample-micrometer-spring-boot – diegoubi Aug 09 '18 at 18:35
  • @sapeish I guess you misread my updated answer. The above "a sample" meant to point to the branch `console-reporter`. Try the branch. – Johnny Lim Aug 09 '18 at 22:18
  • @sapeish FTR your updated sample didn't make your custom `MeterRegistry` as a Spring `@Bean`. – Johnny Lim Aug 09 '18 at 22:25
  • 1
    You are absolutely right! I cloned your sample to check it out but didn't notice the ConsoleReporter was in the `console-reporter` branch so I looked at your master branch only. It is working now, Thanks a lot! – diegoubi Aug 10 '18 at 16:24