Sentinel Aux logs - query cost optimization

Sándor Tőkési 271 Reputation points
2025-05-08T14:07:19.7+00:00

Hey folks,

I'm curious whether there is any way to decrease the cost of Aux logs queries. If you run a query on an Auxiliary table, you have to pay for the data you scanned through.

Is there any KQL function/operator that can be used to decrease the cost of the query if we have a given amount of data in a specific table (so data is in the table and this cannot be changed)?

Examples:

  1. Using the TimeGenerated filter, if I set it to > ago(1h), will it actually only scan the last 1 hour of data, or will it go through the last 24h-s (default settings on the GUI) and then return the results from the last 1 hour? (scanned data is 1h or 24h?)
  2. Even if TimeGenerated actually decreases the cost, will any other 'where' filter do the same? I assume any where filter scans all the data and returns only the matches.
  3. What about the 'limit' operator? If I use the 'limit 5' will I have to pay for only 5 events, or will it scan the whole table and then return with 5 events?
  4. What about materialize? If I want to use the same data over and over again in one query. Would creating a variable and storing materialized data in it actually be cheaper than just using the Aux table itself multiple times? (again, inside one query).

I have my own assumptions of course, but I'm curious whether Microsoft has an official statement or whether somebody has some proof for these things and some other recommendation.

Microsoft Sentinel
Microsoft Sentinel
A scalable, cloud-native solution for security information event management and security orchestration automated response. Previously known as Azure Sentinel.
1,275 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andrew Blumhardt 10,046 Reputation points Microsoft Employee
    2025-05-10T04:41:19.7166667+00:00

    Great question. Optimizing KQL queries for cost in Aux logs is essential, especially at scale. Using a TimeGenerated filter early in your query is the most effective way to reduce scanned data and lower cost.

    Other where filters don’t help as much since they apply after the scan. Limit only reduces returned rows, not the scanned volume.

    Use project early to trim unused columns, and materialize can help avoid repeating large scans in a single query. Stick to time filters, minimal columns, and avoid unnecessary joins to keep queries efficient and cost-effective.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.