jmxtrans / jmxtrans-agent

Java Agent based JMX metrics exporter.
MIT License
179 stars 110 forks source link

Multi-tag issue in StatsDOutputWriter #123

Closed ncolomer closed 6 years ago

ncolomer commented 6 years ago

This issue is about #118 which adds tag support to StatsDOutputWriter.

Looking at DogStatsD Datagram Format documentation, it appears the current implementation is not fully compatible when we declare more than one tag.

Indeed, considering the following jmxtrans-agent configuration:

<jmxtrans-agent>
  <queries>
    <query objectName="java.lang:type=Threading" attributes="ThreadCount" resultAlias="jvm.thread.#attribute#"/>
  </queries>
  <outputWriter class="org.jmxtrans.agent.StatsDOutputWriter">
    <statsd>dd</statsd>
    <host>localhost</host>
    <port>8125</port>
    <tags>service:helloworld,environment:staging</tags>
    <metricName>statsd</metricName>
  </outputWriter>
  <collectIntervalInSeconds>20</collectIntervalInSeconds>
</jmxtrans-agent>

We can observe that the jmxtrans agent (v1.2.7) sends the following messages:

$ nc -ul 8125
statsd.jvm.thread.ThreadCount:128|c|#service:helloworld,#environment:staging,#host:41b85f034724
...

Resulting into datapoints tagged with keys service, #environment and #host instead of expected service, environment and host (we're using telegraf's statsd input).

To fix this, according to Datadog Metrics documentation, the agent should send the previous message as follows:

statsd.jvm.thread.ThreadCount:128|c|#service:kourou,environment:staging,host:41b85f034724

This looks to be the same issue for Sysdig.

A PR fixing the issue will be submitted by tomorrow. Edit: see #124

cc @jakobant @cyrille-leclerc