Forum Discussion

Arumai's avatar
Arumai
Copper Contributor
Jan 31, 2024

AVD Session host uptime and Automate

Hi,

I am new to Azure monitor and reporting. I have written a KQL query to sum-up a daily uptime for AVD session hosts. When this query runs

1: It is not rounding the availability column.

2: How can I set a start time and end time fixed for a day (12AM till 11:59 pm)

3: I need to automate this daily run and email this report

Could you please give me any guidance on this. I give the screen shot below

 

Thanks 

Arumai

 

5 Replies

  • Clive_Watson's avatar
    Clive_Watson
    Bronze Contributor
    1. You can use round(Availability,2) to round a vale to 2 decimal places as an example
    2. This is yesterday, the first seen record and the last

    Heartbeat
    | where TimeGenerated between( startofday(ago(1d)) .. endofday(ago(1d)) )
    | summarize min(TimeGenerated), max(TimeGenerated)


    3. You'll need to look at a Automation Rule and Playbook for that, there are many templates in the Content Hub
    • Arumai's avatar
      Arumai
      Copper Contributor
      Thanks Clive, much appreciated.
      • Arumai's avatar
        Arumai
        Copper Contributor

        Clive_Watson 

        I am trying to extract last month report but it is erroring.  Is the query structure for the last month is OK?  Could you please look at this. Thanks in advance.

        //Heartbeat
        | where TimeGenerated between (startofmonth(ago(1m))) .. endofmonth(ago(1m)))
        | summarize min(TimeGenerated), max(TimeGenerated)
        //| summarize heartbeat_per_hour=count() by bin_at(TimeGenerated, 1h, start_time), Computer
        | extend available_per_hour=iff(heartbeat_per_hour > 0, true, false)
        | summarize Available_Hours=countif(available_per_hour == true) by Computer
        | extend Total_Hours=round((max(TimeGenerated) - min(TimeGenerated) / 1h)
        | extend Availability_Percentage=Available_Hours * 100 / Total_Hours
        | project
        Computer,
        Total_Hours,
        Available_Hours,
        round(Availability_Percentage, 0)

         

Resources