Forum Discussion

henry_vuorela350's avatar
henry_vuorela350
Copper Contributor
Oct 26, 2022

how can I create query monitor logs that will alert if the vm has restarted 4 times within an hour?

how can I create query monitor logs that will alert if the vm has restarted 4 times within an hour?

4 Replies

  • Clive_Watson's avatar
    Clive_Watson
    Bronze Contributor
    There are two approaches (maybe more).
    1. Check the Heartbeat tables for four periods where there is no data sent. However that is only really confirming the agent isn't sending...there are lots of examples
    2. Look at the Windows Events for the eventids that appear when a machine starts ans count these...this will need you to collect that data with a DCR or MMA setting
    • henry_vuorela350's avatar
      henry_vuorela350
      Copper Contributor
      I'm thinking of doing it with heartbeats but I don't know how to create that kind of query. how can I create such a query that monitors something that doesn't happen 4 times within an hour?

      Sorry, I'm a beginner and I don't really know where to read more on the subject.
      • Clive_Watson's avatar
        Clive_Watson
        Bronze Contributor

        henry_vuorela350 

         

        Something like this:

         

        Heartbeat
        | where TimeGenerated > ago(1h)
        | summarize dcount(Computer) by Computer, bin(TimeGenerated,15m)
        | summarize sum(dcount_Computer) by Computer
        | where sum_dcount_Computer < 4

         

         Go to Log Analytics and run query

        These are the computers that didn't have at least 4 heartbeats in the past 1hr - remember this is only an indicator that the VM re-started, it could also show false scenarios like agent failure or other reasons 

        Computer sum_dcount_Computer
        AppFE00008ZW1
        AppFE00008ZX1
        AppFE00008ZQ2
        AppFE00008ZS2
        AppFE00008ZT2
        AppFE00008ZR1