elastic / elasticsearch-metrics-reporter-java

Metrics reporter, which reports to elasticsearch
Apache License 2.0
231 stars 103 forks source link

Add support for labels #53

Open fabMrc opened 7 years ago

fabMrc commented 7 years ago

Hi

Like other reporters, it will be nice to add the labels support for each metrics types. It allows drilldown and aggregation over dimensions. Traditionnally hostname/instanceId/port are some common labels. For exemple :

{
  "name": "usa-gov-heartbearts",
  "@timestamp": "2013-07-20T09:29:58.000+0000",
  "count": 18
  "tags":
    {
        "hostname": "server1",
        "service_id": "myapplication_id",
        "port": 8087,
        "other_label": 1.0
    }
}

And the API

ElasticSearchReporter reporter= ElasticSearchReporter .forRegistry(metrics). .withTags(ImmutableMap.of("other", "tags")).prefix(prefix).build()
vyaghini commented 7 years ago

+1 this. Otherwise you end up adding everything to the metric name and then have to parse it and extract all the info.