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!

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...

AI Adoption Hub Launch | Curated Resources to Get Started with AI in Splunk

Hey Splunk Practitioners and AI Enthusiasts! It’s no secret (or surprise) that AI is at the forefront of ...