This article is sponsored by VictorOps. Thank you for supporting the sponsors who make SitePoint possible!
Developers often use email as their primary mode of communication. Be it downtime alerts, 500 errors or repository commits — all of them are redirected to your email account so that everything can be found in a single place.
But email isn’t really suited to this kind of task. Email makes real-time communication difficult, and conversations can easily become unwieldy, with long delays and a lack of immediacy, particularly when you’re communicating with people in different timezones.
Chat, on the other hand, offers a more immediate way to resolve an issue. You can see who is online at a particular moment, you can share information with multiple people to receive feedback quickly, and you can even perform actions from right within the chat client, via integrations with services like GitHub’s Hubot.
We’ve come a long way from the days of Yahoo, AOL and Microsoft Messenger. Chat is no longer just a text-based interaction between two people — it’s developed into something more, something productive.
This article will cover the emerging trend of ChatOps, outlining some popular uses of chat in a devops setting, and then explain how you can take your ChatOps further with advanced integrations with VictorOps.
Popularized by GitHub, ChatOps is putting tools in the middle of the conversation. With development teams often distributed globally, there is a need for a centralized communication system which also automates certain processes like continuous deployment. GitHub started the trend with their bot, Hubot.
There are many popular chat applications in use in the tech industry. I recently wrote about using Slack for workplace collaboration, but HipChat is also popular. Most of the best chat clients offer direct messaging, multiple channels for different subjects or areas, and advanced file-sharing and integration abilities.
These apps are capable of making a world of difference to the development cycle. There are different chat-based tools and commands for different tasks, such as starting new instances of virtual machines, sending newsletters or deploying code to your main server. Traditionally, each of these tasks would involve working on different tools but with programmable chat bots these tasks can be performed by simple commands run on the chat application.
Imagine connecting with Amazon Web Services to spring up instances with just a single chat command, or deploying your latest commit to the server with the help of GitHub integrations. Or how about checking how many visitors your website has through an analytics system? Perhaps you’re just happy checking your team’s progress through Trello or Asana within your chat application of choice?
ChatOps can increase the efficiency of your team, saving time that would otherwise be wasted on redundant processes.
A standard chat app is certainly useful in improving developer communications. But when it comes to helping developer teams manage incidents, an integration with an on-call alert and management platform like VictorOps is even better.
VictorOps and the joys of being ‘on-call’
The concept of being on-call is borrowed from the medical field. Doctors and nurses need to be available at all hours to manage emergencies, so they will often follow a roster to make sure someone is always on-deck. Similarly in the devops world, an error or downtime to your site or service might occur when you are asleep, especially with services with users in different timezones. Up until now, you probably had a team member assigned to handle such errors, and they’d receive alerts via email when something went wrong.
VictorOps aims to make this process a bit more elegant, by providing a centralized system to fix live problems, communicate with team-members and then learn from what went wrong once the crisis has passed.
Let’s look at how VictorOps handles crisis management and sends outgoing notifications and incoming alerts, before we move on to talk about how to integrate the service with an existing chat application, HipChat.
Error Reporting in VictorOps
If you’ve assigned someone to be on-call for a particular site or app in VictorOps, incidents will also show up on the VictorOps timeline like this:
An email is also sent to the concerned party.
If you’re not going to be available, a co-worker can take the on-call responsibilities for you. When you’re back on-board, you can take them back. The VictorOps bot Victor, who you’ll be formally introduced to later on, explains that pretty well when you are given the tour for the first time.
If you’re not satisfied with just an email being sent to someone when an incident is created, don’t be disappointed. VictorOps supports webhooks, which let you perform a custom action through a callback from VictorOps.
Outgoing notifications — Webhooks
You may be accustomed with webhooks, especially if you’re familiar with continuous integration. With webhooks, you can specify a callback from the VictorOps application when an incident is reported to a different application. This callback can be used to perform a variety of functions — start or stop a process on a server, send out a bunch of emails, put up a status page, or anything else that comes to your mind.
POST request is sent from VictorOps to your application, containing an incident, the summary and a message. It’s identified and authenticated by an HTTP header
For instance, if you’re running an application written in core PHP and a MySQL error occurs, the error trace might be displayed on a webpage. You could avoid this by using a webhook, which temporarily shows an error page while you fix the problem.
For more on using webhooks, head over to the documentation, which lists the steps of generation and authentication in detail.
Incoming alerts — REST endpoints
Now you know how webhooks work, what if you wanted to reverse the information flow and tell VictorOps about something? This is where REST endpoints come into the picture.
VictorOps accepts alerts from any source through an
HTTPS request. You can generate alerts using these requests.
Here’s more on the REST endpoints and a guide to setting up the VictorOps integration.
Integrating HipChat with VictorOps
Now you have a bit of a handle on some of the things VictorOps can do out of the box, let’s look at how to integrate it into your existing chat app.
VictorOps currently provides an easy integration with HipChat, although Slack integration is also coming soon. This integration ties your VictorOps timeline to a particular chat room on HipChat. Anything posted on HipChat is immediately transferred to VictorOps, and vice versa.
To set up the HipChat integration, you’ll only need to follow a few simple steps.
- In your VictorOps integration, enable the HipChat integration to generate a unique URL. You may select the types of messages to be sent and how they should be displayed under the preferences
- In your HipChat settings, select the chat room to integrate and add the generated URL as a new private integration.
It’s really that easy. Once you are done with it, messages on HipChat are transferred to VictorOps and vice versa. You can manage a VictorOps timeline from your favorite chat app, bringing the functionality of both together. For a detailed tutorial with screenshots on the integration, check out the VictorOps documentation.
Let’s test it out. Here’s me posting a message on HipChat.
Move over to VictorOps to see the effect.
Let’s try the opposite, I’ll post a message to the VictorOps timeline.
And there it is on HipChat.
You’ll never miss a thing, no matter which app you have open!
Although VictorOps provides a chat bot,
@victor, who’s pretty friendly and helps you set things up for the first time, you might want to bring across GitHub’s own Hubot to the VictorOps timeline, for some advanced functionality and a bit of fun.
To do so, you need to follow instructions to set up Hubot, followed by the integration of VictorOps into Hubot. Roughly, you’ll need to go through the following steps (assuming you already have NodeJS installed).
Install the Hubot generator from GitHub.
npm install -g yo generator-hubot
Install hubot in its own directory on your server.
Add the VictorOps adapter to Hubot’s dependencies by editing the file
package.json and run
Get the VictorOps Key from your VictorOps dashboard under integrations (
Run Hubot using the VictorOps adapter with the key.
HUBOT_VICTOROPS_KEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx bin/hubot --adapter victorops
Once it’s up and running, you can use it in your timeline! For production, consider storing the
HUBOT_VICTOROPS_KEY as an environment variable. If you need custom functionality, you can create your scripts in CoffeeScript under the
scripts directory. A basic example is provided by default for your reference.
You can start with the basic
help command to help you see a list, which you can use to try out a few different things. Including some slightly less-productive activities!
ChatOps offers a wealth of benefits over traditional communications methods. We’ve given you a basic overview of the concept, advice on bringing it across to your own organization, and a guide to taking it further with on-call alert and management platform VictorOps and Hubot, the advanced (and occasionally mischievous!) chat bot.
If you want more information about ChatOps, VictorOps will be hosting a live “ChatOps Unplugged” webinar, where they’ll give an intro to ChatOps, explain the benefits of ChatOps, specific examples on what can be done, the tools that you can use to accomplish them (including Hubot), and how to get started.