Splunk Search

How to group different values and count the number of transactions?

auaave
Communicator

Hi guys,

I have 2 data sources (source 1 and source 2) with different locations and transactions.
How can I group the locations to Inbound and Outbound and count the transactions?

Thank you.

Source 1
Location        Transaction
Location/dock/1     ok
Location/rec/1      ok
Location/pack/1     ok
Location/ship/1     ok


Source 2
Location        Transaction
Location/dock/1     not ok
Location/rec/1      not ok
Location/pack/1     not ok
Location/ship/1     not ok

Groupings
Inbound = Location/dock/1 , Location/rec/1  
Outbound = Location/pack/1, Location/ship/1

Result
Location       Ok   not ok
Inbound     2          2
Outbound        2          2
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @auaave ,
Can you please try this?

YOUR_SEARCH | | eval Location=case(like(Location,"%dock%") OR like(Location,"%rec%"),"Inbound",like(Location,"%pack%") OR like(Location,"%ship%"),"Outbound") | chart count over Location by  Transaction

My Sample Search:

| makeresults | eval Location="Location/dock/1,Location/rec/1,Location/pack/1,Location/ship/1" | eval Location=split(Location,",")| mvexpand Location | eval Transaction="ok" | append [| makeresults | eval Location="Location/dock/1,Location/rec/1,Location/pack/1,Location/ship/1" | eval Location=split(Location,",")| mvexpand Location | eval Transaction="not ok"] | eval Location=case(like(Location,"%dock%") OR like(Location,"%rec%"),"Inbound",like(Location,"%pack%") OR like(Location,"%ship%"),"Outbound") | chart count over Location by  Transaction

Thanks

View solution in original post

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @auaave ,
Can you please try this?

YOUR_SEARCH | | eval Location=case(like(Location,"%dock%") OR like(Location,"%rec%"),"Inbound",like(Location,"%pack%") OR like(Location,"%ship%"),"Outbound") | chart count over Location by  Transaction

My Sample Search:

| makeresults | eval Location="Location/dock/1,Location/rec/1,Location/pack/1,Location/ship/1" | eval Location=split(Location,",")| mvexpand Location | eval Transaction="ok" | append [| makeresults | eval Location="Location/dock/1,Location/rec/1,Location/pack/1,Location/ship/1" | eval Location=split(Location,",")| mvexpand Location | eval Transaction="not ok"] | eval Location=case(like(Location,"%dock%") OR like(Location,"%rec%"),"Inbound",like(Location,"%pack%") OR like(Location,"%ship%"),"Outbound") | chart count over Location by  Transaction

Thanks

auaave
Communicator

@kamlesh_vaghela, thanks for your help! The groupings works well but I changed the last part to take into account the 2 types of sources.

0 Karma
Get Updates on the Splunk Community!

The Payment Operations Wake-Up Call: Why Financial Institutions Can't Afford ...

The same scenario plays out across financial institutions daily. A payment system fails at 11:30 AM on a busy ...

Make Your Case: A Ready-to-Send Letter for Getting Approval to Attend .conf25

Hello Splunkers, Want to attend .conf25 in Boston this year but not sure how to convince your manager? We've ...

Community Spotlight: A Splunk Expert's Journey

In the world of data analytics, some journeys leave a lasting impact not only on the individual but on the ...