簡體   English   中英

如何計算Splunk中的結果並將其放在表格中?

[英]How to count results in Splunk and put them in a table?

我正在嘗試在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命令(如下所示),它將返回一個包含所有列的表,但是唯一包含數據的表是“ Error Count”列:

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

知道實現此目標的最佳方法是什么?

我認識的某個人提出了解決方案,我需要更改'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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM