【问题标题】:Splunk search if host is inactive for more than 5 minutes如果主机不活动超过 5 分钟,则 Splunk 搜索
【发布时间】:2021-03-18 16:19:52
【问题描述】:

我在每个用户搜索的 splunk 数据中有两条特定消息。

  • 有效
  • 不活动 任何人都知道我如何在 splunk 中搜索处于非活动状态超过 5 分钟的用户。 我已经进行了搜索,它可以找到非活动和活动消息以及每个消息的时间戳。 我想要做的只是在这 2 条消息之间的时间超过每个用户 5 分钟时才返回结果。

例子:

index="document" (message="inactive" OR message="active") 

不确定如何根据每个用户的时间戳计算这两条消息之间的时间?

【问题讨论】:

    标签: splunk splunk-query


    【解决方案1】:

    也许这会有所帮助。

    index="document" (message="inactive" OR message="active")
    ```Create a new field called "duration" that the difference between the last value of _time and the current value```
    | streamstats window=2 range(_time) as duration by user
    ```Show only the active users with duration greater than 5 minutes (300 seconds)```
    | where (message="inactive" AND duration>300)
    

    【讨论】:

    • 谢谢 RichG,streamstats window=2 到底是做什么的?
    • (message="inactive" OR message="active") 的顺序是否重要,因为 5 分钟后查询似乎对我不起作用。
    • 命令上方的注释解释了它的作用。 OR 子句中的顺序不重要。 “5分钟后似乎不起作用”是什么意思?如果您没有得到任何结果,则要么没有用户在 5 分钟内处于非活动状态,要么在索引中未找到任何数据。
    • 对,我看到您的评论,但我在问 window=2 是做什么的?我以前从未使用过。为什么是 2?
    • window=2 表示在统计计算中使用当前事件和前一个事件(共 2 个)。
    猜你喜欢
    • 2022-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-12
    • 1970-01-01
    • 1970-01-01
    • 2014-01-20
    • 1970-01-01
    相关资源
    最近更新 更多