[英]Splunk to take the second queries result(field) into first query for Percentage Memory of Linux host
我是 SplunK 的新手。
我正在嘗試提取屬於名為Database_hosts
的特定組的 Linux 主機的Memory %
。
如果我將其明確提供為host="host01.example.com"
,我可以獲得特定主機的Memory %
但是,我希望針對多個主機運行此查詢。
我可以從 Splunk 中的inputlookup cmdb_host.csv
中提取屬於Database_hosts
組的多個主機。
現在,我可以從inputlookup cmdb_host.csv
中提取主機,其中包含name
字段中的主機,但我不知道如何將第二個查詢放入我的第一個查詢中,即sourcetype=top pctMEM=* host="host01.example.com"
雖然這兩個查詢都是獨立工作的。
sourcetype=top pctMEM=* host="host01" OR host="host02"
| multikv
| dedup host
| rex field=pctMEM "(?<usage>\d+)"
| where usage> 40
| table host pctMEM
和
| inputlookup cmdb_host.csv
| search support_group="Database_hosts" NOT (fqdn IN("ap*", "aw*",""))
| table name
我如何將第二個查詢 output 字段name
用於 First Queris host=
字段。
任何幫助都感激不盡。
剛剛嘗試但沒有運氣:
sourcetype=top pctMEM=* host="[inputlookup cmdb_host.csv where support_group="Database_hosts" | table name]
| multikv
| dedup name
| rex field=pctMEM "(?<usage>\d+)"
| where usage>20
| table name pctMEM
你很親密。 如果您自己運行子搜索(方括號內的部分)並添加| format
| format
,然后您將看到返回到主搜索的內容。 它看起來像((name=host01) OR (name=host02))
。 將其與主要搜索相結合會產生:
sourcetype=top pctMEM=* host=((name=host01) OR (name=host02))
| multikv
| dedup name
| rex field=pctMEM "(?<usage>\d+)"
| where usage>20
| table name pctMEM
這是行不通的。 可以通過在子搜索中將名稱重name
為host
並讓子搜索創建表達式來修復它。
sourcetype=top pctMEM=* [|inputlookup cmdb_host.csv where support_group="Database_hosts"
| return 100 host=name]
| multikv
| dedup name
| rex field=pctMEM "(?<usage>\d+)"
| where usage>20
| table name pctMEM
return
命令告訴 Splunk 返回最多 100 個結果並將 name 重name
為host
。 相當於fields name | rename name as host | format
fields name | rename name as host | format
fields name | rename name as host | format
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.