エージェントは、ツールの呼び出し、モデル呼び出し、インシデント処理、承認の決定など、すべてのアクションを Application Insights リソースに記録します。 エージェントの実行内容、タイミング、理由を正確に確認するには、Kusto クエリ言語 (KQL) を使用して customEvents テーブルにクエリを実行します。 エージェント ポータルの Monitor>Logs からログに直接アクセスします。
ログを検索する場所
エージェントは、すべてのアクションを Azure Application Insights に自動的に記録します。 エージェントを作成するときは、Application Insights リソースも作成します。
ログにアクセスするには:
- エージェント ポータルで、 Monitor>Logs に移動します。
- このアクションにより、Azure portal でエージェントの Application Insights リソースが開きます。
- KQL を使用して、
customEventsテーブルに対してクエリを実行します。
既定のクエリは traces | where timestamp > ago(1d) です。 エージェント アクションテレメトリを表示するには、このクエリを customEvents に変更します。
イベントの種類
エージェントは、9 種類のカスタム イベントを customEvents テーブルに記録します。 次のクエリは、すべてのイベントの種類とその数を示しています。
customEvents
| summarize Count = count() by name
| sort by Count desc
| イベント名 | キャプチャされる内容 | 一般的なボリューム |
|---|---|---|
AgentResponse |
送信されたチャット応答 | High |
ModelGeneration |
すべての LLM 呼び出し (入力/出力トークン、モデル ID) | High |
AgentToolExecution |
すべてのツール呼び出し (名前、入力、出力) | High |
AgentExecution |
エージェント セッションの開始/終了ライフサイクル | 中程度 |
MetaAgent |
エージェントのルーティングとオーケストレーションの決定 | 中程度 |
AgentHandoff |
クロスエージェントハンドオフ | 中程度 |
IncidentActivitySnapshot |
インシデントのライフサイクル (重大度、状態、軽減策の結果) | 低 |
AgentAzCliExecution |
エージェントによって実行される Azure CLI コマンド | 低 |
ApprovalDecision |
提案されたアクションの承認または拒否 | 低 |
主要なイベントとそのフィールド
次のセクションでは、最も一般的にクエリされるイベントの種類とそのフィールドについて説明します。
ツールの実行 (AgentToolExecution)
システムは、エージェントがツールを呼び出すたびにこのイベントをログに記録します。
| フィールド | 説明 | 値の例 |
|---|---|---|
EventType |
ToolStart または ToolEnd |
ToolStart |
ToolName |
ツールの名前 | SearchResource |
ToolInput |
ツールに渡される引数 | {"resourceTypes": ["microsoft.resources/subscriptions"]} |
ToolOutput |
ツールによって返される結果 ( ToolEnd イベントの場合) |
(ツール出力 JSON) |
SubAgentName |
ツールを呼び出したエージェントの名前 | meta_agent |
CallId |
ペアリングの関連付け ID | call_aaaabbbb-0000-cccc-... |
customEvents
| where name == "AgentToolExecution"
| where customDimensions.EventType == "ToolStart"
| where timestamp > ago(7d)
| project timestamp,
Tool = tostring(customDimensions.ToolName),
Input = tostring(customDimensions.ToolInput)
| sort by timestamp desc
インシデント ライフサイクル (IncidentActivitySnapshot)
エージェントが処理するすべてのインシデントについて、このイベントをログに記録します。 作成から解決までの完全なライフサイクルをキャプチャします。
| フィールド | 説明 | 値の例 |
|---|---|---|
IncidentId |
プラットフォーム インシデント ID | Q2VVG0T8K7AL0J |
IncidentTitle |
インシデントの説明 | DailyIssueTriager blocked: cannot access repo |
IncidentSeverity |
プラットフォームからの重大度 | Not set |
IncidentStatus |
現在の状態 | active |
IncidentPlatform |
ソース プラットフォーム | PagerDuty |
IncidentMitigatedByAgent |
エージェントが解決したかどうか |
True または False |
IncidentAssistedByAgent |
エージェントが調査に役立ったかどうか |
True または False |
AgentAutonomyLevel |
エージェントが処理した方法 |
autonomous または review |
ResponsePlanId |
使用された応答計画 | PDtrigger |
ResponsePlanCustom |
既定またはカスタムプラン |
True または False |
IncidentImpactedService |
影響を受けるサービス | SRE Agent |
IncidentCreatedOn |
インシデントが作成されたとき | ISO 8601 datetime |
IncidentHandledOn |
エージェントが処理を開始したとき | ISO 8601 datetime |
IncidentMitigatedOn |
解決された場合 (軽減された場合) | ISO 8601 datetime |
// Incident outcomes over the last 30 days
customEvents
| where name == "IncidentActivitySnapshot"
| where timestamp > ago(30d)
| project timestamp,
IncidentId = tostring(customDimensions.IncidentId),
Title = tostring(customDimensions.IncidentTitle),
Platform = tostring(customDimensions.IncidentPlatform),
MitigatedByAgent = tostring(customDimensions.IncidentMitigatedByAgent),
AssistedByAgent = tostring(customDimensions.IncidentAssistedByAgent),
Autonomy = tostring(customDimensions.AgentAutonomyLevel),
ResponsePlan = tostring(customDimensions.ResponsePlanId)
| sort by timestamp desc
モデル生成 (ModelGeneration)
LLM 呼び出しごとにこのイベントをログに記録します。 トークンの使用状況、モデルの選択、および要求エージェントを追跡します。
| フィールド | 説明 | 値の例 |
|---|---|---|
EventType |
ModelGenerationStart、 ModelGenerationEnd、または ModelGenerationError |
ModelGenerationEnd |
AgentName |
LLM 呼び出しを行うエージェント | daily_report_agent |
ModelId |
使用モデル | gpt-4o |
InputTokens |
プロンプトのトークン | 29828 |
OutputTokens |
応答内のトークン | 871 |
ThreadId |
会話スレッド | bb171c1f-3bb2-4895-... |
// Token usage by agent in the last 7 days
customEvents
| where name == "ModelGeneration"
| where customDimensions.EventType == "ModelGenerationEnd"
| where timestamp > ago(7d)
| extend Agent = tostring(customDimensions.AgentName),
InputTokens = toint(customDimensions.InputTokens),
OutputTokens = toint(customDimensions.OutputTokens),
Model = tostring(customDimensions.ModelId)
| summarize TotalInput = sum(InputTokens),
TotalOutput = sum(OutputTokens),
Calls = count()
by Agent, Model
| sort by TotalInput desc
承認の決定 (ApprovalDecision)
提案されたエージェント アクションを承認または拒否するときに、このイベントをログに記録します。
// All approval decisions
customEvents
| where name == "ApprovalDecision"
| where timestamp > ago(30d)
| project timestamp, customDimensions
一般的なクエリ
次の KQL クエリを使用して、エージェントの動作に関する一般的な質問に回答します。
エージェントは特定のスレッドで何をしましたか?
customEvents
| where timestamp > ago(7d)
| where tostring(customDimensions.ThreadId) == "<YOUR_THREAD_ID>"
| project timestamp,
Event = name,
EventType = tostring(customDimensions.EventType),
Tool = tostring(customDimensions.ToolName),
Agent = tostring(customDimensions.SubAgentName)
| sort by timestamp asc
<YOUR_THREAD_ID>を会話のスレッド ID に置き換えます。
最も頻繁に使用するツールはどれですか?
customEvents
| where name == "AgentToolExecution"
| where customDimensions.EventType == "ToolStart"
| where timestamp > ago(30d)
| summarize Count = count() by Tool = tostring(customDimensions.ToolName)
| sort by Count desc
| take 20
エージェントが軽減と支援を行ったインシデントの数はいくつですか?
customEvents
| where name == "IncidentActivitySnapshot"
| where timestamp > ago(30d)
| summarize
Total = count(),
MitigatedByAgent = countif(tostring(customDimensions.IncidentMitigatedByAgent) == "True"),
AssistedByAgent = countif(tostring(customDimensions.IncidentAssistedByAgent) == "True")
毎日のトークン消費量の傾向
customEvents
| where name == "ModelGeneration"
| where customDimensions.EventType == "ModelGenerationEnd"
| where timestamp > ago(30d)
| extend InputTokens = toint(customDimensions.InputTokens),
OutputTokens = toint(customDimensions.OutputTokens)
| summarize TotalTokens = sum(InputTokens) + sum(OutputTokens) by bin(timestamp, 1d)
| render timechart
すべてのイベントの共有フィールド
すべてのカスタム イベントには、関連付けとトレース用の次のフィールドが含まれています。
| フィールド | 説明 |
|---|---|
gen_ai.agent.id |
エージェントの Azure Resource Manager ID |
gen_ai.agent.name |
エージェント名 |
TraceId |
OpenTelemetry トレース ID。1 つの要求間でイベントを関連付けます |
SpanId |
OpenTelemetry スパン ID |
ParentSpanId |
呼び出し階層の親スパン |
ThreadId |
会話スレッドの GUID |
LogTimestamp |
ISO 8601 タイムスタンプ |
CorrelationId |
ログ グループ化の短い関連付け ID |
TraceIdを使用して、エージェントの推論、ツール呼び出し、応答を通じてユーザー入力から 1 つの要求に従います。
[Azure Activity Log (Azure アクティビティ ログ)]
エージェント リソースの作成、更新、削除などの Azure リソース レベルの操作には、Azure アクティビティ ログを使用します。 アクティビティ ログは、エージェント、マネージド ID、および Application Insights リソースに対するすべての Azure Resource Manager 操作をキャプチャします。
エージェントのリソース グループの下にある Azure portal でアクティビティ のサインインにアクセスします。
概要
監査ログは、すべてのエージェントに対して自動的に有効になります。 エージェント ポータルで Monitor>Logs を開き、KQL を使用してアクション履歴を照会します。
| 資源 | 学習する内容 |
|---|---|
| Kusto ツールを作成する | 再利用可能な KQL クエリを作成して監査データをマイニングする |
| アクセス許可 | 監査データのクエリを実行できるユーザーを RBAC が制御する方法 |