Splunk Search

Count occurrences of multiple fields

joxley
Path Finder

I have the following data

start_station   | end_station
_____________________________
Wimbledon       | Waterloo
Wimbledon       | Vauxhall
Vauxhall        | Wimbledon
Waterloo        | Vauxhall

I want to count how many times I visited each station and get the following output

Vauxhall   | 2
Waterloo   | 1
Wimbledon  | 3
1 Solution

joxley
Path Finder

One possible solution is to make a multi-value field out of the two fields then count by that

| eval stations=start_station + ";" + end_station | makemv delim=";" stations | stats count by stations

View solution in original post

tachifelix
Path Finder

try this search string: "change source name"
note:the following search don't work in splunk 6.2

  source="test32.csv" | stats count by start_station |appendcols [search source="test32.csv"|stats count as end by end_station]  | table start_station end|fillnull value=0

joxley
Path Finder

One possible solution is to make a multi-value field out of the two fields then count by that

| eval stations=start_station + ";" + end_station | makemv delim=";" stations | stats count by stations
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...