azure-data-explorer - 尝试使用过去 30 天内未登录的用户创建 KQL
问题描述
让我说我不知道如何使用 Kusto,话虽如此,我们开始吧!我去了我的 AAD 工作簿并获得了一个查询以获取登录信息。然后,我添加了一些信息以获取已登录我的服务的用户列表。我如何让它在过去 30 天内拉出未登录的用户?
let data = SigninLogs
| union ADFSSignInLogs;
data
| where TokenIssuerType in ('AzureAD', 'ADFederationServices') or '*' in ('AzureAD', 'ADFederationServices')
| project TimeGenerated,UserPrincipalName, Status_dynamic, UserDisplayName, Identity, AppDisplayName, AppId, ResourceDisplayName
| extend errorCode = Status_dynamic.errorCode
| extend SigninStatus = case(errorCode == 0, "Success", errorCode == 50058, "Pending user action", errorCode == 50140, "Pending user action", errorCode == 51006, "Pending user action", errorCode == 50059, "Pending user action", errorCode == 65001, "Pending user action", errorCode == 52004, "Pending user action", errorCode == 50055, "Pending user action", errorCode == 50144, "Pending user action", errorCode == 50072, "Pending user action", errorCode == 50074, "Pending user action", errorCode == 16000, "Pending user action", errorCode == 16001, "Pending user action", errorCode == 16003, "Pending user action", errorCode == 50127, "Pending user action", errorCode == 50125, "Pending user action", errorCode == 50129, "Pending user action", errorCode == 50143, "Pending user action", errorCode == 81010, "Pending user action", errorCode == 81014, "Pending user action", errorCode == 81012, "Pending user action", "Failure")
| where SigninStatus == '*' or '*' == '*' or '*' == 'All Sign-ins'
| make-series SignIns = count() default = 0
on TimeGenerated
from ago(30d) to now() step 1d
by SigninStatus,UserDisplayName,UserPrincipalName,AppDisplayName,ResourceDisplayName
如何让我的查询仅显示过去 30 天内未登录我的服务的用户?
解决方案
您需要使用arg_max
获取每个用户名的最新登录时间戳,然后您可以过滤上次登录时间超过 30 天 ( 30d
) 之前的那些。
...
| summarize arg_max(LoginTime, *) by Username
| where LoginTime < ago(30d)
显然,您需要调整列名以匹配您的架构(实际列名)。
推荐阅读
- reactjs - 使用 Firestore 版本 9 提交数据到存储时出错
- visual-studio-code - 停止 VS Code 调试器调试第三方库代码
- javascript - 使用 javascript 的可重用网页元素
- python - Python quiver 角度问题:angles="uv" 和angles="xy" 有什么区别
- r - 使用 where 根据变量标签选择列
- ios - 如何以编程方式启动 iOS Safari 并使用默认引擎(iOS 14.x)进行搜索?
- python - 如何在 kivy 中正确对齐 TabbedPanel 选项卡
- android - 如何在android的UnitTest中使用@Before在gradle api 7.0.2中调用setup()
- r - 我如何对齐两个 ggpubr 直方图,使它们彼此面对?
- git - 将 Git 存储库推送到 Bitbucket