VictorOps is pretty awesome. Think an extensible, actionable Pagerduty. Somewhere where you can integrated DevOps tools to automate your escalation and response process all in one place. I have downed the Flavor Aid1 and bought in. They offer a plethora built in integrations and a simple yet versatile REST Alert API. They do not have an official ruby API client and I couldn’t find one out there in the community, so I put one together this weekend.
victor_ops-client gem.2 This came together based off of experience writing different bots for some of the clients I work for. It offers a common naming pattern for your
monitoring_tool description and
Here is how to use it:
Install the gem
gem install victor_ops-client
Require it in your script
Initialize your client
# Required for Initializing Client API_URL = 'INSERT_URL_HERE' ROUTING_KEY = 'INSERT_ROUTING_KEY_HERE' client = VictorOps::Client.new api_url: API_URL, routing_key: ROUTING_KEY
API_URL is an
Incoming Webhook URL provided by VictorOps. You can find it by looking at your
Settings -> Integrations -> REST Endpoint. The
ROUTING_KEY is URI compliant string that you would like to use to route messages within VitorOps and the Transmogrifier.
On initialization you can pass in
monitoring_tool as extra values that will be used in the generation of alerts. If you don’t, the tool will auto populate the values with defaults. I recommend that you pass in a
name at the least. Any value that you pass in on initialization can be accessed directly through a
Once you have established your client, you can send any of the supported alert messages to VictorOps with a simple interface and convenience methods.
# Send a CRITICAL alert client.critical 'THE DISK IS FULL!!!' # Send a WARNING alert client.warn desc: 'Disk is nearing capacity', stats: `df -h` # Send an INFO alert client.info [ 'this', 'is', 'an', 'array' ] # Send an ACKNOWLEDGMENT client.ack 'bot ack' # Send a RECOVERY client.recovery desc: 'Disk has space', emoji: ':saiyan:'
Note that the payload you are sending can be either a
HASH. The helper methods convert the input to the alert methods using
awesome_print. I do this so that you can pack important metadata into the
state_message within VictorOps easily in the code.
If you would like to take a look at the source code feel free to take a look, fork, contribute.
I will be adding a persistence layer (most likely using daybreak) that will provide and interface to update previously posted incidents via the