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

Azure 在Appinsigts中,确定查询返回的时间戳是否为>;24小时前,azure,azure-devops,azure-application-insights,Azure,Azure Devops,Azure Application Insights,我在Azure AppInsights中有一个日志序列,用于保存计划作业每次运行的日志记录 为了知道上次运行作业的时间,我使用如下请求 customEvents | where name == "Scheduled job started" | project source=strcat(tostring(customDimensions.prefix), "-", tostring(customDimensions.postfix)), timest

我在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
所以它给了我一张像这样的桌子

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 
customEvents
|其中name==“已启动计划作业”
|扩展源代码=strcat(tostring(customDimensions.prefix),“-”,tostring(customDimensions.postfix)),时间戳
|汇总last_started=max(格式为datetime(时间戳),'yy-MM-dd HH:MM:ss')),lastTimestamp=max(时间戳)按来源列出
|其中lastTimestamp

正如您所看到的,
ago
操作员可以在这里帮助您。由于该运算符只能与datetime字段一起使用,因此我也必须选择lastTimestamp,但它会在投影中被过滤掉。

尝试
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 
customEvents
|其中name==“已启动计划作业”
|扩展源代码=strcat(tostring(customDimensions.prefix),“-”,tostring(customDimensions.postfix)),时间戳
|汇总last_started=max(格式为datetime(时间戳),'yy-MM-dd HH:MM:ss')),lastTimestamp=max(时间戳)按来源列出
|其中lastTimestamp
正如您所看到的,
ago
操作员可以在这里帮助您。由于该运算符只能用于datetime字段,因此我也必须选择lastTimestamp,但它在投影中被过滤掉