Home > Enterprise >  kql query to compare the hour which has minimum number of TriggersStarted from last week to today pa
kql query to compare the hour which has minimum number of TriggersStarted from last week to today pa

Time:10-16

I tried below query to compare the hour which has min number of TriggersStarted ) from past 1 week to TriggersStarted from last 1 hour today.But i am failing to join the both tables as i dont have common column to merge the both tables.

enter image description here

AzureMetrics
| where TimeGenerated between ( ago(7d) .. endofday(ago(1d)) )
| where MetricName == "TriggersStarted"
| summarize LastWeek=count() by bin(TimeGenerated, 1h)
//| sort by TimeGenerated desc
| summarize min_triigers = min(LastWeek)
| join
(
AzureMetrics
| where TimeGenerated > ago(1h)
| where MetricName == "TriggersStarted"
| summarize TodaysoFar=count()
) on ( cant find common coulmn)

i couldnt be able to add two tables beacuse i dont have common column between them. could u tell me Is there any possibility to use other approach to get it done or should i use another functions?

CodePudding user response:

I'm not sure a join is required. You can try getting both scalar values using toscalar() then printing them in a single row.

For example:

let last_week = toscalar(
  AzureMetrics
  | where TimeGenerated between ( ago(7d) .. endofday(ago(1d)) )
  | where MetricName == "TriggersStarted"
  | summarize LastWeek=count() by bin(TimeGenerated, 1h)
  | summarize min(LastWeek)
);
let last_hour = toscalar(
  AzureMetrics
  | where TimeGenerated > ago(1h)
  | where MetricName == "TriggersStarted"
  | summarize count()
);
print last_week, last_hour
  • Related