공지가 발생하면 Autopilot을 트리거하여 근본 원인 분석을 실행하고 결과를 Slack 채널에 직접 게시하십시오. Autopilot이 사용 가능한 응답을 반환하지 않으면 워크플로우가 대신 오류 알림을 보내 팀이 수동으로 조사해야 함을 알 수 있도록 합니다.
이 워크플로우를 사용하기 전에 다음 사항을 확인하십시오:
- UUID 형식의 뉴렐릭 공지 문제 ID
- 뉴렐릭에 구성된 Slack 대상 ― 대상 생성참조
- 대상의 UUID 및 타겟 Slack 채널 이름
팁
공지 워크플로우에서 이 워크플로우를 트리거할 때 issueId 입력 값으로 {{ issueId }}을(를) 사용하십시오. 이 변수는 트리거하는 공지의 이슈 ID를 워크플로우로 자동으로 전달합니다.
이 워크플로우는 다음 단계를 완료합니다:
- 공지를 확인하고 팀에 RCA가 진행 중임을 알리는 초기 Slack 메시지를 보냅니다
- 공지 문제 ID로 범위가 지정된 근본 원인 분석 프롬프트와 함께 Autopilot을 실행합니다.
- Autopilot이 사용 가능한 응답을 반환했는지 확인합니다.
- 성공 시: Autopilot이 성공하면 응답을 Slack Block Kit 블록으로 다시 포맷하고 결과를 Slack에 게시합니다.
- 실패 시: Autopilot이 실패하면 문제 ID가 포함된 오류 메시지를 게시합니다.
이 워크플로우는 newrelic.autopilot.run을(를) 사용하며 newrelic.notification.sendSlack
name: autopilotSlackRCAdescription: Automatically analyze New Relic alerts with Autopilot and send cleanly formatted findings to SlackworkflowInputs: 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: truesteps: - 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