airbnb / kafka-statsd-metrics2

Send Kafka Metrics to StatsD.
Apache License 2.0
135 stars 49 forks source link

Jar silently fails to initialize? #13

Open djudd opened 9 years ago

djudd commented 9 years ago

(I'm not sure if this is a bug or just something I'm doing wrong but I'm not sure where else to ask for help. At least, the installation instructions may be missing something.)

I added the jar to the kafka libs directory (and later verified that it's on the classpath with ps). I added the following configuration lines to server.properties, and restarted my kafka broker:

kafka.metrics.reporters=com.airbnb.kafka.KafkaStatsdMetricsReporter

external.kafka.statsd.reporter.enabled=true
external.kafka.statsd.host=localhost
external.kafka.statsd.port=8125

Initially I got an error for a missing statsd client class, which I fixed by adding the linked statsd client jar as well - perhaps this should be more explicit in the installation instructions. But then I failed to get any further results. No message like "Kafka Statsd metrics reporter is enabled" and no errors in the logs.

This is with kafka 0.8.2.1 and kafka-statsd-metrics2 0.4.1

Praburaj commented 9 years ago

+1. I observe the same as well. I can see that the KafkaStatsdMetricsReporter is getting initialized as I can see errors reported when I give an incorrect value for any of the statsd settings. However I don't see any metrics reported to statsd server. Any help will be appreciated.

dlanderson commented 9 years ago

I had the same problem using Scala 2.10, kafka 8.2.2. The reporter would initialize properly but no statsd metrics were emitted. After making sure my CLASSPATH only included the kafka core libs, I rebuilt using ./gradlew shadowJar and copied the resulting build/libs/kafka-statsd-metrics2-0.4.1-all.jar to the kafka lib dir - works great now.

E.g:

  1. git clone https://github.com/airbnb/kafka-statsd-metrics2.git
  2. cd kafka-statsd-metrics2
  3. env CLASSPATH=/usr/lib/kafka/kafka_2.10-0.8.2.2/libs/* ./gradlew shadowJar --info
  4. cp build/libs/kafka-statsd-metrics2-0.4.1-all.jar /usr/lib/kafka/kafka_2.10-0.8.2.2/libs/
dtboctor commented 8 years ago

Seeing this same problem, with kafka 0.9, scala 2.11, recompiling didn't fix it.

brendan-munro commented 7 years ago

I am also seeing this issue, also with Kafka 0.9. I've followed the above recommendations and still have no positive results.

michaelmoss commented 7 years ago

I encountered the same issue. Everything was initializing ("Started KafkaStatsDReporter..." in the logs), but no metrics were being produced. I tracked down the issue to our inclusion of another library, https://github.com/endgameinc/storm-metrics-statsd which uses the popular com.timgroup.java-statsd-client. It turns out, this repo, kafka-statsd-metrics2 includes com.indeed:java-dogstatsd-client which has classes with the same name and package as the timgroup jar its forked from. These seem to be conflicting at runtime.

https://github.com/tim-group/java-statsd-client/blob/master/src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java https://github.com/indeedeng/java-dogstatsd-client/blob/master/src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java

I made it so my project just imports one, and everything works. I'll let the maintainers, now datadog, know they should update the package name to prevent these conflicts.

https://github.com/DataDog/java-dogstatsd-client/blob/master/src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java

KendallWeihe commented 7 years ago

I'm running into this same issue

porridge commented 6 years ago

I think I'm running into the same issue. But I cannot see any evidence of class loader or type errors anywhere in my logs. Has anyone tracked down why the metrics are just silently missing?

FTR, using the datadog's distribution rather than the timgroup one fixed it for me:

 -      "com.timgroup" % "java-statsd-client" % "3.0.1"
 +      "com.datadoghq" % "java-dogstatsd-client" % "2.5"