Splunk Search

How to create a search to check single user having multiple transaction?

splkjk
Explorer

Hello Team @SPL, Was working on some of the development activity, got stuck at some level. We have a scenario where I need to check , on a single day which user had done transactions for more than 3 different vendors and transfer the output into tabular format.

When i perform the distinct count i get the count of the user who had done transaction with 3 vendors on same day

| stats dc(Vendor) AS dc_vendor values(Vendor) AS Vendor BY UserID

 

Need to have output detailed in table 2

Table 1:-

Date  UserID Vendor Transactions
10/5/2021 user 1 SAAS(User 1) $$$$$
10/5/2021 user 2 PAAS(User 1) $$$$$
10/7/2021 user 3 IAAS $$$$$
10/8/2021 user 4 AAA $$$$$
10/9/2021 user 5 CCCC $$$$$
10/10/2021 user 6 FFFF $$$$$
10/5/2021 user 7 XXXX (User 1) $$$$$
10/6/2021 user 8 ZZZZ $$$$$
10/8/2021 user 9 EEE $$$$$
10/9/2021 user 10 QQQQ $$$$$

 

Output Table 2

Date UserID Vendor Transactions
10/5/2021 user 1 SAAS(User 1) $$$$$
    AAS(User 1) $$$$$
    XXXX (User 1) $$$$$
Labels (7)
Tags (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @splkjk,

you have to join the values of Vendor and Transaction before stats and separe them afte, something like this:

| eval Vendor_Transaction=vendor."|".Transaction
| stats dc(Vendor) AS dc_vendor values(Vendor_Transaction) AS Vendor_Transaction BY UserID
| where dc_Vendor>3
| mvexpand Vendor_Transaction
| rex field=Vendor_Transaction "^(?<Vendor>[^\|]+)*|(?<Transaction>.*)"
| table UserID Vendor Transaction

Ciao.

Giuseppe

splkjk
Explorer

Thanks @gcusello  for the inputs, but i should have been more specific. I'm new to Splunk and trying to explore the options.
My output table shouldn't contain Transaction amount, just the date, UserID and Vendor

DateUserIDVendor
10/5/2021user 1SAAS(User 1)
  AAS(User 1)
  XXXX (User 1)



Tags (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @splkjk,

in this case you can use the first halp of my search:

your_search
| stats dc(Vendor) AS dc_vendor values(Vendor) AS Vendor earliest(_time) AS Date BY UserID
| where dc_Vendor>3
| eval Date=strftime(earliest,"%d-%m-%Y")
| table Date UserID Vendor

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...