jjneely / statsrelay

A Golang consistent hashing proxy for statsd
MIT License
56 stars 19 forks source link

Add tags support in relayed metrics #14

Closed szibis closed 7 years ago

szibis commented 7 years ago

This PR adds support for statsd metrics tags supported by Datadog - https://help.datadoghq.com/hc/en-us/articles/204312749-Getting-started-with-tags

Adds new option metrics-tags which is used to add tags at the end of each metric just like prefix on the beginning. Sending metic with tags:

echo "test.service.counter:1|c|@1.000000|#foo:bar,test" | nc -w 1 -u 127.0.0.1 9125

and statsrelay running with example:

statsrelay -sendproto=TCP -b=127.0.0.1 -metrics-prefix=prefix -metrics-tags=relaytag,relay:tag 10.1.1.1:8125

This will produce:

prefix.test.service.counter:1|c|@1.000000|#foo:bar,test,relaytag,relay:tag
statsrelay.statsProcessed:1|c

If no tag in metric and defined in statsrelay then it will add statsrelay |#tags to every metric.

This feature should be very helpful with DataDog metrics management and any system supporting tags like InfluxDB backend for example. We can manage short key in metrics with dimensions defined in tags.

szibis commented 7 years ago

@jjneely can you take a look ?

jjneely commented 7 years ago

Sorry this has taken me so long. Life....work....

These changes look great, and it looks like there are several changes that will help keep statsrelay fast as well. Much appreciated.