Snippet

Audit the GenAI content table for words that should not be there

A complete KQL query that counts content-bearing columns in AppGenAIContent without ever showing the content.

kustoNov 6, 2026MIT

AI-generated, human-reviewed: the first draft was generated by an AI agent; I fact-checked, tested, and edited it. AI use policy

What it does#

Counts rows in AppGenAIContent where a content-bearing column is not empty: input and output messages, system instructions, tool call arguments and results, and evaluation explanations. It returns counts, distinct traces, and up to five sample trace IDs per column, never the values. ToolDefinitions is reported on its own row because tool names and schemas are expected there.

You need#

  • A Log Analytics workspace that receives Application Insights data from your agent
  • Read access to the workspace; this table is not visible from the classic Application Insights query surface

Where it goes#

Run it in the workspace’s Logs page. Change lookback if you are auditing more than a day.

genai-content-audit.kql
// SPDX-License-Identifier: MIT
// Copyright (c) 2026 Sarang Datye
// Counts AppGenAIContent rows whose content-bearing columns are not empty.
// Expect zero rows for every content column. ToolDefinitions holds tool names and schemas,
// so it is reported separately. The output never projects the content values.
let lookback = 24h;
let rows = AppGenAIContent
| where TimeGenerated > ago(lookback);
union
    (rows | where isnotempty(tostring(InputMessages))
     | summarize rows = count(), traces = dcount(TraceId), sampleTraceIds = make_set(TraceId, 5)
     | extend auditedColumn = "InputMessages"),
    (rows | where isnotempty(tostring(OutputMessages))
     | summarize rows = count(), traces = dcount(TraceId), sampleTraceIds = make_set(TraceId, 5)
     | extend auditedColumn = "OutputMessages"),
    (rows | where isnotempty(tostring(SystemInstructions))
     | summarize rows = count(), traces = dcount(TraceId), sampleTraceIds = make_set(TraceId, 5)
     | extend auditedColumn = "SystemInstructions"),
    (rows | where isnotempty(tostring(ToolCallArguments))
     | summarize rows = count(), traces = dcount(TraceId), sampleTraceIds = make_set(TraceId, 5)
     | extend auditedColumn = "ToolCallArguments"),
    (rows | where isnotempty(tostring(ToolCallResult))
     | summarize rows = count(), traces = dcount(TraceId), sampleTraceIds = make_set(TraceId, 5)
     | extend auditedColumn = "ToolCallResult"),
    (rows | where isnotempty(tostring(EvaluationExplanation))
     | summarize rows = count(), traces = dcount(TraceId), sampleTraceIds = make_set(TraceId, 5)
     | extend auditedColumn = "EvaluationExplanation"),
    (rows | where isnotempty(tostring(ToolDefinitions))
     | summarize rows = count(), traces = dcount(TraceId), sampleTraceIds = make_set(TraceId, 5)
     | extend auditedColumn = "ToolDefinitionsAllowed")
| project auditedColumn, rows, traces, sampleTraceIds
| order by auditedColumn asc

Check that it works#

On a clean system you see at most one row, ToolDefinitionsAllowed. Any other row means words reached telemetry; open the sample trace IDs in your own tooling, not in a shared ticket.