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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...