Query Details

Azure Monitor Data Collection Rule Inventory

Sentinel Data Collection Rules

Query

// Show all the details.

arg("").Resources
| where type =~ "microsoft.insights/datacollectionrules"
| project DCRName = name,
    Kind = kind,
    ProvisioningState = properties.provisioningState,
    InputStream = properties.dataFlows[0].streams[0],
    OutputStream = properties.dataFlows[0].outputStream,
    TransformKql = properties.dataFlows[0].transformKql,
    FlowDestination = properties.dataFlows[0].destinations[0],
    LAWName = properties.destinations.logAnalytics[0].name,
    LAWWorkspaceId = properties.destinations.logAnalytics[0].workspaceId,
    LAWResourceId = properties.destinations.logAnalytics[0].workspaceResourceId,
    DataCollectionEndpointId = properties.dataCollectionEndpointId,
    ImmutableId = properties.immutableId,
    SubscriptionId = subscriptionId,
    ResourceGroup = resourceGroup,
    Location = location,
    StreamDeclarations = properties.streamDeclarations,
    DataSources = properties.dataSources,
    DataFlows = properties.dataFlows,
    Destinations = properties.destinations,
    AgentSettings = properties.agentSettings,
    Endpoints = properties.endpoints,
    ResourceId = id
| order by DCRName asc

About this query

Explanation

This query is designed to help you review and audit Azure Monitor data collection rules (DCRs). These rules are crucial for defining how monitoring data is collected, transformed, and routed within Azure. By examining these rules, you can identify any configuration gaps that might affect the visibility of security data.

Key Points:

  1. Purpose: The query provides an inventory of data collection rules and their configuration details, which is useful for auditing purposes. It helps ensure that monitoring data is being collected and routed correctly.

  2. Execution: The queries should be run in Microsoft Defender XDR's advanced hunting feature using the arg() operator. The results will show the accessible rules based on the user's permissions.

  3. Limitations: The query results are snapshots of current configurations and do not include historical data. There is a 1,000-record limit for the arg portion of Azure Monitor Logs cross-service queries.

  4. Risk: Misconfigured rules can impact the visibility and routing of security data. However, the inventory results alone do not indicate malicious activity or confirm data collection.

  5. Data Sources: The query uses the Resources table from Azure Resource Graph to gather information about the data collection rules.

  6. Query Details:

    • The first query lists the data collection rules by name, kind, resource group, subscription ID, location, and immutable ID.
    • The second query provides detailed information about each rule, including provisioning state, input and output streams, transformation logic, destinations, and more.

By using these queries, you can effectively audit your Azure Monitor data collection rules to ensure they are configured correctly and identify any potential issues that might affect your security data visibility.