Get Azure alert details using KQL

SujinaSJ-1789 271 Reputation points
2023-08-04T12:16:36.7633333+00:00

Hi All,

Can we get the alert details (alert name, Fired time, resolved time etc.) using KQL? If yes, what configuration is required and which table to query?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,561 questions
{count} votes

Accepted answer
  1. SwathiDhanwada-MSFT 18,911 Reputation points
    2023-08-07T05:01:03.71+00:00

    You can Azure Resource Graph service to query the alerts triggered within your subscription. Below sample query gets all Azure Monitor alerts that were fired in the last 12 hours and extracts commonly used properties for your reference. You can modify it based on your requirement.

    alertsmanagementresources
    | where properties.essentials.startDateTime > ago(12h)
    | project
      alertId = id,
      name,
      monitorCondition = tostring(properties.essentials.monitorCondition),
      severity = tostring(properties.essentials.severity),
      monitorService = tostring(properties.essentials.monitorService),
      alertState = tostring(properties.essentials.alertState),
      targetResourceType = tostring(properties.essentials.targetResourceType),
      targetResource = tostring(properties.essentials.targetResource),
      subscriptionId,
      startDateTime = todatetime(properties.essentials.startDateTime),
      lastModifiedDateTime = todatetime(properties.essentials.lastModifiedDateTime),
      dimensions = properties.context.context.condition.allOf[0].dimensions, properties
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bhardwaj, Rajeev 110 Reputation points
    2023-08-05T02:49:28.7666667+00:00

    Yes, it can be.

    Different services store alert data in different tables. You need to determine which table holds the relevant data for the alerts you're interested in.

    For example, you can use below for Security Events:

    SecurityAlert

    | project AlertName, AlertStartTime, AlertEndTime, ResolutionTime

    | where TimeGenerated >= datetime(2023-07-01) and TimeGenerated <= datetime(2023-08-01)

    Please confirm if it works for you.


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.