在 Appinsigts 中,确定查询返回的时间戳是否为 >24 小时前

In Appinsigts, determine if the timestamp returned by a query is >24h ago

我在 Azure AppInsights 中有一个日志序列,用于保存计划作业的每个 运行 的日志记录。

为了知道上次作业是什么时候运行,我按如下方式使用请求

customEvents
| where name == "Scheduled job started"  
| project source=strcat(tostring(customDimensions.prefix), "-", tostring(customDimensions.postfix)), timestamp
| summarize last_started=max(format_datetime(todatetime(timestamp),'yy-MM-dd HH:mm:ss')) by source
| order by last_started desc

所以它给了我一个 table 喜欢

job0    20-08-11 13:40:06   
job1    20-08-11 13:35:06   
job2    20-08-11 13:15:06
...

现在,我需要为过去超过 24 小时的时间戳创建警报,这意味着,我想修改查询,以便它只包含时间戳超过 24 小时前的行。稍后,如果有这样的时间戳,我将制定一个警报规则。

我怎样才能做到这一点?

尝试 ago 运算符:

customEvents
| where name == "Scheduled job started"  
| extend source=strcat(tostring(customDimensions.prefix), "-", tostring(customDimensions.postfix)), timestamp
| summarize last_started=max(format_datetime(todatetime(timestamp),'yy-MM-dd HH:mm:ss')), lastTimestamp = max(timestamp) by source
| where lastTimestamp < ago(1d)
| order by lastTimestamp desc
| project source, last_started 

如您所见,ago 运算符可以在此处为您提供帮助。由于该运算符只能与日期时间字段一起使用,我也必须 select lastTimestamp,但它在投影中被过滤掉了。