공지가 발생하면 Autopilot을(를) 트리거하여 근본 원인 분석을 실행하고 결과를 Slack 채널에 직접 게시하십시오. Autopilot이 사용 가능한 응답을 반환하지 않으면 팀이 수동으로 조사해야 함을 알 수 있도록 워크플로우가 대신 오류 알림을 보냅니다.
이 워크플로우를 사용하기 전에 다음 사항을 확인하십시오:
- UUID 형식의 뉴렐릭 공지 문제 ID
- 뉴렐릭에 구성된 Slack 대상 ― 대상 생성참조
- 대상의 UUID 및 타겟 Slack 채널 이름
팁
Alert Workflows에서 이 워크플로우를 트리거할 때 issueId 입력의 값으로 {{ issueId }}을(를) 사용하십시오. 이 변수는 트리거하는 공지의 이슈 ID를 워크플로우로 자동으로 전달합니다.
이 워크플로우는 다음 단계를 완료합니다:
- 공지를 확인하고 팀에 RCA가 진행 중임을 알리는 초기 Slack 메시지를 보냅니다
- 공지 이슈 ID로 범위가 지정된 근본 원인 분석 프롬프트를 사용하여 Autopilot을(를) 실행합니다
- Autopilot이(가) 사용 가능한 응답을 반환했는지 확인합니다
- Autopilot이(가) 성공하면 응답을 Slack Block Kit 블록으로 다시 포맷하고 결과를 Slack에 게시합니다
- Autopilot이(가) 실패하면 이슈 ID와 함께 오류 메시지를 게시합니다
이 워크플로우는 newrelic.autopilot.run 및 newrelic.notification.sendSlack을(를) 사용합니다.
중요
선택기 expression 값은 한 줄에 작성해야 합니다. 여러 줄 YAML 블록 스칼라(| 또는 |-)는 선택기 표현식에 대해 평가되지 않으며 아무런 출력도 생성하지 않습니다.
팁
Autopilot의 finalAnswer 필드는 프롬프트 컨텍스트에 따라 일반 문자열 또는 JSON 인코딩 객체로 반환될 수 있습니다. 이 워크플로우의 analysisText 선택기는 두 가지 형태를 모두 자동으로 처리합니다.
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: analysisRaw expression: .response.finalAnswer - name: analysisText expression: '(.response.finalAnswer | if type=="string" then fromjson else . end).card.body | map(.value) | join("\n\n")' ignoreErrors: true
- name: checkAgentResponse type: switch switch: - condition: ${{ (.steps.runAutopilot.outputs.analysisRaw // "") != "" }} next: buildSlackBlocks next: sendAutopilotError
- name: buildSlackBlocks type: assign inputs: blocks: '${{ (.steps.runAutopilot.outputs.analysisText // "") | 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작동 원리
runAutopilot 단계는 데이터 추출 계층에서 finalAnswer 형태 가변성을 처리하기 위해 두 개의 선택기를 사용합니다:
analysisRaw은(는) 원시finalAnswer값을 캡처합니다.checkAgentResponse단계에서는 이를 사용하여 Autopilot이(가) 무언가를 반환했는지 확인합니다.analysisText은(는) 값을 정규화합니다 ―finalAnswer이(가) JSON으로 인코딩된 문자열인 경우 먼저 이를 파싱한 다음.card.body에서 텍스트 콘텐츠를 추출합니다.buildSlackBlocks단계는analysisText을(를) 직접 사용하여 포맷팅 로직을 단순하게 유지합니다.
buildSlackBlocks **bold** 및 ###/## 제목 마커를 Slack mrkdwn 형식으로 변환하고, 결과를 줄 바꿈으로 분할하며, 비어 있지 않은 각 줄을 Block Kit section 블록으로 감쌉니다.