Oooooooffff…have you ever done something just SO stupid…
Techy alert!
So I am in the process of setting up graphite and statsd for use in our environment, and I was very proud of myself for getting a test version of Graphite up and running and turned my efforts to statsd, a NodeJS daemon written by etsy for aggregating stats via UDP and putting them into Graphite. Cool stuff. Graphite is not terribly well documented and requires a lot of prep work to make sure all the components are in place, but statsd is brain-dead simple: install NodeJS, clone statsd, create the config file and start it up…simple.
So I do all that, and I keep getting errors while it is reading my config file. That’s weird, it is about as simple JSON as you will find. I did what the README said: I copied exampleConfig.js “somewhere” (in my case, I copied it to config.js and edited it with my local parameters) and then I ran it: “node stats.js /my_path/config.js” I kept getting the same error over and over again about the “:” in my config file. It is amazing how many times you will run something hoping for a different result and never getting it. Of course I diddled the file for hours, putting quotes around different values, altering the white space, but all to no effect.
I glanced at the source for stats.js and noticed how the config file was being included and made a mental note that it looked odd that there were method calls on the config object, but figured it was just some Javascript magic since I don’t speak Javascript (even though I started to look at it thanks to MongoDB a few months back). Bad move. I sighed and thought to myself “There is an obvious solution here and I am going to feel like an idiot when I know what it is.” Then I went back to editing the config JSON for another, I don’t know, couple of hours?
At some point, though, you have to reset everything and take a fresh look. So I went to a new directory, cloned the project from github afresh, and took a look at the directory. Oh, look, there is already a config.js in there. Isn’t that weird! What’s in it? A whole bunch of code, not just one little JSON object. So that must have meant when I copied exampleConfig.js to config.js the first time, I obliterated a key module? Oh. Awesome. Copied exampleConfig.js to my_config.js, edited it, typed “node stats.js /path/my_config.js” and everything worked great.
Fuck me.