简体   繁体   中英

Spring Boot auto-configured metrics not arriving to Librato

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM