Splunk Search

Correlating values in different index

Souradip11
Explorer

Hi,

I have two indexes - "cart" and "purchased" . In "cart" index there is a field "cart_id" and in "purchased" there is a field "pur_id".  If  payment will be successfully for a cart then the card_id values will be stored as a pur_id in the "purchased" index.

cart purchased 

cart_id 123 payment received  pur_id   123

cart_id 456   no payment  no record for 456

Now I want to display the percentage of cart for which payment is done.

I wonder if anyone can help here.

 

Thank you so much 

Labels (2)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
index IN (cart purchased) cart_id=* OR pur_id=*
| eval common_id=coalesce(cart_id, pur_id)
| eventstats dc(index) as common_count by common_id
| where index="cart"
| stats count as carts count(eval(common_count > 1)) as purchases
| eval pct=(purchases*100)/carts
| table carts purchases pct
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Perhaps this will help.  It counts the number of unique cart and purchase IDs then does the math to find the percentage of paid carts.

index IN (cart purchased) cart_id=* OR pur_id=*
| stats dc(cart_id) as carts, dc(pur_id) as purchases
| eval pct=(purchases*100)/carts
| table carts purchases pct
---
If this reply helps you, Karma would be appreciated.
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 ...