Skip to content

Instantly share code, notes, and snippets.

@Bouhnosaure
Last active March 9, 2022 15:50
Show Gist options
  • Save Bouhnosaure/6b7178c65b5cc0a33ba41cb9c7cddc32 to your computer and use it in GitHub Desktop.
Save Bouhnosaure/6b7178c65b5cc0a33ba41cb9c7cddc32 to your computer and use it in GitHub Desktop.
New Relic template for Discord webhooks

Useful links

Installation

Workflows

  • Create a webhook link on discord (Channel settings > Integrations > Webhooks > Copy URL)
  • Sign in and go the section "Alerts & AI" on New Relic
  • Under "Enrich & Notify" select "Workflows" then click on "Add a workflow" button
  • Give it a name, select Webhooks as notify channel and paste the template located below (workflows.hbs) as the "Payload template"
  • Click on send test notification in order to verify that everything is good (also update the template if needed)
  • Click on "Update message" and "Activate workflow"

Alerts (Classic)

  • Create a webhook link on discord (Channel settings > Integrations > Webhooks > Copy URL)
  • Sign in and go the section "Alerts & AI" on New Relic
  • Under "Alerts (Classic)" select "Channels" then click on "New notification channel" button
  • Select "Slack", give a name, paste the url and append at the end "/slack" like this:

Before https://discord.com/api/webhooks/94****00/Erv****VfC After https://discord.com/api/webhooks/94****00/Erv****VfC/slack

  • Click on send test notification in order to verify that everything is good
  • Save changes and you are good to go

Anomaly detection

  • Create a webhook link on discord (Channel settings > Integrations > Webhooks > Copy URL)
  • Sign in and go the section "Alerts & AI" on New Relic
  • Under "Detect" select "Anomaly detection" then click on "Add a configuration" button
  • Select what you need/want and click on Webhook
  • Paste the template located below (proactive-detection.hbs) as the "Payload template"
  • Click on send test notification in order to verify that everything is good (also update the template if needed)
  • Click on "Save configuration" (if it's disabled, check that you have selected an application or a service)

Demo

image

{
"embeds": [{
"image": {
"url": "{{ viewChartImageUrl }}"
},
"title": "{{ entity.name }} {{ severity }} {{ category }}",
"url": "{{ anomalyzerUrl }}"
}]
}
{
"embeds": [{
"color": {{#eq priority "CRITICAL"}}15548997{{/eq}}{{#eq priority "HIGH"}}15105570{{/eq}}{{#eq priority "MEDIUM"}}16705372{{/eq}}{{#eq priority "LOW"}}1752220{{/eq}},
"title": "{{ annotations.title.[0] }}",
"url": "{{ issuePageUrl }}",
"description": "{{#each annotations.description }}{{this}}{{#unless @last}}, {{/unless}}{{/each}}",
"fields":[
{
"name": "Impacted entities",
"value": "{{#each entitiesData.names }}{{this}}{{#unless @last}}, {{/unless}}{{/each}}",
"inline": true
},
{
"name": "State",
"value": "{{ state }}",
"inline": true
}
],
"footer": {
"text": "Total incidents {{ totalIncidents }}"
}
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment