# AppDynamics

[<mark style="color:blue;">AppDynamics</mark>](https://www.appdynamics.com/) develops application performance management solutions that deliver problem resolution for highly distributed applications.

Route detailed alerts from AppDynamics to the right users in Squadcast.

### Using AppDynamics as an Alert Source

1. Navigate to **Services** -> **Service Overview** -> select or search for your Service. Expand the accordion -> In the Alert Sources section, click **Add**.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-4fbd74e7ca0b30173c47a1d58ed6a0804a0465aa%2FAlert_Sources.png?alt=media&#x26;token=aaca6610-9d18-4dd4-9cf5-320042f326f1" alt="Integration of AppDynamics as an alert source in squadcast"><figcaption></figcaption></figure>

2\. Select **AppDynamics**. Copy the displayed **Webhook URL** to [configure](#create-a-http-request-template-in-appdynamics) it within **AppDynamics.** Finish by clicking **Add Alert Source** -> **Done**.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-e72c3bd82bca400c4281d077b04a800003925a56%2FAppDynamics.png?alt=media&#x26;token=7ef3ce93-6f30-4cf7-8629-a0d8d06916cf" alt="Webhook URL configuration within AppDynamics in Squadcast"><figcaption></figcaption></figure>

{% hint style="warning" %}
**Important:**

When an alert source turns Active, it’ll show up under Configured Alert Sources, you can either generate a test alert from the integration or wait for a real-time alert to be generated by the Alert Source. An Alert Source is active if there is a recorded incident via that Alert Source for the Service.
{% endhint %}

### Create an HTTP Request Template in AppDynamics

In AppDynamics dashboard, click on Alert & Respond menu, then select HTTP Request Templates and click the New button.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-ce53a022f02cc7fc4a664e056f4df7b1e5dc3eac%2Fappdynamics_2.png?alt=media&#x26;token=d2245909-089b-4d46-9684-f7139914cf6d" alt="creating HHTP request templets in AppDynamics"><figcaption></figcaption></figure>

In the Create HTTP Request Template box, enter an appropriate Name such as Squadcast Integration Template and then add a Custom Templating Variable named <mark style="color:red;">`sc_event_type`</mark> and the default value as <mark style="color:red;">`triggered`</mark>.

In the Request URL section, select the Method as **POST** and paste the URL you have obtained from the previous section into Raw URL and URL Encoding as **UTF-8** and in the Authentication section, select the Type as **NONE**.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-ba311a55abdc59d383a73458c51ef79c30021454%2Fappdynamics_3.png?alt=media&#x26;token=f5a001af-f7e1-40df-8dde-01fa65d07fc1" alt="Creating HTTP request Template using raw URL in AppDynamics"><figcaption></figcaption></figure>

In the Payload section, select the MIME Type as <mark style="color:red;">`application/json`</mark> and Payload Encoding as <mark style="color:red;">`UTF-8`</mark> and in the payload body, paste the below JSON.

```json
{    
   "incident_key": "${latestEvent.node.name} - ${latestEvent.application.name}",
   "event_type": "${sc_event_type}",
   "description": "${latestEvent.displayName} on ${latestEvent.node.name}",
   "client": "AppDynamics",
   "client_url": "${controllerUrl}",
   "details": {
 "event_name": "${latestEvent.displayName}",
 "summary": "${latestEvent.summaryMessage}",
 "event_id": "${latestEvent.id}",
 "guid": "${latestEvent.guid}",
 "event_time": "${latestEvent.eventTime}",
 "event_type": "${latestEvent.eventType}",
 "event_type_key": "${latestEvent.eventTypeKey}",
 "application_name": "${latestEvent.application.name}",
 "node_name": "${latestEvent.node.name}",
 "message": "${latestEvent.eventMessage}",
 "severity": "${latestEvent.severity}"
   },
   "contexts":[
 {
   "type": "image",
   "src": "${latestEvent.severityImage.deepLink}",
   "alt": "${latestEvent.severity}"
 },
 {
   "type": "link",
   "href": "${latestEvent.deepLink}",
   "text": "View this transaction in AppDynamics"
 }
   ]
}
```

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-04cfdf3f7944c9ce19b22a3aa926cb93c3cc2a19%2Fappdynamics_4.png?alt=media&#x26;token=5eba2ab1-f3f2-4252-ba1d-79110ea7e6c5" alt="MIME typs as application/json in the payload section in HTTP request templates"><figcaption></figcaption></figure>

In the Response Handling Criteria section, click on Add Success Criteria button and select the Status Code as 200 and check the Expect Payload checkbox and select the Content Type as `application / json`

In the Settings section, check the One Request Per Event checkbox and click the **Save** button.

### Create Trigger and Resolve Actions in AppDynamics

Go to Actions and then create a New Action, and then in the Create Action box, select Make an HTTP Request radio button and select OK.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-3f340a9aba5ca7f4b25e47ef41369a469b2a29e4%2Fappdynamics_5.png?alt=media&#x26;token=da2d5f09-0c5d-4c6c-a3a4-16a33ea98dd5" alt="Create actions in AppDynamics to trigger and resolve it"><figcaption></figcaption></figure>

In the Create HTTP Action box, enter the name as **Squadcast - Triggered** and select the HTTP Request Template which we have saved earlier as Squadcast Integration Template and click the **Save** button.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-e7d0bb04579cbf33ac1d99f050c14d75d9ea90d6%2Fappdynamics_6.png?alt=media&#x26;token=3c33de6b-7985-4d94-83ae-ae1af9773075" alt="selecting HTTP request template in HTTP action box with the name Squadcast - triggered"><figcaption></figcaption></figure>

Create one more action with name as **Squadcast - Resolved** and select the same HTTP Template and change the value of `sc_event_type` to `resolved` and click on the **Save** button.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-75723b770daa8ac882950744778daad06e9c75d8%2Fappdynamics_7.png?alt=media&#x26;token=1ff216cc-33f5-41ed-b9d5-86f9d9a482f2" alt="Selecting HTTP request template in HTTP action box with the name Squadcast - Resolved"><figcaption></figcaption></figure>

### Assign Actions to Policies

Now you have to setup policies and assign actions to them such that when those alerts are fired, the corresponding action will be initiated.

Ideally assign the Squadcast - Triggered action to all Critical or Warning events which has started and assign the Squadcast - Resolved action to all Critical or Warning events which was cancelled or ended, so that the incidents can be **Auto-Resolved** in Squadcast when those events end.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-b114825b3f27bc1b283f5fb99f0a0b7eb6093ef6%2Fappdynamics_8.png?alt=media&#x26;token=e3529a83-2bed-4ba2-8445-3cc900c87323" alt="setting-up policies and assign triggered and resolved actions"><figcaption></figcaption></figure>

That's it! Now you AppDynamics integration is good to go and incidents will be created and resolved in Squadcast based on your AppDynamics policies.

*Have any questions?* [*Ask the community*](https://community.squadcast.com/view/home)*.*
