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!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...