Like many other people, I’ve been working at home throughout 2020 and 2021. Many customers I work with use Microsoft Teams to collaborate, send messages, and do video calls. But did you know that you can also send alerts from New Relic One directly to channels in Microsoft Teams? When issues come up, you can easily alert teams where they are already working and collaborating. This post shows you how to send alerts to Microsoft Teams, and it only takes about five minutes to set up.
Adding an incoming webhook to Microsoft Teams
To send notifications from New Relic One to Microsoft Teams, you need to add an incoming webhook to the channel where you want the notifications to go. To do so, follow these steps, which are also included in the Microsoft Teams’ documentation on creating an incoming webhook.
- In Microsoft Teams, navigate to the channel of your choice and select (...) More Options from the top navigation menu.
- Choose Connectors from the menu and search for Incoming Webhook.
- Select the Configure button, provide a name for the webhook, and, optionally, upload an image avatar like the New Relic logo for your webhook.
- Copy and save the webhook URL that Microsoft Teams generates for you. You'll need to add this URL to New Relic One later in this tutorial.
Once you have a webhook URL, you are ready to configure the notification channel in New Relic One.
Setting up a notification channel in New Relic One
Log in to New Relic One and navigate to Alerts & AI > Notification Channels as shown in the next image.
- Choose New notification channel from the top right of the page.
- Next, select Webhook from the Select a channel type dropdown menu.
- Name your channel in Channel name. This name will appear in the New Relic UI. It doesn’t need to match the channel name in Microsoft Teams.
- In the Base Url field, paste the webhook URL you copied from Microsoft Teams’ Incoming Webhook screen.
- Next, choose Use Custom Payload and choose JSON as the Payload Type.
- In the Payload field, copy the JSON below. Microsoft Teams has a bespoke JSON schema for sending interactive cards that will appear in your channel.
{
"summary":"$ACCOUNT_NAME New Relic Alert: $CONDITION_NAME in New Relic Alert - $POLICY_NAME",
"themeColor":"0076D7",
"@type":"MessageCard",
"potentialAction":[
{
"@type":"openUri",
"name":"Go To Incident",
"targets":[
{
"os":"default",
"uri":"$INCIDENT_URL"
}
]
},
{
"@type":"openUri",
"name":"Go To Policy",
"targets":[
{
"os":"default",
"uri":"$POLICY_URL"
}
]
}
],
"@context":"http://schema.org/extensions",
"sections":[
{
"activitySubtitle":"$SEVERITY violation $EVENT_STATE at $TIMESTAMP_UTC_STRING",
"activityTitle":"New Relic Alert: $POLICY_NAME - $CONDITION_NAME"
},
{
"images":[
{
"image":"$VIOLATION_CHART_URL"
}
]
},
{
"markdown":true,
"facts":[
{
"name":"Assigned to",
"value":"Unassigned"
},
{
"name":"Runbook",
"value":"$RUNBOOK_URL"
},
{
"name":"Open Violations",
"value":"$OPEN_VIOLATIONS_COUNT_CRITICAL critical, $OPEN_VIOLATIONS_COUNT_WARNING warning violations"
},
{
"name":"Status",
"value":"$EVENT_STATE"
}
]
}
]
}
Note that New Relic Webhook notification channels support templating using variables. In this JSON, we use variables in the format $VARIABLE_NAME
for the message template in Microsoft Teams.
Assigning channels to policies
The final step is to add alert policies to your new notification channel. To assign policies to a channel, navigate to Alerts & AI > Policies > Notification channels > Add notification channels as described in the previous link. Choose your new channel, select Alert policies, and then add any alert policies that you’d like to receive alerts for in Microsoft Teams.
Now that you have a new way of alerting your teams, you may want to add more alert policies. Happy alerting!
Next steps
Do a deep dive of the Alerts and Applied Intelligence documentation to learn more about how to proactively add alerts so your teams aren’t caught by surprise when issues come up.
If you’re not already using New Relic, sign up here to get free, forever access to all of New Relic.
The views expressed on this blog are those of the author and do not necessarily reflect the views of New Relic. Any solutions offered by the author are environment-specific and not part of the commercial solutions or support offered by New Relic. Please join us exclusively at the Explorers Hub (discuss.newrelic.com) for questions and support related to this blog post. This blog may contain links to content on third-party sites. By providing such links, New Relic does not adopt, guarantee, approve or endorse the information, views or products available on such sites.