Study guide
Technical reference and lesson notes
Purpose of This Lesson
Microsoft provides a public GitHub repository containing reusable Kusto Query Language (KQL) hunting queries for Microsoft Sentinel and Microsoft Defender. These queries are useful starting points for threat hunting, inventory analysis, and learning how Microsoft security data is queried.
This lesson focuses on locating a Microsoft-provided query, adapting its time range or other parameters, and running it in Microsoft Defender Advanced Hunting.
Key Concepts
Microsoft Sentinel GitHub Repository
The Microsoft-maintained repository is available at:
https://github.com/Azure/Azure-Sentinel
The repository contains resources for Microsoft Sentinel, including hunting queries organized into categories. One relevant path is the hunting query collection, where queries are grouped by technology and use case.
A typical workflow is:
- Open the Azure Sentinel GitHub repository.
- Navigate to the hunting queries area.
- Select the Microsoft 365 Defender category when looking for Defender-related queries.
- Choose a relevant subcategory, such as device inventory.
- Read the query description and identify the code beneath the
Querylabel. - Copy the KQL into Microsoft Defender Advanced Hunting or an appropriate Sentinel hunting experience.
- Review, modify, and run the query in the target tenant.
Microsoft 365 Defender Advanced Hunting
Microsoft Defender Advanced Hunting provides an interactive environment for querying security data with KQL. Analysts can use it to investigate activity, identify patterns, validate hypotheses, and create reusable hunting content.
A repository query is not necessarily a finished answer for every environment. Analysts should review its tables, fields, filters, time range, and expected data sources before relying on the result.
Reusable Queries as Starting Points
Microsoft-provided hunting queries can help analysts:
- Learn the structure of Defender hunting tables and fields.
- Quickly investigate common security questions.
- Establish a baseline for device or user activity.
- Adapt an existing query to a specific incident or time period.
- Build analyst confidence through hands-on experimentation.
For example, a device inventory query may calculate the count and percentage of each device type in the available inventory. The same query can be modified to examine a different time window or adjusted for a more specific investigative objective.
Microsoft Security Operations Context
A SOC analyst commonly begins with a question rather than a specific query. Examples include:
- What types of devices are represented in the environment?
- Is a device category unexpectedly increasing or decreasing?
- Did a suspicious activity pattern occur during a particular period?
- Can a hypothesis from an incident be tested against Defender telemetry?
The GitHub repository provides vetted examples that can reduce the time needed to translate those questions into KQL. However, the analyst remains responsible for validating the query and interpreting the results in the context of the tenant.
When using content across Microsoft Sentinel and Microsoft Defender, confirm that the query matches the target product’s available tables, schema, permissions, and data. A query designed for one hunting experience may require adjustment before it works elsewhere.
Tool / Feature Decision Guide
| Requirement | Recommended approach | Reason |
|---|---|---|
| Need a Microsoft-provided example query | Browse the Azure-Sentinel GitHub hunting query repository | It provides categorized starting points and descriptions |
| Need interactive investigation across Defender telemetry | Use Microsoft Defender Advanced Hunting | It is designed for KQL-based hunting in Defender data |
| Need to understand what a copied query does | Read the description, tables, filters, and time constraints before execution | Query output is only meaningful when the analyst understands its scope |
| Need a different investigation period | Modify the query’s time filter | The default period may not cover the incident timeline |
| Need to use content in another Microsoft security product | Validate schema and supported tables first | Similar products and repositories do not guarantee identical query compatibility |
KQL Notes
The lecture identifies these examples as KQL queries. A common adjustment is changing the query’s time range. For instance, a query that examines the last seven days may need to cover a much longer period when investigating historical activity.
Before changing a time range, consider:
- Whether the relevant data is retained for the requested period.
- Whether the broader range will increase execution time or result volume.
- Whether older data has the same schema and collection coverage.
- Whether the query’s purpose is a current inventory snapshot or historical trend analysis.
Do not treat a longer time range as automatically better. A narrow range is often more useful for incident triage, while a broader range can support baselining or historical investigation.
Exam-Relevant Takeaways
- Microsoft provides reusable hunting content through the Azure-Sentinel GitHub repository.
- Hunting queries are organized into categories, including Microsoft 365 Defender-related content.
- The query code is typically found beneath a
Querylabel and should be reviewed before copying. - Microsoft Defender Advanced Hunting is the execution environment demonstrated for the copied query.
- Analysts can adapt a query, including its time range, to match the investigation.
- A query’s description helps explain the intended result and should be read before execution.
- Repository content is a starting point; analysts must validate data availability, schema, scope, and results in their own tenant.
Common Exam Traps
- Confusing KQL with a different query language: Microsoft security hunting queries use KQL.
- Assuming the default time range is universal: A query limited to seven days may miss evidence outside that period.
- Treating a repository query as automatically tenant-ready: The query may depend on specific Defender data, permissions, or schema.
- Ignoring the target product: A query found in the Sentinel repository may be intended for a particular Microsoft 365 Defender or Sentinel context. Check compatibility before running it.
- Focusing only on syntax: A successful query execution does not prove that the results are complete or relevant.
- Overlooking the query description: The description often explains what the output measures and prevents misinterpretation.
Real-World SOC Analyst Notes
- Preserve the original query before modifying it so that changes can be reviewed or reproduced.
- Record the query version, time range, execution date, and tenant context in investigation notes.
- Validate whether the result reflects actual inventory or only devices represented in the available telemetry.
- Expand time ranges deliberately. Large searches may produce more noise, take longer, or obscure the investigative question.
- Use repository queries for learning and acceleration, but apply normal change-control and peer-review practices before turning modified queries into production hunting content or detections.
- Treat public query content as code: inspect filters, joins, assumptions, and output fields before using it in an investigation.
- When results affect incident severity or escalation, corroborate them with alerts, device details, identity data, or other relevant evidence.
Quick Reference Summary
- Repository:
Azure/Azure-Sentinelon GitHub. - Content location: Hunting queries, organized into technology and use-case categories.
- Example category: Microsoft 365 Defender device inventory.
- Execution tool shown: Microsoft Defender Advanced Hunting.
- Language: KQL.
- Primary customization: Adjust the time range and other query logic to fit the investigation.
- Best practice: Read, validate, test, and document copied queries before relying on their output.
Flashcards
Q: Where can an analyst find Microsoft-provided Sentinel and Defender hunting query examples?
A: In the Microsoft-maintained Azure/Azure-Sentinel GitHub repository, particularly its hunting query collection.
Q: Which language is used for the hunting queries discussed in this lesson?
A: Kusto Query Language, or KQL.
Q: What should an analyst inspect before copying a repository query?
A: Read the description and review the query code, tables, filters, time range, and expected data before running it.
Q: Which Microsoft tool is used in the demonstration to execute the copied query?
A: Microsoft Defender Advanced Hunting.
Q: A query examines only the last seven days, but the incident began 30 days ago. What should the analyst do?
A: Modify the query’s time filter to cover the incident period, then consider data retention, performance, and whether older telemetry is available.
Q: Why is a GitHub hunting query best treated as a starting point rather than a final answer?
A: Its assumptions, schema, data sources, and time range may not match the analyst’s tenant or investigative question.
Q: When would a narrow time range be preferable to a much broader one?
A: During focused incident triage, when the analyst needs relevant evidence quickly and wants to reduce noise and query cost or execution time.
Q: What is the exam-relevant difference between finding a query in the Sentinel repository and running it in Defender Advanced Hunting?
A: The repository is the source of reusable content, while Advanced Hunting is the execution environment demonstrated; compatibility and available data must still be validated.
Q: What does a device inventory query measuring count and percentage of device type help an analyst understand?
A: It provides a distribution of device types represented in the queried inventory, supporting inventory review and baseline analysis.
Q: What operational record should be preserved when modifying a hunting query?
A: Keep the original query and document the modifications, time range, execution date, and tenant context.
Q: A query runs successfully but returns no devices. What should the analyst check before concluding that no devices exist?
A: Check the time range, data availability, table and schema assumptions, permissions, and whether the tenant has the expected Defender telemetry.
Q: Why should an analyst read the description associated with a repository query?
A: It explains the query’s intended measurement and helps the analyst determine whether the output answers the current question.
Practice Questions
Question 1
An analyst finds a Microsoft 365 Defender device inventory query in the Azure-Sentinel GitHub repository. The query runs in Advanced Hunting but covers only the last seven days, while the investigation concerns activity from 45 days ago. What is the best next step?
A. Assume the query cannot be used for historical investigations
B. Change the time filter to include the investigation period and validate retention and results
C. Run the query repeatedly for seven-day periods without documenting the changes
D. Move the query directly into an automation rule
Correct answer: B
The query can be adapted, but the analyst should confirm that the required historical telemetry exists and document the changed scope. A longer time range may also affect performance and result volume.
Question 2
A copied hunting query executes successfully but produces results that appear inconsistent with the organization’s known device inventory. What should the analyst do first?
A. Treat the query output as authoritative because it came from Microsoft
B. Delete the query and start an unrelated investigation
C. Review the query description, tables, filters, time range, and available tenant data
D. Convert the query into a detection immediately
Correct answer: C
Microsoft-provided queries are reusable examples, not guarantees that every tenant has identical data or coverage. The analyst must validate the query’s assumptions and scope.
Question 3
An SC-200 exam question asks where an analyst can obtain categorized, Microsoft-provided hunting query examples for Sentinel and Defender investigations. Which choice is most appropriate?
A. The Azure/Azure-Sentinel GitHub repository
B. Microsoft Entra audit logs only
C. A Defender incident’s evidence pane only
D. An automation rule gallery only
Correct answer: A
The Azure/Azure-Sentinel GitHub repository contains categorized hunting query content, including Microsoft 365 Defender-related examples.
Question 4
A SOC analyst wants to use a public repository query as a production hunting query. Which practice best reduces operational risk?
A. Run it without inspection because Microsoft authored it
B. Review and test it, preserve the original, document changes, and validate tenant-specific data
C. Extend the time range to the maximum possible value by default
D. Use the output as an automatic severity decision without corroboration
Correct answer: B
Query content should be reviewed and tested like code. Documentation, validation, and controlled adoption help prevent incorrect conclusions and unnecessary noise.
Question 5
Which statement best describes the relationship between the Microsoft Sentinel GitHub repository and Defender Advanced Hunting?
A. The repository stores query examples, while Advanced Hunting can be used to execute compatible Defender hunting queries
B. Advanced Hunting is the GitHub repository’s replacement and cannot use KQL
C. The repository automatically runs every query against the tenant
D. Queries from the repository always work unchanged in every Microsoft security product
Correct answer: A
The repository is a source of reusable query examples. Advanced Hunting is an interactive Defender query environment, but analysts must verify that a query’s schema, tables, permissions, and data sources match the target environment.