Monitoring Rails Unicorn Memory and Idle/Busy Workers with Datadog — Strange Bedfellows
Overview
When I tried to monitor Unicorn with Datadog on the host running Rails,
there didn’t seem to be any suitable Integration ((if there is one, please let me know >_< )).
So I figured I’d write my own custom script!
Just as I was about to write a custom script…
A colleague said: “Mackerel has a plugin for that, you know?”
Me: “Huh? …”
Mackerel was already installed
Mackerel turned out to have a plugin for monitoring Unicorn.
Since the folks at Hatena have kindly released it as OSS,
and reinventing the wheel is a waste of time,
and you only live once, I decided to use this Mackerel plugin with Datadog.
A “strange bedfellows” Mackerel + Datadog script
- /etc/dd-agent/unicorn_check.py
1 | from checks import AgentCheck |
- /etc/dd-agent/conf.d/unicorn_check.yaml
Specify Unicorn’s PID file.
1 | init_config: |
Checking the Datadog Agent configuration file
1 | $ sudo dd-agent configcheck |
Restarting the Datadog Agent
1 | $ sudo service datadog-agent restart |
Checking the graph a few minutes later
There it is!
Wrap-up
And just like that, we got “strange bedfellows”-style monitoring working!
There’s a slight sense of guilt in being neither one camp nor the other,
but I think the value of this article lies in how quickly we cobbled together
a working solution, so I put pen to paper.
I hope you find it useful.

