Splunk Search

同じSourcetypeで複数のhostからデータを合計する方法について

hirosakurai
Engager

同じSourcetypeで2つのhostから受信しているcsvに含まれる値を合計したいのですが、searchの方法を教えてください。

host-Aから受信しているcsvのA列(field_A)とB列(field_B)、およびhost-Bから受信しているcsvのA列(field_A)を合計したいのです。

これらのhostは通信経路上の通信量(bps)を監視していて、A列、B列にそれぞれの監視ポート上の通信量が記録されています。
現在の環境ではhost-AのA列とB列、host-BのA列を合計すると、Inboundの合計通信量が出ます。

0 Karma
1 Solution

HiroshiSatoh
Champion

全体の合計でよいですか?
例えば以下のようにすればどうでしょうか?

index=your index (host=host-A OR host=host-B)
|stats sum(eval(if(host="host-A",field_A+field_B,field_A))) as total

ソースタイプ毎なら

index=your index (host=host-A OR host=host-B)
|stats sum(eval(if(host="host-A",field_A+field_B,field_A))) as total by sourcetype

View solution in original post

0 Karma

HiroshiSatoh
Champion

全体の合計でよいですか?
例えば以下のようにすればどうでしょうか?

index=your index (host=host-A OR host=host-B)
|stats sum(eval(if(host="host-A",field_A+field_B,field_A))) as total

ソースタイプ毎なら

index=your index (host=host-A OR host=host-B)
|stats sum(eval(if(host="host-A",field_A+field_B,field_A))) as total by sourcetype
0 Karma

hirosakurai
Engager

ありがとうございます。できました!

質問に書いていませんでしたがcsvには1秒ごとに行が記録されていて、3つのフィールドを合計した値をグラフで出したかったのです。
以下のようにしたら希望の通りのグラフを描くことができました。

 index=your index (host=host-A OR host=host-B)
 |timechart span=5m avg(eval(if(host="host-A",field_A+field_B,field_A))) as total

とても助かりました。また何かあればよろしくお願いします。

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...