이 템플릿은 뉴렐릭 공지에 대해 Autopilot을(를) 실행하고 근본 원인 분석을 Slack 채널에 게시합니다. Autopilot이(가) 사용 가능한 응답을 반환하지 않는 경우, 워크플로우는 대신 오류 알림을 전송합니다. 공통 전제 조건 및 설정 참고 사항은 Autopilot RCA 워크플로우 템플릿을 참조하십시오.
이 워크플로우를 사용하기 전에 다음 사항을 확인하십시오:
- 뉴렐릭에 구성된 Slack 대상 ― 대상 생성참조
- 대상의 UUID 및 타겟 Slack 채널 이름
이 워크플로우는 다음 단계를 완료합니다:
- 공지를 확인하고 팀에 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: 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 블록으로 감쌉니다.
관련 주제
Autopilot RCA 워크플로우 템플릿
모든 Autopilot RCA 템플릿에 대한 공통 전제 조건 및 설정 참고 사항
오토파일럿 개요
Autopilot이 알림 및 인시던트를 조사하는 방법을 알아보십시오.
조건부 논리
성공 또는 실패 시 분기하기 위해 switch 문 사용
Slack 공지 보내기
sendSlack 작업에 대한 전체 참조
목적지를 생성하세요
이 워크플로우에 필요한 Slack 대상을 구성하십시오.
Autopilot 및 이메일을 사용한 공지 RCA
Slack 대신 이메일로 RCA 결과를 전송하십시오.
흐름 흐름 자동화 문제 해결
일반적인 Autopilot 및 Slack 통합 문제에 대한 해결 방법