Blog Post

Microsoft Teams Blog
3 MIN READ

Monitor your applications by configuring New Relic Alerts in Microsoft Teams

Amit Oberoi's avatar
Amit Oberoi
Icon for Microsoft rankMicrosoft
Apr 17, 2019

Microsoft Teams is gaining a lot of traction in DevOps space and has over 65+ DevOps apps in store. We also constantly look for user feedback/how to improve the experience for our dev community. One of the asks from our customers has been the integration of New Relic into Teams. New Relic is one of widely used tools in DevOps space. It allows developers to find and fix problems faster, building high performing DevOps teams.

 

There’s an existing New Relic connector on appsource that you can use to configure New Relic notifications in Teams. This article explains how we can use incoming webhooks and make New Relic notifications actionable.

 

Webhooks are ‘user-defined HTTP callbacks’. They are trigged by some events like drop in response time, higher CPU usage, values (like count, average etc.). Whenever the event occurs, the source site makes an HTTP request to the URL configured for the webhook.

 

Generating Webhook for Teams

Add incoming webhook connector to the Teams channel where you want to receive the New Relic notifications. You can even choose to upload the custom image for your connector. If you choose not to upload the custom image, default incoming webhook image will be shown at notifications. Copy the URL from the webhook, this will be needed when you would configure the notifications in New Relic portal.

 

 

Configuring Webhook on New Relic Portal

From New Relic portal, create a new notification channel using webhooks. Fill in the webhook details at the new relic page. In ‘Base Url’ field, paste the URL copied from Teams incoming webhook configuring page.

 

 

Custom JSON Example

Below is the custom payload example that I used to generate the notification card. You can use your own custom JSON it based on your needs.

{
"summary": "New Relic Alert: Test Condition in New Relic Alert - Test Policy",
"themeColor": "0076D7",
"@type": "MessageCard",
"potentialAction": [
    {
        "@type": "openUri",
	"name": "Go To Incident",
	"targets": [
            {
                "os": "default",
                "uri": "http://..."
            }
        ],
    },
    {
        "@type": "openUri",
	"name": "Go To condition",
	"targets": [
            {
                "os": "default",
                "uri":"https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/connectors/connectors"
            }
        ],
    },
    {
        "@type": "openUri",
	"name": "Application Dashboard",
	"targets": [
            {
                "os": "default",
                "uri": "http://..."
            }
        ],
    },
	{
	"@type": "ActionCard",
	"name": "Add a comment",
	"inputs": [
			{
				"@type": "TextInput",
				"id": "comment",
				"title": "Enter your comment",
				"isMultiline": true
			}
		],
	"actions": [
			{
				"@type": "HttpPOST",
				"name": "OK",
				"target": "http://..."
			}
		]
	},
	
],
"@context": "http://schema.org/extensions",
"sections": [
    {
        "activitySubtitle": "New Relic Alert - Test Policy",
        "activityTitle": "New Relic Alert: Test Condition in New Relic Alert - Test Policy"
    },
    {
        "images": [
            {
                "image":"http://gorgon.nr-assets.net/image/0bade12c-e4f4-4f50-8155-6445741c3e99?config.legend.enabled=false&height=210&width=400"
            }
        ],
    },
    {
        "markdown": true,
        "facts": [
            {
                "name": "Assigned to",
                "value": "Unassigned"
            },
            {
                "name": "Due date",
                "value": "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
            },
            {
                "name": "Status",
                "value": "Not started"
            }
        ]
    }
]
}

Once the channel is created, you can setup Alert policies, Conditions etc. based on which you’ll start getting the notifications in the Teams channel that you configured in the portal.


Here’s the sample of New Relic notification generated based on above JSON

 

Updated Jan 26, 2021
Version 2.0