Forum Discussion
PatrikHansson
Sep 07, 2020Brass Contributor
KQL to only get values during office hours
Hi, im trying to get insightdata for office hours only. all examples i find is for one day only but I want to have a graph for a week but only 6am to 16pm. Can't figure it out. Anyone that can help.
InsightsMetrics
| where Computer contains "servername"
| where Name == "WriteBytesPerSecond"
| where parse_json(Tags).["vm.azm.ms/mountId"] == "F:"
| summarize sum(Val) by Computer, bin(TimeGenerated, 24h)
Hi PatrikHansson ,
Try using hourofday() function and then filter the hours.
Link to the function dcumentation: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/hourofdayfunction
Example:
InsightsMetrics | where TimeGenerated > ago(7d) | extend Hour = hourofday(TimeGenerated) | where Hour >= 6 and Hour < 16 | summarize sum(Val) by Computer, bin(TimeGenerated, 24h)
Rafi
- Rafi_RaboMicrosoft
Hi PatrikHansson ,
Try using hourofday() function and then filter the hours.
Link to the function dcumentation: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/hourofdayfunction
Example:
InsightsMetrics | where TimeGenerated > ago(7d) | extend Hour = hourofday(TimeGenerated) | where Hour >= 6 and Hour < 16 | summarize sum(Val) by Computer, bin(TimeGenerated, 24h)
Rafi
- PatrikHanssonBrass Contributor
Rafi_Rabo Thanks...so simple