title: Azure Kubernetes Service (AKS) - Pod restart alert
body: <p>I want to create an alert rule when a pod has restarted. i.e. if the pod restarts twice in a 30 min window</p>
  
  <p>I have the following log analytics query:</p>
  
  <pre><code>KubePodInventory
  | where ServiceName == "xxxx"
  | project PodRestartCount, TimeGenerated, ServiceName
  | summarize AggregatedValue = count(PodRestartCount) by ServiceName, bin(TimeGenerated, 30m) 
  </code></pre>
  
  <p>But setting the alert threshold to 2 in this case won't work since the PodRestartCount is not reset. Any help would be greatly appreciated. Maybe there is a better approach which I'm missing.</p>