Splunk Search

集計軸が違う場合にCount数を加工して出力する方法についてお教え下さい (How to process and output the count number when the aggregation axis is different)

NgSplunk
New Member

集計軸が違う場合にCount数を加工して出力する方法についてお教え下さい。

index「接続情報」のデータ項目は「タイムスタンプ、ユーザ名、接続プロトコル」になります。
またデータイメージは下記にタイムスタンプが付加された物になります。
---------+----------
ユーザ名 | 接続プロトコル
---------+----------
ユーザA | http
ユーザB | http
ユーザA | ftp
ユーザA | scp
ユーザA | http
ユーザB | http



ユーザC | ftp
---------+----------

接続プロトコル"http"が多い為、"http"接続のみ1/2の件数にして表示したいと思っています。

接続プロトコルを軸に1か月単位で集計する場合は下記のサーチで行えました。
index="接続情報"
| timechart span=mon eval(if("接続プロトコル"="http",count(eval("接続プロトコル"))/2,count)) by "接続プロトコル"

ですが、ユーザ名を軸に集計する場合の方法が分かりません。
1つのサーチで実行可能でしょうか?
よろしくお願いいたします。

Labels (2)
Tags (1)
0 Karma

millarma
Path Finder

if i understand your question, I might start by using the split() or rex command to turn the field into two fields:

|rex field="接続プロトコル" "(?<user>[^\|]+)\|(<?protocol>.*)"

the intent here is captur everyting until '|' and use it to create a 'user' field.  then capture every after '|' and use it to create a protocol field.

 

once you have two fields, you can:

|stats count by user protocol 

0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...