addthis / metrics-reporter-config

Apache License 2.0
74 stars 52 forks source link

Failed to load metrics-reporter-config, metric sinks will not be activated #9

Closed piavlo closed 10 years ago

piavlo commented 10 years ago

then using the metrics-reporter-config with cassandra , no matter what reporter configuration i use(graphite,riemann,console) i always get this

INFO [main] 2014-08-03 21:27:01,911 CassandraDaemon.java (line 393) Trying to load metrics-reporter-config from file: /etc/cassandra/metrics.yaml WARN [main] 2014-08-03 21:27:01,912 CassandraDaemon.java (line 401) Failed to load metrics-reporter-config, metric sinks will not be activated java.lang.NullPointerException at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:396) at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:496) at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:585)

i've tried the reporter-config 2.1.0 that comes with cassandra 2.0.9 as well versions 2.2.0 and 2.4.0-SNAPSHOT build from the repo with relevant reporters jars(and dependencies) deployed under cassandra lib dir the result is always the same error , even for console reporter config like this

console:
  -
    outfile: '/tmp/metrics.out'
    period: 10
    timeunit: 'SECONDS'

i've verified that /etc/cassandra/metrics.yaml is valid yaml file any clues what can be wrong?

cburroughs commented 10 years ago

Is that the full stack trace? The NPE doesn't actually inclue any https://github.com/apache/cassandra/blob/cassandra-2.0.9/src/java/org/apache/cassandra/service/CassandraDaemon.java#L396 code

https://github.com/apache/cassandra/blob/cassandra-2.0.9/src/java/org/apache/cassandra/service/CassandraDaemon.java#L396

tea-dragon commented 10 years ago

Looks like your system property is pointing to the wrong place. The null reference is almost certainly from the getResource call chained with get file.

See: http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String) On Aug 4, 2014 9:29 AM, "cburroughs" notifications@github.com wrote:

Is that the full stack trace? The NPE doesn't actually inclue any https://github.com/apache/cassandra/blob/cassandra-2.0.9/src/java/org/apache/cassandra/service/CassandraDaemon.java#L396 code

https://github.com/apache/cassandra/blob/cassandra-2.0.9/src/java/org/apache/cassandra/service/CassandraDaemon.java#L396

— Reply to this email directly or view it on GitHub https://github.com/addthis/metrics-reporter-config/issues/9#issuecomment-51059485 .

tea-dragon commented 10 years ago

I suppose since it is printing the location, and it looks like what you expect, it could be a permissions thing. I'd double check that and the exact path/ name. On Aug 4, 2014 10:35 AM, "Ian Barfield" ian@addthis.com wrote:

Looks like your system property is pointing to the wrong place. The null reference is almost certainly from the getResource call chained with get file.

See: http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String) On Aug 4, 2014 9:29 AM, "cburroughs" notifications@github.com wrote:

Is that the full stack trace? The NPE doesn't actually inclue any https://github.com/apache/cassandra/blob/cassandra-2.0.9/src/java/org/apache/cassandra/service/CassandraDaemon.java#L396 code

https://github.com/apache/cassandra/blob/cassandra-2.0.9/src/java/org/apache/cassandra/service/CassandraDaemon.java#L396

— Reply to this email directly or view it on GitHub https://github.com/addthis/metrics-reporter-config/issues/9#issuecomment-51059485 .

piavlo commented 10 years ago

@tea-dragon There is no permissions issue with the file or path to the file it's fully readable by everyone also if i rename the file i do not get any message/exception.

@cburroughs how do i get a full stack trace? I've tried changing INFO logging level to DEBUG and TRACE which caused the the log to be very verbose but the NPE is still same as with INFO level with no extra stack trace info.

tea-dragon commented 10 years ago

I can't imagine why renaming the file would help... maybe you can elaborate on that. Also, this looks like it is using a ClassLoader, so maybe you should double check your java class path. Unless you are using a custom class loader, I doubt it will find files without being included therein.

On Mon, Aug 4, 2014 at 3:45 PM, piavlo notifications@github.com wrote:

@tea-dragon https://github.com/tea-dragon There is no permissions issue with the file or path to the file it's fully readable by everyone also if i rename the file i do not get any message/exception.

@cburroughs https://github.com/cburroughs how do i get a full stack trace? I've tried changing INFO logging level to DEBUG and TRACE which caused the the log to be very verbose but the NPE is still same as with INFO level with no extra stack trace info.

— Reply to this email directly or view it on GitHub https://github.com/addthis/metrics-reporter-config/issues/9#issuecomment-51107757 .

cburroughs commented 10 years ago

I meant that the first line of the stack trace was in a.o.cassandra code, it isn't even getting to any code in metrics-reporter-config. I wanted to make sure part of the stack trace wasn't getting cut off somewhere.

Try putting your metrics.yaml file in the cassandra conf directory and loading it with just -Dcassandra.metricsReporterConfigFile=metrics.yaml. If that works then your problem is probably some funky java classloader thing. You may need to use a file:// junk in your url.

piavlo commented 10 years ago

@tea-dragon - sorry i was not clear enough , i did not meant it helps but just that it does nothing then i give it nonexisting file path

piavlo commented 10 years ago

@cburroughs using -Dcassandra.metricsReporterConfigFile=metrics.yaml indeed solve the issue tnx a lot for the help

rmatte01 commented 9 years ago

Same issue. @cburroughs solutions helped to resolve it. Thanks for the question and answer. !!!

avteja commented 8 years ago

I am facing the same issue using Cassandra 3.5.0 on Windows 7. I tried the above suggestion (of @cburroughs) , but I still get a FileNotFoundException as below (though I have the `metrics-reporter-config.yaml' in the correct directory). I have checked permissions of the file, anyone can access and edit. I am using metrics-graphite-3.1.0.jar.

Exception: java.io.FileNotFoundException: C:\Program%20Files\DataStax-DDC\apache-cassandra\conf\metrics-reporter-config.yaml (The system cannot find the path specified) at java.io.FileInputStream.open0(Native Method) ~[na:1.8.0_91] at java.io.FileInputStream.open(FileInputStream.java:195) ~[na:1.8.0_91] at java.io.FileInputStream.(FileInputStream.java:138) ~[na:1.8.0_91] at com.addthis.metrics.reporter.config.AbstractReporterConfig.loadFromFile(AbstractReporterConfig.java:40) ~[reporter-config-base-3.0.0.jar:3.0.0] at com.addthis.metrics3.reporter.config.ReporterConfig.loadFromFile(ReporterConfig.java:249) ~[reporter-config3-3.0.0.jar:3.0.0] at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:337) [apache-cassandra-3.5.0.jar:3.5.0] at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:551) [apache-cassandra-3.5.0.jar:3.5.0]

yuesong commented 8 years ago

AbstractReporterConfig.java:40 is:

InputStream input = new FileInputStream(new File(fileName));

https://github.com/addthis/metrics-reporter-config/blob/master/reporter-config-base/src/main/java/com/addthis/metrics/reporter/config/AbstractReporterConfig.java#L40

There's nothing to it. Is C:\Program%20Files\DataStax-DDC\apache-cassandra\conf\metrics-reporter-config.yaml a valid path? Specially, %20 is the URL encoded value of space - I don't think that's a valid file path. You can easily test it with the above one-liner java code - I don't have Windows otherwise I would've done it.

avteja commented 8 years ago

Yes, you are right. Thank You. I made it work by reinstalling Cassandra into a path which has folder names with no spaces. I don't know if it is possible to handle the above error in any different way. If possible, can you suggest any way to do so?

yuesong commented 8 years ago

It has to do with how cassandra finds the config file - it uses the classloader to find resource URL, then just calls URL#getFile() on it. Special characters, such as space, are url encoded, and getFile method doesn't do anything smarter with it, so you end up with an invalid file path. The relevant code is here:

https://github.com/apache/cassandra/blob/58e11acdd08d046016591c34547b7bd4c3f3f051/src/java/org/apache/cassandra/service/CassandraDaemon.java#L344

Line number don't quite match with your stack trace, because I can't find the right tag, but I doubt the code is very different.

vsr7 commented 8 years ago

Am getting this error when tried to integrate Ganglia with cassandra. I followed similar steps provided as above( I used ganglia) .

INFO 11:10:24,963 Completed flushing /var/lib/cassandra/data/system/local/system-local-jb-76-Data.db (5298 bytes) for commitlog position ReplayPosition(segmentId=1470211824179, position=193311) INFO 11:10:24,978 Node localhost/127.0.0.1 state jump to normal INFO 11:10:24,994 Trying to load metrics-reporter-config from file: gangliaReporting.yaml ERROR 11:10:25,016 Tried to enable GangliaReporter, but class com.yammer.metrics.reporting.GangliaReporter was not found

WARN 11:10:25,016 No reporters were succesfully enabled

Please guide me on how to proceed. I would like to monitor the cassandra metrics onto ganglia.