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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...