• /
  • EnglishEspañolFrançais日本語한국어Português
  • Se connecterDémarrer

Alert RCA with Autopilot and Slack

When an alert fires, trigger Autopilot to run a root cause analysis and post the findings directly to a Slack channel. If Autopilot returns no usable response, the workflow sends an error notice instead so the team knows to investigate manually.

Before using this workflow, ensure you have:

  • A New Relic alert issue ID in UUID format
  • A Slack destination configured in New Relic — see Create destinations
  • The destination's UUID and the target Slack channel name

This workflow completes the following steps:

  1. Sends an initial Slack message to acknowledge the alert and let the team know RCA is underway
  2. Runs Autopilot with a root cause analysis prompt scoped to the alert issue ID
  3. Checks whether Autopilot returned a usable response
  4. On success: Reformats the response as Slack Block Kit blocks and posts findings to Slack if Autopilot succeeds.
  5. On failure: Posts an error message with the issue ID if Autopilot fails.

This workflow uses newrelic.autopilot.run and newrelic.notification.sendSlack

name: autopilotSlackRCA
description: Automatically analyze New Relic alerts with Autopilot and send cleanly formatted findings to Slack
workflowInputs:
issueId:
type: String
required: true
validations:
- errorMessage: Must be a valid New Relic issue ID in UUID format
pattern: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
type: regex
slackDestinationId:
type: String
required: true
validations:
- pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
errorMessage: "Invalid format. Please provide a valid UUID."
type: regex
channel:
type: String
required: true
steps:
- name: notifyAlertReceived
type: action
action: newrelic.notification.sendSlack
version: 1
inputs:
destinationId: ${{ .workflowInputs.slackDestinationId }}
channel: ${{ .workflowInputs.channel }}
text: |-
🔔 *Alert Received — Starting Root Cause Analysis*
⏳ Running Autopilot for RCA, please wait...
- name: runAutopilot
type: action
action: newrelic.autopilot.run
version: 1
inputs:
prompt: >-
Perform a root cause analysis for the following New Relic alert:
Issue ID: ${{ .workflowInputs.issueId }}
Provide your comprehensive analysis including Summary, Root Cause, and Remediation Actions.
selectors:
- name: agentResponse
expression: .response.finalAnswer
ignoreErrors: true
- name: checkAgentResponse
type: switch
switch:
- condition: ${{ (.steps.runAutopilot.outputs.agentResponse // "") != "" }}
next: buildSlackBlocks
next: sendAutopilotError
- name: buildSlackBlocks
type: assign
inputs:
blocks: '${{ (.steps.runAutopilot.outputs.agentResponse // "") as $r | (if ($r|type)=="string" then ($r | try fromjson catch null) else $r end) as $json | (if ($json|type)=="array" then ($json[0].text // ($json | tostring)) elif ($json|type)=="object" and ($json.card.body|type)=="array" then [ $json.card.body[] | if .type=="Text" then (.value // "") else "" end ] | join("\n\n") elif ($json|type)=="object" and ($json.text|type)=="string" then $json.text else ($r | tostring) end) | gsub("\\*\\*"; "*") | gsub("### "; "*") | gsub("## "; "*") as $text | ([ $text / "\n" ]) as $lines | [ { "type": "header", "text": { "type": "plain_text", "text": "✅ Autopilot RCA Complete" } }, { "type": "divider" } ] + [ $lines[][] | select(. != "") | { "type": "section", "text": { "type": "mrkdwn", "text": . } } ] }}'
next: sendRcaFindings
- name: sendRcaFindings
type: action
action: newrelic.notification.sendSlack
version: 1
inputs:
destinationId: ${{ .workflowInputs.slackDestinationId }}
channel: ${{ .workflowInputs.channel }}
blocks: ${{ .steps.buildSlackBlocks.outputs.blocks }}
next: end
- name: sendAutopilotError
type: action
action: newrelic.notification.sendSlack
version: 1
inputs:
destinationId: ${{ .workflowInputs.slackDestinationId }}
channel: ${{ .workflowInputs.channel }}
text: |-
🟥 *Autopilot RCA Failed*
Could not extract findings from Autopilot response for issue: ${{ .workflowInputs.issueId }}
Please investigate manually.
next: end

Autopilot overview

Learn how Autopilot investigates alerts and incidents

Conditional logic

Use switch statements to branch on success or failure

Send Slack notifications

Full reference for the sendSlack action

Create destinations

Configure the Slack destination required by this workflow

Droits d'auteur © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.