Splunk Search

how to show Value with individual count

Bhargav99
New Member

Hello Folks I am new to plunk please help me out of this I need Value with its individual count shown next to it .
I wrote this query

index=* sourcetype=my _sourcetype tag_type = AGENTID_COMPLETED User_Id="*"|dedup agentId | stats values(device_type_list) AS device_list,count AS "# of devices" by User_Id | eval device_list =mvjoin(device_list,",")



User_Id           | device_list | # of devices
x@gmail.com         WIN           1
ami@gmail.com       WIN           1
apea@gmail.com      WIN           3
bbir@gmail.com      LINUX         1
bmci@gmail.com      WIN           7
dn@gmail.com        LINUX         1
dslev@gmail.com     WIN           2
ee@gmail.com        LINUX,WIN     14   .................. I need as         LINUX(4), WIN (10)
fburr@gmail.com     WIN        2
fkong@gmail.com     WIN           3
gann@gmail.com      WIN           1
glyel@gmail.com     WIN           1
jlau@gmail.com      LINUX, WIN    7  ..................I need as         LINUX(4), WIN (10)

Thank you

Tags (4)
0 Karma
1 Solution

somesoni2
Revered Legend

Try this

index=* sourcetype=my _sourcetype tag_type = AGENTID_COMPLETED User_Id="*"|dedup agentId | stats count by User_Id device_type_list | eval device_type_list=device_type_list."(".count.")" | stats values(device_type_list) AS device_list,sum(count) AS "# of devices" by User_Id | eval device_list =mvjoin(device_list,",")

View solution in original post

0 Karma

somesoni2
Revered Legend

Try this

index=* sourcetype=my _sourcetype tag_type = AGENTID_COMPLETED User_Id="*"|dedup agentId | stats count by User_Id device_type_list | eval device_type_list=device_type_list."(".count.")" | stats values(device_type_list) AS device_list,sum(count) AS "# of devices" by User_Id | eval device_list =mvjoin(device_list,",")
0 Karma

Bhargav99
New Member

seems perfect !!!!!! Only will try to remove the count for the single ones. Thank you so much!!!!!!!

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Replace your stats with this:

... | stats count as "# of devices" by User_Id device_type_list | rename device_type_list as device_list
0 Karma

Bhargav99
New Member

Hey I tried This but I need unique User Id to be shown in same record.

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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