Blog Post
Detecting and Alerting on MDE Sensor Health Transitions Using KQL and Logic Apps
Very nice approach, enjoyed the post!
I noticed the query can sometimes produce false positives in large environments, mainly because prev() is evaluated globally and not per device. That can lead to cross-device contamination when serialized.
Here's the adjustment that fixes it:
| extend PrevState = prev(SensorHealthState)
| extend PrevState_deviceId = prev(DeviceId)
| where DeviceId == PrevState_deviceId
I also added logic to detect never-active devices, those that were onboarded but never reported as Active.
I also replaced == "Inactive" with !="Active" to have visibility over misconfigured devices.
Full improved query and explanation here:
https://github.com/Ninos97/detection-rules/blob/main/src/Improving%20MDE%20Sensor%20Health%20Detection.md
Hope you find it useful :)
- absharanOct 13, 2025
Microsoft
Thank you for sharing this, I will take a look into it and update. Cheers.