Splunk Search

How to list only distinct values from the listed results?

rakeshyv0807
Explorer

Hi I have a query which runs and results me the list of Ip's in a table format grouped by username.

In my table of results there might be different IP's for the same username which are listed down in the single IP cell. Please find below the example of my result table:

Username-------------------------------------------Ipaddress------------------------application---------------------------city-----------------------------country
1) abcd--------------------------------------------------123.123.123.12---------------------xyz---------------------------------asdf-----------------------------zxcvb
123.123.123.12 xyz asdf zxcvb
234.456.677.22 ghj ghjk fghjk

2) dfgh--------------------------------------------------234.123.12.345----------------------ssss------------------------------dfggh----------------------------ghjhjkk

As shown above for one username there will be list of ip's and corresponding city and country info are displayed. What i want to achieve here is that I need to display only distinct ip's for each username. How can I do it?

To display my results in above table I am using the following search:

mysearch
| iplocation clientip1
| streamstats count as occuranceCount list(clientip1) as client_IP, list(applicationid) as application list(Country) as Country, list(City) as City by subject
| sort - occuranceCount
| dedup subject
| table subject occuranceCount client_IP connectionid City Country

Please help!
Thanks in advance

0 Karma

thambisetty
SplunkTrust
SplunkTrust

you can apply any stats functions like values/list/avg/median etc to only field names. based on your query ban must be field in your index.

————————————
If this helps, give a like below.
0 Karma

rameshnaik
New Member

I want list out all values of variable ban in the string "ban":12897

Using below command but nothing is listed.

index=k8_bm* "jeopardyType" "Prepaid-Service-Error" "ban" | stats values(ban)

 

0 Karma

mayurr98
Super Champion

Instead of list try values? i.e. values(clientip1) as client_IP

let me know if this helps!

JanniktheOne
Engager

values is what I was searching for. It only shows distinct lists.

0 Karma

rakeshyv0807
Explorer

I have tried the values(clientip1) as client_IP but since I am deleting duplicates by username using dedup so the different Ip's of same username are not being displayed.

0 Karma

mayurr98
Super Champion

well you are doing by subject which is already distinct so dedup subject will not make any sense.

can you try this?

mysearch 
| iplocation clientip1 
| streamstats count as occuranceCount by subject clientip1 applicationid Country City 
| table subject occuranceCount clientip1 connectionid City Country 
| sort - occuranceCount 
| dedup subject
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...