↓ Skip to main content
  1. Articles/

Cortex Agents in Microsoft Sentinel: Closing the AI Blind Spot in Your SIEM

Your SOC can see who logged in to Snowflake. It can’t see what their agent asked, which tools it called, or which tables it read. This post closes that gap.

Code: github.com/sfc-gh-kkeller/Sentinel_Cortex (MIT). Snowflake setup SQL, an Azure provisioning script, a traffic generator, the ingestion pipeline, KQL validation queries, and a teardown script.

Personal project. This is an “art of the possible” reference implementation. It isn’t an official Snowflake or Microsoft solution, isn’t supported, and isn’t production-hardened. Review it with your security team before you adapt it.


The blind spot
#

In Keep Shipping I argued that agent projects die on trust, and that anomaly detection and audit are two of the five controls every platform has to provide. Most enterprises already have a place where detection and audit live: their SIEM. For many Snowflake customers in Europe, that’s Microsoft Sentinel.

Sentinel has a native Snowflake solution, “Snowflake (via Codeless Connector Framework)”, in the Content Hub. It polls Snowflake’s SQL API and fills ten custom tables with platform audit data:

Covered by the native connectorNot covered
Logins, queries, user and role grants, loads, roles, tables, table storage, users, materialized viewsAI_OBSERVABILITY_EVENTS (agent traces)
CORTEX_AGENT_USAGE_HISTORY (tokens, credits, model region)
ACCESS_HISTORY (objects and columns each query touched)
Every other Cortex usage view

That’s solid baseline telemetry, but it stops at SQL. When a Cortex Agent answers a question, your SOC sees a query from a user. It doesn’t see that an agent planned the query, which tool it chose, what the user asked, or that the same conversation then read a table of customer records. For agent security, that context is the whole point.

The repo adds a second ingestion path for exactly the data the native connector leaves out.


What Snowflake records about agents
#

Three sources matter for a SOC.

SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS: the agent’s trace. Every conversation turn is recorded as a trace made of spans: planning, tool calls, SQL generation, chart generation, and response generation. It covers Cortex Agents (including Snowflake CoWork), Cortex Search services with REQUEST_LOGGING enabled, and external agents instrumented with TruLens. You read it through table functions such as GET_AI_OBSERVABILITY_EVENTS, which are scoped to one agent and require MONITOR on it.

CORTEX_AGENT_USAGE_HISTORY: the bill. Tokens, credits, model, inference region, role and interface per agent request. It’s useful for cost, but also as a security signal: a sudden spike in one user’s agent usage at 3 AM is worth an alert.

ACCESS_HISTORY: the data. Which objects and columns each SQL statement read or modified. This is the link from “the agent ran a query” to “the agent read CUSTOMERS.EMAIL”. It now also carries an agents_info column, which records which agent issued the query.

Together they answer the questions an incident responder actually asks: who asked what, what did the agent do, what data did it touch, and what did it cost?


Architecture: two paths, one workspace
#

┌──────────────────────────────── Snowflake ────────────────────────────────┐
│                                                                           │
│  Cortex Agent ──► AI_OBSERVABILITY_EVENTS     LOGIN_HISTORY, QUERY_HISTORY│
│       │           CORTEX_AGENT_USAGE_HISTORY  GRANTS, ROLES, USERS, ...   │
│       └─► SQL ──► ACCESS_HISTORY                                          │
└──────────┬────────────────────────────────────────────┬───────────────────┘
           │ custom pipeline                            │ native connector
           │ (Python → Logs Ingestion API)              │ (CCF, SQL API polling)
           ▼                                            ▼
┌────────────────────────── Microsoft Sentinel ─────────────────────────────┐
│  AIObservabilityEvents_CL                     Snowflake…_CL (10 tables)   │
│  CortexAgentUsage_CL                                                      │
│  CortexAccessHistory_CL                                                   │
│                                                                           │
│  Correlate on SESSION_ID · QUERY_ID · REQUEST_ID                          │
└───────────────────────────────────────────────────────────────────────────┘

The native connector keeps doing what it does well. The custom pipeline sends the three AI-relevant sources to the Azure Monitor Logs Ingestion API, through a Data Collection Endpoint and a Data Collection Rule, into three custom tables in the same Log Analytics workspace.

Why the Logs Ingestion API? Microsoft retired the legacy HTTP Data Collector API after 14 September 2026. For a source that no existing solution covers, the supported paths are now the Logs Ingestion API or a custom Codeless Connector Framework connector. The Logs Ingestion API is the quickest of the two to stand up.


Step 1: get the observability grants right in Snowflake
#

Do this first, and do it on a dedicated audit role, not an interactive one.

-- Read the agent's traces
GRANT MONITOR ON AGENT SENTINEL_DEMO_DB.DEMO.DEMO_AGENT TO ROLE SENTINEL_DEMO_AUDIT_ROLE;

-- Read Cortex Search request logs, if the agent uses search
GRANT MONITOR ON CORTEX SEARCH SERVICE SENTINEL_DEMO_DB.DEMO.TICKET_SEARCH
  TO ROLE SENTINEL_DEMO_AUDIT_ROLE;

-- Read ACCOUNT_USAGE (usage history, access history)
GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE SENTINEL_DEMO_AUDIT_ROLE;

-- Needed for the GET_AI_OBSERVABILITY_EVENTS table function
GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE SENTINEL_DEMO_AUDIT_ROLE;

Then there’s one decision that deserves a conversation with your privacy officer, not just a ticket:

GRANT READ UNREDACTED AI OBSERVABILITY EVENTS TABLE ON ACCOUNT
  TO ROLE SENTINEL_DEMO_AUDIT_ROLE;

Without this privilege, the audit role sees metadata only: tool names, latency, model, token counts, error severity. With it, it sees full content: the user’s prompts, tool inputs and outputs, and the agent’s answers. No role has it by default, including PUBLIC.

Full content makes investigations far easier. It also means copying conversation text, which may contain personal or confidential data, into a second system with its own retention, access model and data residency. For many European organisations, metadata in the SIEM plus a controlled path back to the full trace in Snowflake is the better default. Either way, decide on purpose.


Step 2: turn on the native connector
#

In Sentinel: Content Hub → install the Snowflake solution → Data connectors → Snowflake (via Codeless Connector Framework) → Add Account. Provide the account identifier and credentials for a role with SQL API access. The ten tables start filling on the connector’s polling schedule, which runs with a delay of around two hours.

This gives you logins, queries and grants: the backbone you’ll join agent events against.


Step 3: build the AI pipeline
#

The Azure side is one script, azure/01_provision_dcr.sh. It creates the resource group, Log Analytics workspace, Sentinel onboarding, Data Collection Endpoint, the three custom tables with typed columns, the Data Collection Rule, and an app registration for the uploader. It writes the resulting endpoint, rule ID and credentials to a local .env file.

The pipeline itself, scripts/push_to_sentinel.py, is deliberately small. It queries Snowflake, maps rows to the table schema, and uploads them with the Azure SDK. The agent-trace part looks like this:

cur.execute("""
    SELECT
        TIMESTAMP,
        RECORD:name::STRING                          AS record_name,
        RECORD:span_id::STRING                       AS span_id,
        TRACE:trace_id::STRING                       AS trace_id,
        RECORD_ATTRIBUTES:sf.cortex.agent.name::STRING AS agent_name,
        RECORD_ATTRIBUTES:sf.user.name::STRING       AS user_name,
        SUBSTR(VALUE::STRING, 0, 4000)               AS event_value,
        RECORD:severity_text::STRING                 AS severity_text
    FROM TABLE(SNOWFLAKE.LOCAL.GET_AI_OBSERVABILITY_EVENTS(
        'SENTINEL_DEMO_DB', 'DEMO', 'DEMO_AGENT', 'CORTEX AGENT'))
""")

logs_client.upload(
    rule_id=DCR_IMMUTABLE_ID,
    stream_name="Custom-AIObservabilityEvents_CL",
    logs=[to_row(r) for r in cur],
)

The same pattern repeats for CORTEX_AGENT_USAGE_HISTORY (into CortexAgentUsage_CL) and ACCESS_HISTORY (into CortexAccessHistory_CL). To get something to look at, scripts/generate_agent_traffic.py sends five prompts to a demo Cortex Agent through its REST API. That produces around 45 trace events: nine span types across five conversations.


Step 4: correlate and detect in KQL
#

Once the data lands, it’s ordinary KQL. What does the agent spend its time on?

AIObservabilityEvents_CL
| where AgentName == "DEMO_AGENT"
| summarize EventCount = count() by RecordName
| order by EventCount desc

Who is using agents, how heavily, and through which interface?

CortexAgentUsage_CL
| project TimeGenerated, UserName, AgentName, Tokens, TokenCredits,
          RoleName, InferenceRegion, InteractionInterface, RequestId
| order by TimeGenerated desc

A first detection: unusually heavy agent usage per user and hour.

CortexAgentUsage_CL
| summarize TotalTokens = sum(Tokens), TotalCredits = sum(TokenCredits),
            Requests = count() by UserName, bin(TimeGenerated, 1h)
| where Requests > 10 or TotalCredits > 5
| order by TotalCredits desc

The real value is correlation. Three keys tie everything together:

KeyJoins
SESSION_IDAgent session ↔ native login and query tables
QUERY_IDA SQL statement ↔ the objects and columns it touched in ACCESS_HISTORY
REQUEST_IDAn agent request ↔ its token and credit consumption

With those, an analyst can start from an alert on a sensitive table and walk back to the agent conversation that caused it, or start from a suspicious conversation and see every row of data it reached. The demo’s validate.kql correlates traces and access history on a time window, since the minimal pipeline doesn’t yet carry session and query IDs on every row. In production, carry the IDs.


Before you take it to production
#

The repo is a working demo, and some shortcuts are deliberate. Here’s what I’d change before pointing it at a real account.

  1. Run as the audit role, not ACCOUNTADMIN. The demo script connects as ACCOUNTADMIN for simplicity. Use the dedicated role from step 1, and authenticate the pipeline with key-pair or workload identity rather than a long-lived token.
  2. Pull incrementally. The demo reads fixed windows with row limits. Keep a high-water mark per source (last timestamp or event ID), so nothing is skipped or sent twice.
  3. Schedule it. Run the pipeline as an Azure Function or container job on a timer. You can also run it from inside Snowflake as a Task with an external access integration, so the credentials never leave the platform.
  4. Know the latencies. Agent traces are available quickly. ACCESS_HISTORY can lag by around three hours, CORTEX_AGENT_USAGE_HISTORY by up to a day, and the native connector polls with a delay of about two hours. Write detections that tolerate late data, and don’t promise your SOC real time where the source isn’t.
  5. Carry agent identity through. Add agents_info from ACCESS_HISTORY and agent_type from QUERY_HISTORY to the pipeline. Then Sentinel can tell a human query from an agent query directly, which is what most agent detections hinge on.
  6. Cover every agent. Loop over all agents you’re allowed to MONITOR, not just one, and add the other Cortex usage views (Cortex Analyst, Search, AI functions, guardrails, CoCo) as you need them.
  7. Decide on redaction and retention. Apply the step 1 decision, then set Log Analytics retention and table-level access to match it.
  8. Build the content. The demo ships validation queries, not a finished detection pack. Analytics rules and a workbook for your own agent estate are the next step.

Try it
#

git clone https://github.com/sfc-gh-kkeller/Sentinel_Cortex && cd Sentinel_Cortex

snow sql -c sentinel_demo -f sentinel-demo/snowflake/01_setup.sql
# create the Cortex Search service and agent (see the write-up in the repo)
snow sql -c sentinel_demo -f sentinel-demo/snowflake/02_grants_observability.sql

pip install -r sentinel-demo/requirements.txt
python3 sentinel-demo/scripts/generate_agent_traffic.py

export SUB_ID="<your-azure-subscription-id>"
bash sentinel-demo/azure/01_provision_dcr.sh
python3 sentinel-demo/scripts/push_to_sentinel.py

Data shows up in Sentinel within about 5 to 15 minutes. Run validate.kql in the workspace to check it. When you’re done, bash sentinel-demo/teardown.sh drops the Snowflake objects and deletes the Azure resource group.


The takeaway
#

Agents don’t need a new security stack. They need to show up in the one you already run. Snowflake already records what every Cortex Agent does, down to the span. The native Sentinel connector just doesn’t fetch it yet. One small pipeline, three custom tables and a few join keys turn an agent from an invisible user into something your SOC can investigate, alert on and audit.

For sending Snowflake’s own alerts to Sentinel in the other direction, see Snowflake Native Webhook Notifications for SIEM.


References
#

Behaviour and availability are as documented at the time of writing (November 2026). Check the current Snowflake and Microsoft documentation for your edition and region. Views are my own.

Kevin Keller
Author
Kevin Keller
Personal blog about AI, Observability & Data Sovereignty. Snowflake-related articles explore the art of the possible and are not official Snowflake solutions or endorsed by Snowflake unless explicitly stated. Opinions are my own. Content is meant as educational inspiration, not production guidance.
Share this article

Related