Splunk Search

Transaction not grouping results with startswith and endswith filter

dasfx
Engager

I am doing the labs for Fundamentals Part 2 and I am not understanding something 

I have to use the startswith and endswith options of the transaction command to display transactions that
begin with an addtocart action and end with a purchase action.

The end result should look like this

dasfx_0-1627035929928.png


The successful query for that is 

 

 

index=web sourcetype=access_combined
| transaction clientip startswith=action="addtocart" endswith=action="purchase"
| table clientip, JSESSIONID, product_name, action, duration, eventcount, price

 

 


However, when I try the following query

 

 

index=web sourcetype=access_combined
| transaction clientip startswith="addtocart" endswith="purchase"
| table clientip, JSESSIONID, product_name, action, duration, eventcount, price

 

 

 

the output (shown below) I get is not correct

dasfx_1-1627036270562.png

I am interested to know why omitting the "action" filter with startswith and endswith give me a different result and doesn't group them anymore?

Thank you in advance for your help

Labels (1)
0 Karma
1 Solution

renjith_nair
Legend

There might be other events which has "addtocart" and/or "purchase" strings. You may verify that by searching these specific strings. But when you add "action=addtocart" its only looking for real transactions which has some actions in it

Try comparing

index=web sourcetype=access_combined ("addtocart" OR "purchase")|stats count

with

index=web sourcetype=access_combined (action="addtocart" OR action="purchase")|stats count
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

dasfx
Engager

Hello, you are right. Thanks a lot for your time. 

I think I have figured it out. 

When I try the following command 

index=web sourcetype=access_combined
| transaction clientip startswith="addtocart" endswith="purchase"
| table clientip, JSESSIONID, product_name, action, duration, eventcount, price

 
Splunk is grouping any event where the string "addtocart"  comes before the string "purchase", regardless if those events are the values of the action field or not. 

That's why, in the screenshot in the action column, I still see entries which have only "purchase" and this is what confused me because I could not understand why isn't there an "addtocart" too in that column for the same transaction. 

However, when we specify startswith=action="addtocart", we make it clear we only want events where the action field starts and end with those values.

Your comment and some goofing around (screenshot below) helped made it clear for me


dasfx_0-1627302607591.png

 

0 Karma

renjith_nair
Legend

There might be other events which has "addtocart" and/or "purchase" strings. You may verify that by searching these specific strings. But when you add "action=addtocart" its only looking for real transactions which has some actions in it

Try comparing

index=web sourcetype=access_combined ("addtocart" OR "purchase")|stats count

with

index=web sourcetype=access_combined (action="addtocart" OR action="purchase")|stats count
---
What goes around comes around. If it helps, hit it with 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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...