SOLVED

KQL to only get values during office hours

Brass Contributor

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)
2 Replies
best response confirmed by PatrikHansson (Brass Contributor)
Solution

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_Rabo Thanks...so simple :flushed:

1 best response

Accepted Solutions
best response confirmed by PatrikHansson (Brass Contributor)
Solution

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

View solution in original post