azure - 如何编写 Kusto 查询以在哨兵中获取上个月的日志?
问题描述
| where TimeGenerated > ago(30d)
只给我最近 30 天的日志,我正在搜索查询以从表中获取上个月的日志,因此我可以将其直接导出到 Power BI。
解决方案
下面是如何做到这一点。我展示了两种方式。'简单'的方法是把当月的日期塞进去。更难的方法需要您使用该make_datetime
功能。
// The Easy 'Manual' Way
AuditLogs
| where TimeGenerated >= datetime('2021-08-01') and TimeGenerated <= datetime('2021-08-31')
// Automated Way
let lastmonth = getmonth(datetime(now)) -1;
let year = getyear(datetime(now));
let monthEnd = endofmonth(datetime(now),-1);
AuditLogs
| where TimeGenerated >= make_datetime(year,lastmonth,01) and TimeGenerated <= monthEnd
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/make-datetimefunction
推荐阅读
- c# - 内插变量
- java - 删除所有项目后列表正在返回项目
- axon - 如何启动跟踪事件处理器的正确重置
- nginx - php7.2 + nginx + 内存缓存。未检索到 memcache 密码子目录中的 style.css 和 script.js
- c# - Azure 通知中心静态实例或重新创建
- arrays - Angular - 通过按钮显示数组列表中的隐藏值
- c# - 将几列JSON数组Newtonsoft c#分组
- c++ - 如何使用 yaml cpp 在同一行打印带有 2 个减号的 2d 列表?
- python - 没有这样的文件或目录,但文件存在?
- jmeter - com.blazemeter.jmeter.videostreaming.core.exception.PlaylistDownloadException: