【问题标题】:How to count results in Splunk and put them in a table?如何在 Splunk 中计算结果并将它们放在表格中?
【发布时间】:2015-06-30 18:16:28
【问题描述】:

我正在尝试在 Splunk 中创建一个表,其中包含多个提取的字段以及当我为 Splunk 提供要搜索的字符串时返回的条目总数的计数。我遇到的问题是,当我使用 stats 命令获取返回结果的计数并将其通过管道传输到表时,它只是将所有字段留空,但显示返回结果计数的值。如果没有计数逻辑,表格会显示我所追求的所有值。以下是我的示例查询:

index=test "Failed to find file"
| table host, sourceUser, sourceApp, source
| rename host as "Server", sourceUser as "User", sourceApp as "Application", source as "Log"

以下是示例结果(两行 CSV,因为我无法发布图片):

服务器、用户、应用程序、日志

myserver1,joesmith,RadomApp,C:\Users\Joe\Log.txt

这将返回我要求的所有字段。如果我添加 stats 命令(如下所示),它会返回一个包含所有列的表,但唯一有数据的是“错误计数”列:

index=test "Failed to find file"
| stats count as error
| table host, sourceUser, sourceApp, source, error
| rename host as "Server", sourceUser as "User", sourceApp as "Application", source as "Log", error as "Error Count"

示例结果:

服务器、用户、应用程序、日志、错误计数

,,,,1

您知道解决此问题的最佳方法是什么吗?

【问题讨论】:

    标签: splunk


    【解决方案1】:

    我认识的人提出了解决方案,我需要更改“stats”行,以便最终查询如下所示:

    index=test "Failed to find file"
    | stats count as error by host, sourceUser, sourceApp, source
    | table host, sourceUser, sourceApp, source, error
    | rename host as "Server", sourceUser as "User", sourceApp as "Application", source as "Log", error as "Error Count"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 2021-12-25
      • 2021-11-23
      • 2018-12-08
      相关资源
      最近更新 更多