简体   繁体   English

用Java发送石墨消息

[英]send graphite messages with java

I want to display metrics (just a simple requests per second/minute counter) with grafana. 我想使用grafana显示指标(仅是每秒/分钟的简单请求数)。 I use graphite to collect the metrics. 我使用石墨来收集指标。

When I use java to report the requests to graphite: 当我使用Java向石墨报告请求时:

        Graphite graphite = new Graphite(new InetSocketAddress("mygraphiteserver.com", 2003));
    MetricRegistry registry = new MetricRegistry();
    GraphiteReporter reporter = GraphiteReporter.forRegistry(registry)
            .prefixedWith("mymetrics.requests")
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .filter(MetricFilter.ALL)
            .build(graphite);
    reporter.start(1, TimeUnit.SECONDS);
    Meter loginRequests = registry.meter(name("successful"));
    loginRequests.mark();
    reporter.report();

The problem is, that everything runs without any exception, but the Graphite server does not get any metrics. 问题是,一切正常运行,但是Graphite服务器没有任何度量。 Any idea what is wrong her? 你知道她怎么了吗?

Furthermore, the name of this metric ("mymetrics.requests.successful") does not appear in the lists of metric series. 此外,此度量标准的名称(“ mymetrics.requests.successful”)不会出现在度量标准系列的列表中。

Thanks a lot in advance! 在此先多谢!

您需要先连接石墨.connect();

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

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