Integrating VictorOps with Salesforce Using its REST Endpoint

Share this article

This article was sponsored by VictorOps. Thank you for supporting the sponsors who make SitePoint possible!

When you have a live application with real users, problems don’t show up according to your schedule. You need a way to manage and resolve issues that come up all of a sudden, and this process needs to be as simple and painless as possible. This is where VictorOps comes in. It allows you to manage who is responsible for fixing live problems, enables communication among the team when these issues arise, and integrates with the rest of your systems to make detecting problems a piece of cake.

In this article, we’ll cover how you can use VictorOps as a REST endpoint to integrate it with other services. In particular, we’ll focus on SalesForce integration. To make this integration, you’ll need a VictorOps account.

Integration and the REST Endpoint

First of all, what do we mean when we say that VictorOps gives you a “REST endpoint”? The idea is that VictorOps allows you to access resources using a RESTful API over HTTP. What’s the point, you ask? Well, it is usually very easy to make HTTP requests, and we can use the REST endpoint to quickly set up integrations with other services. For example, a lot of companies use Nagios to monitor services within a deployment. We can integrate VictorOps with Nagios using a plugin, which simply takes alerts and pushes them over to VictorOps’s REST endpoint. The breadth of services you can integrate using the REST endpoint is incredible; as long as you have a little code that can fire off some HTTP requests to ‘alert.victorops.com’, you can make the integration happen.

Let’s take a look at how to set up one of these integrations. A lot of teams use Salesforce as a communications medium. We want people who use Salesforce (which generally includes people on the non-technical side of things) to be able to communicate with the people working with their company’s servers. So, when cases are created in Salesforce, we should get alerts through VictorOps. This allows you to have one place (VictorOps) where you can see IT problems arise throughout your infrastructure. Let’s see how to set up that integration.

Salesforce Integration

Salesforce has a way to hook in little bits of code that decide what to do when specific things called “triggers” happen. These little bits of code are written in a language called “Apex” (which is more or less specific to Salesforce) that is meant to have a syntax very similar to Java. Fortunately, you don’t have to spend any of your time learning how to write Apex in order to get Salesforce integration to work since the kind folks at VictorOps have a repository that contains the required code snippets.

For security reasons, we need to tell Salesforce that our code is going to be making requests to the VictorOps REST endpoint. To do that, we’ll have to add “http://alert.victorops.com/” as a remote site by going through ‘Security Controls => Remote Site Settings => New Remote Site’ in the Salesforce dashboard. After you do that, you should see this on the ‘All Remote Sites’ page:

All Remote Sites page in Salesforce

Before we can get the Apex code talking with VictorOps, we need to put in our API and route keys from VictorOps into the Apex code. Get yourself of a copy of the code first from this repository. Then, we need the right keys from VictorOps. From the VictorOps dashboard, we go to ‘Settings => Integrations REST Endpoint’. After enabling the integration, you’ll see a URL like this:

API Key URL in VictorOps

The part of the URL in red is your “API key”. Now, we’ll create a routing key. Your routing key allows you to route certain alerts to certain groups of people within your VictorOps organization. To set one up, again head over to ‘Settings’ in the VictorOps dashboard, click on ‘Integrations’ and down to ‘Incident Routing’. Add a rule with a routing key (e.g. “salesforce_integration”). At this point, you’ll probably be routing that routing key to ‘everyone’:

Routing Key in VictorOps

Now, in the Apex code, you should find a file named “VictorOpsTimeLine Apex Class”, with a bit of text in it that looks like this:

http://alert.victorops.com/integrations/generic/20131114/alert/$YOUR_API_KEY_HERE/$ROUTING_KEY_HERE

Edit it to add your API and routing keys.

Next up, we’ll add in the Apex code into Salesforce. Head over to ‘Setup => Apex Classes’ in Salesforce and then simply upload the files in this repository that end in ‘Class’. For example, whereas ‘VO Alert Test Class’ goes in the classes. You should end up with:

Salesforce Apex Classes List

We also need to set up the triggers. To do that, head over to the Developer Console via ‘Setup => Apex Classes => Developer Console’. Click on ‘File => New => Apex Trigger’. The name should correspond to the file name of the trigger (there are two of them) and the sObject should be “Case” (since we want this trigger to fire when cases are created or resolved).

Salesforce Developer Console

Then, just paste in the trigger code and save.

In order to finally deploy this code to a production environment (as opposed to the developer sandbox you’ve been working in so far) you’ll need to deploy a changeset from the sandbox to the production organization.

To test out the integration, you can create a new case in Salesforce and you should see it show up as an alert inside VictorOps like this:

Case Result in VictorOps

Other Integrations

We’ve outlined the Salesforce integration using the REST endpoint, but the procedures for integrating other platforms are remarkably similar because VictorOps can communicate with many different platforms via the REST endpoint. For example, Sensu is a nice way to monitor your system based on a set of checks, and you can use the REST endpoint in order to make its alerts show up on VictorOps so you can deal with them in a coordinated fashion.

In fact, rolling your own integration is fairly easy since VictorOps has very good documentation on how you can get alerts into the system. With an API, a simple HTTP library and a couple of hours, you can get information from nearly any service into the alerts on your VictorOps dashboard.

By providing such easy integration, VictorOps lets you deal with complex problems in a much more efficient and timely manner because you don’t have to check a million sources of information to figure out where and when the problems show up.

Further Viewing and Reading

That brings us to the end of this tutorial, but if you have any other clever ideas for VictorOps integrations, feel free to suggest them in the comments. For more on the topic, here’s a list of useful resources you can check out:

Frequently Asked Questions (FAQs) about Integrating VictorOps with Salesforce using REST Endpoint

What is the purpose of integrating VictorOps with Salesforce using REST Endpoint?

The integration of VictorOps with Salesforce using REST Endpoint is designed to streamline the process of incident management. It allows for real-time alerts and notifications to be sent directly from Salesforce to VictorOps, ensuring that any issues are promptly addressed. This integration can significantly improve the efficiency of your incident management process, reducing downtime and improving customer satisfaction.

How do I set up the integration between VictorOps and Salesforce?

Setting up the integration involves creating a REST Endpoint in VictorOps, and then configuring Salesforce to send alerts to this endpoint. Detailed instructions for this process can be found in the article.

What information can be sent from Salesforce to VictorOps?

Salesforce can send a wide range of information to VictorOps, including incident details, customer information, and any other relevant data. This information can then be used by VictorOps to generate alerts and notifications.

Can I customize the alerts that are sent from Salesforce to VictorOps?

Yes, the alerts can be customized to include any relevant information. This can be done by modifying the payload that is sent from Salesforce to VictorOps.

What are the benefits of using REST Endpoint for this integration?

REST Endpoint allows for real-time communication between Salesforce and VictorOps. This means that alerts can be sent immediately, ensuring that any issues are promptly addressed.

Is there any specific format for the payload that is sent from Salesforce to VictorOps?

Yes, the payload must be in JSON format. This is a common format for data interchange and is widely supported by many platforms.

Can I test the integration before deploying it?

Yes, it is recommended to test the integration before deploying it. This can be done by sending a test alert from Salesforce to VictorOps.

What happens if the integration fails or encounters an error?

If the integration fails or encounters an error, an error message will be sent to VictorOps. This message will contain details about the error, allowing for quick troubleshooting and resolution.

Can I integrate multiple Salesforce instances with VictorOps?

Yes, you can integrate multiple Salesforce instances with VictorOps. Each instance will require its own REST Endpoint in VictorOps.

Is there any limit to the number of alerts that can be sent from Salesforce to VictorOps?

There is no specific limit to the number of alerts that can be sent. However, it is recommended to monitor the volume of alerts to ensure that they are manageable and do not overwhelm the VictorOps system.

Dhaivat PandyaDhaivat Pandya
View Author

I'm a developer, math enthusiast and student.

apirest apisponsored
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week