Archive for the ‘Monitoring & Alerting’ Category

How to make AppDynamics work with OpsGenie


22 Jun

App Dynamics doesn’t directly support Ops Genie, and Ops Genie does not have a direct integration with App Dynamics. I found a post about adding a custom module to a dedicated App Dynamics controller that would work but most people don’t get a dedicated App Dynamics controller, it’s expensive and designed for large customers only.

So I was working on a shared multi-tenant SaaS app dynamics setup/account and I learned they support REST requests. OpsGenie also supports RESTful HTTP API calls. So we just need to make AppDynamics push HTTP REST requests to OpsGenie’s API. I couldn’t find any documentation/guides online on how to do this so I’m posting it here real quick.

Open up https://www.opsgenie.com/docs/web-api/alert-api#createAlertRequest (use this for reference)

  1. Login to OpsGenie
  2. Click on “Integrations” on the left and then click on “Add New Integration”
  3. Add an API integration and copy the API Key
  4. Name it something like “AppDynamics REST”
  5.  Click on Save Integration

Ok time to do the AppDynamics side

  1. Login to the AppDynamics
  2. Click on “Alert & Respond” at the top
  3. Click on “HTTP Request Templates”
  4. Click on +New
  5. Name could be something like “OpsGenie Create Alert”
  6. While not required, I recommend adding a Custom Templating Variable and calling it “apiKey” and then putting your API key you got from OpsGenie in there (it’s best to make the key a variable, easier to change in the future rather than hard coding it)
  7. Authentication should be NONE
  8. You can leave the “Custom Request Headers” section blank/alone
  9. Payload, change MIME Type to “application/json” and Payload Encoding can remain UTF-8
  10. Now comes the actual body of the message, as an example you can put in
{
"apiKey": "${apiKey}",
"source": "APPDYNAMICS",
"alias": "${latestEvent.id}",
"message": "${latestEvent.severity} - ${latestEvent.application.name} on ${latestEvent.node.name}",
"description": "${latestEvent.displayName} - AppDynamics has detected a ${latestEvent.severity} level alert with the ${latestEvent.application.name} application on the ${latestEvent.node.name} server. Please look into this.",
"note": "Please view the AppDynamics event that triggered this from: ${latestEvent.deepLink} for more details."
}

Just put that in the box.

11. In “Response Handling Criteria” for “Success Criteria” set status code to “200” and check “Expect Payload” and set Content Type to “application/json” (This tells AppDynamics that OpsGenie will respond with a 200 OK HTTP message and the format will be in json.
12. Click on “One Request Per Event”
13. Click on Save

 

So the main trick is the body of the message. Let’s go over it.

apiKey will be replaced with the apiKey variable you filled in at the top.

source can be anything, for my example I put in APPDYNAMICS.

alias is optional, if you don’t specify it OpsGenie will make up a random alias (which doubles as the Alert ID) but I figured it’s nice to make the OpsGenie Alert ID/Alias line up with the AppDynamics Event ID.

message Think of this like a subject. This is what will be in the actual alert, the alert that gets SMS/TXT messaged to the on-call’s phone, or the alert that gets read to the on-call over the phone. It’s limited to 140 characters.

description I treat this like the body of an email. This is where I can put in more details, you have a lot more room to work with. When the on-call person gets notified, they’ll see message but they’ll be given a link they can click on and that’ll bring them to the OpsGenie alert and that’ll show them the description.

note is equivalent to a comment. When it creates the alert in OpsGenie, message and description show up in the alert but then you can comment on the alert, so this will create the alert and immediately add a comment to it. The person checking the alert will also see this comment/note at the bottom in addition to what they see in the description.

You can play around with the variables and how things are formatted. Use that link I referenced (https://www.opsgenie.com/docs/web-api/alert-api#createAlertRequest) for examples of variables you can use.

Deon's Playground

Placing whatever interests me and more