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!

Unlock New Opportunities with Splunk Education: Explore Our Latest Courses!

At Splunk Education, we’re dedicated to providing top-tier learning experiences that cater to every skill ...

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...