0
votes

I want to display metrics (just a simple requests per second/minute counter) with grafana. I use graphite to collect the metrics.

When I use java to report the requests to graphite:

        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. Any idea what is wrong her?

Furthermore, the name of this metric ("mymetrics.requests.successful") does not appear in the lists of metric series.

Thanks a lot in advance!

1
I had same problem with plain protocol on 2003. Did you try pickled graphite? PickledGraphite pickledGraphite = new PickledGraphite(new InetSocketAddress("127.0.0.1", 2004)); - Suvitruf - Andrei Apanasik
Try sending metrics directly to Graphite using netcat (nc) to test if the connection to Graphite is working as expected. - dukebody
@dukebody Thanks, I used the following command to test the connection: echo "<<my.series.name 42 `date +%s`" | nc <<mygraphiteserver>> 2003 which works fine. - Andre Grunow
@Suvitruf Thanks for the hint. I changed to PickledGraphite, but the result is the same. Unfortunately. - Andre Grunow
Just tried this with the latest from github.com/dropwizard/metrics, works fine to my Graphite server. One thing I didn't have is your name() method; what does it do? - Jonathan Ross

1 Answers

-1
votes

you need to connect first like graphite.connect();