# An empty KQL result does not mean your client's logs are empty

> On Azure, your permissions and the time range you pick shape what a query returns more than its syntax does.

Original: https://fdetimes.net/en/tools/empty-kql-result-azure-logs/

According to Microsoft's documentation, when a caller without permission queries a protected table, the query still succeeds but returns no data. There is no 400 error, and no 403 either.

The feature is still in preview, but it is enough to lead an FDE on a first visit to a client's Azure environment to the wrong conclusion that the system records nothing.

Every FDE working with Azure clients will run into this sooner or later, because debugging, investigating incidents and measuring how a deployment performs all go through the logs. Reading those logs almost always means writing Kusto Query Language (KQL).

Microsoft Sentinel is built on Azure Monitor and stores all its data in Log Analytics workspaces, so one language lets you read both operational logs and security logs.

The skill worth learning has three parts, and syntax is only one of them. The other two are choosing the right table and time range, and knowing what you are actually allowed to see.

## A read-only language, and an unforgiving one

The overview page on Microsoft Learn describes KQL as a tool for exploring data, discovering patterns, identifying anomalies and building statistical models. The language was developed inside Azure Data Explorer, a service Microsoft introduced in 2018.

The first thing for an FDE to remember is that a Kusto query is read-only: it processes data and returns results, and writes nothing. Management commands, which start with a dot, have their own syntax and are not part of KQL. So when you ask a client for permission to run queries, you are not asking for permission to change their systems.

The second point costs more time: KQL is case-sensitive everywhere, from table and column names to operators and functions. People who come from SQL tend to trip over this straight away.

## How narrow should the first query be?

Data in Azure Monitor Logs is partitioned on the TimeGenerated column. Microsoft writes that narrowing the time range is the most effective way to make a query run fast. A query spanning more than 15 days is considered excessively resource-intensive, and one spanning more than 90 days may be throttled.

The commands search * and union * force the system to scan every table in the workspace, sometimes hundreds of them. The first query at a client should therefore name exactly one table and filter on time in the second line. The example below returns ten records from the last hour:

```kusto
AzureDiagnostics
| where TimeGenerated > ago(1h)
| take 10
```

Type `timegenerated` in lowercase and the query breaks, because KQL is case-sensitive. Get used to that kind of error on sample data, rather than meeting it for the first time while sitting next to a client in the middle of an incident.

## Limits and costs to know in advance

Azure Monitor sets clear limits. Each user can run at most 5 concurrent queries against Analytics tables, not counting alert queries. A single query returns at most 500,000 records, and through the Query API it can run for at most 10 minutes.

If you write a script that runs many queries in parallel for a client, the limit of 5 concurrent queries is where it will fail first.

Cost is the part many people overlook. When a query touches a table on the Basic or Auxiliary plan, the charge is based on the total data scanned across every table in the query. Data in Analytics tables that is still within its retention period is not counted.

Microsoft's own example shows how quickly the cost adds up: scanning 3 days of a table that ingests 100 GB a day is billed as 300 GB. Stretch that to 15 days, the point Microsoft already treats as excessive, and the equivalent figure is 1,500 GB. Before running a long query against an unfamiliar table, ask the client which plan that table is on.

## What access to request before writing a query

The built-in Log Analytics Reader role can view and search all monitoring data and monitoring settings within its assigned scope, but cannot read workspace keys. For most projects, this is the sensible level of access to ask a client for.

**Key point:** An empty result does not always mean there are no logs; sometimes you just lack the access to see them.

Holding the Reader role still may not show you everything if the workspace uses protected tables, because, as noted at the start, missing permissions there produce no error.

If your company is a managed security provider, Azure Lighthouse lets you manage a client's Sentinel from your own tenant, although deploying connectors also requires GDAP. And after March 31, 2027, Sentinel will be available only in the Microsoft Defender portal, which belongs in your handover documentation.

## An empty table: what to check, and in what order

Take a client who reports that an API has been failing repeatedly since the previous evening, and you run the sample query above in the morning and get an empty table back. Do not jump to conclusions. Work through the checks one by one, from the cheapest to the most laborious.

First, the time range. A filter of `ago(1h)` in the morning will not reach last night's incident. Widen it just enough to cover the time the client reported, say one day, rather than leaping to several weeks.

Next, the names. Since KQL is case-sensitive in both table and column names, compare each letter against the names in the workspace, and ask the client which table that service's logs actually go into.

Then, permissions: at what scope is your Log Analytics Reader role assigned, and does that scope cover the resource under investigation? Finally, ask the client whether the table is a protected table, because that is the case where missing access produces silence.

A common mistake is widening the search in the most expensive way: switching to search * to "find it somewhere", or stretching the time range beyond 15 days, even beyond 90 and getting throttled. If the table is on the Basic or Auxiliary plan, each such widening also increases the data you are billed for.

## Once there is data, what is the next question?

Suppose the client says API requests are logged in the `AppRequests` table, with a `Success` column marking whether each request succeeded or failed. The next step is to count failures by hour around the time the client reported the incident:

```kusto
AppRequests
| where TimeGenerated > ago(1d)
| where Success == false
| summarize count() by bin(TimeGenerated, 1h)
```

The result is only about twenty-four rows, each an hour with its count of failed requests. The first hour where the number jumps gives you a marker to take back to the client: was there a deployment, a configuration change or a traffic spike at that point?

Aggregating early like this also keeps you well clear of the 500,000-record limit per query. Only once you have pinned down the problem hour should you narrow the `where` clause to that hour and pull back detailed logs to read.

The mistake that costs more in credibility is telling a client their system is not logging before you have gone through all four checks above.

## What to learn first

There is no need to wait for a real project. Microsoft offers a Log Analytics demo environment with sample data that requires no Azure subscription, only a Microsoft account or Microsoft Entra ID to sign in to the portal. Build the habits: one table, time filter first, correct casing, then hourly counts like the one above.

On the career side, if an FDE job posting mentions Azure Monitor or Sentinel, a sample KQL query in your portfolio shows you can read a client's logs on your own. On a CV, a line describing how you used KQL to pinpoint when an incident began, with a sample query and how you handled an empty result, carries more weight than simply listing the tool.

KQL syntax can be learned in a few sessions. What takes longer to develop is looking at an empty result table and asking the right question: is the system not logging, or am I not yet allowed to see?

**Try this week:**

- Open Microsoft's Log Analytics demo environment, run a query on one table with a one-hour TimeGenerated filter, then rewrite a column name in lowercase to see how the query breaks.
- On the sample data, write a summarize count() by bin(TimeGenerated, 1h) query over one day and find the hour with an unusual number of records.
- Draft a checklist of what to request at the start of an Azure project: the Log Analytics Reader role, its assigned scope, which tables are protected and the plan of each table.

## Sources

- [Kusto Query Language (KQL) overview - Kusto | Microsoft Learn](https://learn.microsoft.com/en-us/kusto/query/)

- [Kusto Query Language (KQL) overview - Kusto | Microsoft Learn](https://learn.microsoft.com/en-us/kusto/query/?view=microsoft-sentinel)

- [Introducing Azure Data Explorer](https://azure.microsoft.com/en-us/blog/introducing-azure-data-explorer/)

- [Optimize log queries in Azure Monitor - Azure Monitor | Microsoft Learn](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/query-optimization)

- [Azure Monitor service limits - Azure Monitor | Microsoft Learn](https://learn.microsoft.com/en-us/azure/azure-monitor/fundamentals/service-limits)

- [Query Data in Basic and Auxiliary Tables in Azure Monitor Logs - Azure Monitor | Microsoft Learn](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/basic-logs-query)

- [Manage access to Log Analytics workspaces - Azure Monitor | Microsoft Learn](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/manage-access)

- [Manage multiple tenants in Microsoft Sentinel as a Managed Security Service Provider | Microsoft Learn](https://learn.microsoft.com/en-us/azure/sentinel/multiple-tenants-service-providers)

- [What is Microsoft Sentinel SIEM? | Microsoft Learn](https://learn.microsoft.com/en-us/azure/sentinel/overview)

- [Log Analytics Tutorial: Query and Analyze Log Data - Azure Monitor | Microsoft Learn](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/log-analytics-tutorial)
