• /
  • EnglishEspañolFrançais日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は、参考として提供されています。

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、このページを参照してください。

問題を作成する

AutopilotとEmailを使用した集計RCA

|View as Markdown (English)

このテンプレートは、New Relic集計でAutopilotを実行し、根本原因分析をフォーマットされたHTMLメールとして送信します。Autopilotが使用可能な応答を返さない場合、代わりにワークフローがエラー通知を送信します。共通の前提条件と設定の注意事項については、Autopilot RCAワークフローテンプレートをご覧ください。

このワークフローを使用する前に、以下のことを確認してください:

  • New Relicで設定されたEmailの宛先 — 宛先の作成を参照してください。
  • 宛先のUUID

このワークフローでは、次の手順を完了します:

  1. 集計の課題IDにスコープされた根本原因分析プロンプトを使用して、Autopilotを実行します
  2. Autopilot が使用可能なレスポンスを返したかどうかを確認します
  3. Autopilotが成功した場合、レスポンスをHTMLとしてフォーマットし、Emailの宛先に送信します。
  4. Autopilot が失敗した場合、課題IDを含むエラーメールを送信します。

このワークフローはnewrelic.autopilot.runとnewrelic.notification.sendEmailを使用します。

name: autopilotEmailRCA
description: Automatically analyze New Relic alerts with Autopilot and send a formatted incident analysis report via email
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
emailDestinationId:
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
steps:
- name: runAutopilot
type: action
action: newrelic.autopilot.run
version: 1
inputs:
prompt: >-
Investigate New Relic issue ${{ .workflowInputs.issueId }}.
Produce an incident analysis report covering: what triggered the alert, likely root cause, affected entities, supporting evidence, and recommended next steps.
IMPORTANT: Output your final answer DIRECTLY as clean, basic HTML. Use <h2> for section headers, <b> for bold text, <p> for paragraphs, <code> for logs/IDs, and standard <table>/<tr>/<td> tags with simple borders for tabular data. Do NOT use markdown.
selectors:
- name: agentResponse
expression: .response.finalAnswer
- name: agentResponseBlocks
expression: '(.response.finalAnswer // "") as $r | (if ($r|type)=="string" then ($r | try fromjson catch null) else $r end) as $json | if ($json|type)=="object" and ($json.card.body|type)=="array" then $json.card.body elif ($json|type)=="array" then $json elif ($json|type)=="object" and ($json.text|type)=="string" then [{"type":"Text","value":$json.text}] else [{"type":"Text","value":($r|tostring)}] end'
ignoreErrors: true
- name: checkAutopilotResponse
type: switch
switch:
- condition: ${{ (.steps.runAutopilot.outputs.agentResponse // "") != "" }}
next: sendRcaEmail
next: sendAutopilotError
- name: sendRcaEmail
type: action
action: newrelic.notification.sendEmail
version: 1
inputs:
destinationId: ${{ .workflowInputs.emailDestinationId }}
subject: Autopilot RCA Report - Issue ${{ .workflowInputs.issueId }}
message: '${{ def sanitizeHtml: gsub("(?i)<script\\b[^>]*>[\\s\\S]*?</\\s*script\\s*>"; "") | gsub("(?i)<\\s*script\\b[^>]*/?\\s*>"; "") | gsub("(?i)<style\\b[^>]*>[\\s\\S]*?</\\s*style\\s*>"; "") | gsub("(?i)<\\s*(iframe|object|embed|link|meta|form|svg)\\b[^>]*/?\\s*>"; "") | gsub("(?i)</\\s*(iframe|object|embed|form|svg)\\s*>"; "") | gsub("(?i)\\son\\w+\\s*=\\s*[^\\s>]+"; "") | gsub("(?i)javascript\\s*:"; ""); (.steps.runAutopilot.outputs.agentResponseBlocks // []) as $blocks | [ $blocks[] | if .type == "CodeBlock" then "<pre><code>" + ((.code // "") | gsub("&";"&amp;") | gsub("<";"&lt;") | gsub(">";"&gt;")) + "</code></pre>" else ((.value // "") | gsub("\\*\\*";"") | sanitizeHtml) as $clean | [ $clean / "\n" | .[] | select((. | gsub("^\\s+|\\s+$";"")) != "") ] as $lines | (reduce $lines[] as $line ([]; ($line | test("^\\s*\\|?\\s*:?-+:?\\s*(\\|\\s*:?-+:?\\s*)+\\|?\\s*$")) as $isSep | ($line | contains("|")) as $isPipe | if $isSep then . elif $isPipe then if (length > 0 and .[-1].type == "table") then .[0:-1] + [ .[-1] + {rows: (.[-1].rows + [$line])} ] else . + [ {type:"table", rows: [$line]} ] end else . + [ {type:"line", value: $line} ] end )) as $rawSegments | [ $rawSegments[] | if .type == "table" and (.rows | length) < 2 then {type:"line", value: .rows[0]} else . end ] as $segments | [ $segments[] | if .type == "table" then "<table style=\"width:100%;border-collapse:collapse;font-family:Arial,sans-serif;\">" + ([ .rows | to_entries[] | . as {key: $i, value: $row} | ($row | sub("^\\s*\\|";"") | sub("\\|\\s*$";"")) as $trimmed | [ $trimmed / "|" | .[] | gsub("^\\s+|\\s+$";"") ] as $cells | (if $i == 0 then "th" else "td" end) as $tag | (if $i == 0 then "text-align:left;padding:8px;border-bottom:2px solid #ccc;" else "padding:8px;border-bottom:1px solid #eee;" end) as $style | "<tr>" + ([ $cells[] | "<" + $tag + " style=\"" + $style + "\">" + . + "</" + $tag + ">" ] | join("")) + "</tr>" ] | join("")) + "</table>" else .value as $line | ($line | sub("^\\s+";"")) as $t | if ($t | startswith("<")) then $line elif ($line | startswith("### ")) then "<h3>" + ($line | ltrimstr("### ")) + "</h3>" elif ($line | startswith("## ")) then "<h2>" + ($line | ltrimstr("## ")) + "</h2>" elif ($line | startswith("# ")) then "<h2>" + ($line | ltrimstr("# ")) + "</h2>" elif ($line | startswith("- ")) then "<p>&#8226; " + ($line | ltrimstr("- ")) + "</p>" else "<p>" + $line + "</p>" end end ] | join("\n") end ] | join("\n") }}'
next: end
- name: sendAutopilotError
type: action
action: newrelic.notification.sendEmail
version: 1
inputs:
destinationId: ${{ .workflowInputs.emailDestinationId }}
subject: Autopilot RCA Failed - Issue ${{ .workflowInputs.issueId }}
message: >-
Autopilot could not produce findings for issue ${{ .workflowInputs.issueId }}. Please investigate manually.
next: end

使い方

runAutopilotステップでは、データ抽出レイヤーにおけるfinalAnswerのシェイプのばらつきに対応するために、2つのセレクターを使用します:

  • agentResponseは生のfinalAnswer値をキャプチャします。checkAutopilotResponseステップでは、これを使用してAutopilotが何かを返したかどうかを判断します。
  • agentResponseBlocks は値を型付きブロックオブジェクトの配列に正規化し、3つの可能な finalAnswer の形状(プレーン文字列、.card.body 配列を含むJSONエンコードされたオブジェクト、および単なる配列)を処理します。これにより、Autopilot がレスポンスをどのようにフォーマットしたかに関係なく、sendRcaEmail ステップに反復処理するための一貫した構造が提供されます。

sendRcaEmail ブロックをインラインで処理します:

  • CodeBlock アイテムは、HTMLエンティティがエスケープされた状態で<pre><code>としてレンダリングされます。
  • その他のブロックはsanitizeHtmlを通過し、<script>、<style>、インラインイベントハンドラー、およびその他の安全でない可能性のあるマークアップが削除されます。
  • Markdownスタイルのパイプテーブルが検出され、基本的なインラインスタイルを持つ<table>要素に変換されます。
  • 見出しのプレフィックス(# 、## 、### )および箇条書きマーカー(- )は、対応するHTMLタグに変換されます。
  • 残りのすべての行は<p>タグでラップされます。

AutopilotとSlackを使用した集計RCAテンプレートとは異なり、HTMLフォーマットは完全にsendRcaEmailステップ内で処理されます — 個別のassignステップは必要ありません。

Autopilot RCAワークフローテンプレート

すべてのAutopilot RCAテンプレートに共通の前提条件と設定に関する注意事項

Autopilotの概要

Autopilotがアラートとインシデントを調査する方法について学習します

コンディショナル・ロジック

switch文を使用して、成功または失敗に応じて分岐します。

メール通知の送信

sendEmailアクションの完全なリファレンス

目的地を作成する

このワークフローに必要なEメールの宛先を設定してください。

AutopilotとSlackを使用した集計RCA

メールの代わりにRCAの調査結果をSlackに投稿

ワークフロー自動化のトラブルシューティング

Autopilotとワークフローのインテグレーションに関するよくある問題の解決策

Copyright © 2026 New Relic株式会社。

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