简体   繁体   English

Spring Boot自动配置的指标未到达Librato

[英]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. 我正在使用启用了自动配置(@EnableAutoConfiguration)的Spring Boot,并尝试将Spring MVC指标发送到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. 现在,只有我自己创建的指标到达Librato,但是自动配置的指标(CPU,文件描述符等)没有发送给我的记者。

If I access a metric endpoint I can see the info generated there, for instance http://localhost:8081/actuator/metrics/system.cpu.count 如果我访问度量标准端点,则可以看到在那里生成的信息,例如http://localhost:8081/actuator/metrics/system.cpu.count

I based my code on this post for ConsoleReporter. 我的代码基于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()); 在我的主要功能上,我添加了Metrics.addRegistry(SpringReporter.libratoRegistry());

For the Librato library I am using in my compile("com.librato.metrics:metrics-librato:5.1.2") build.gradle. 对于Librato库,我在自己的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. 如果我在这篇文章中使用ConsoleReporter,则会发生同样的事情,只有我自己创建的指标会打印到控制台。

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. 尝试将您的MeterRegistry for Librato记者设置为Spring @Bean ,让我知道它是否有效。


UPDATED: 更新:

I tested with ConsoleReporter you mentioned and confirmed it's working with a sample . 我使用您提到的ConsoleReporter进行了测试,并确认它正在处理示例 Note that the sample is on the branch console-reporter , not the master branch. 请注意,该示例位于分支console-reporter ,而不是master分支上。 See the sample for details. 有关详细信息,请参见示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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