Splunk Search

How to combine two fields with eval ?

monipinni
Explorer

paymenttype RefunpaymentType

DEBIT DEBIT
GIFTCARD PGIFTCARD
ORIGINAL CREDITCARD
ORIGINAL DEBITCARD

I am trying to get output like this and also count of this combinations

Refund Count

DEBIT-DEBIT 100
GIFTCARD -PGIFTCARD 50
ORIGINAL-CREDITCARD 75
ORIGINAL-DEBITCARD 88

Can any one help

Tags (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

... | stats count AS Count BY paymenttype RefunpaymentType
| eval Refund = paymenttype . "-" . RefunpaymentType
| table Refund Count

View solution in original post

0 Karma

siddharthkhatsu
Explorer

| search "body.refundTenderType"=*
| search "body.refundTenders{}.paymentType"=*
| rename body.refundTenderType as "RefundTender"
| rename body.refundTenders{}.paymentType as "RefundTenderPaymentType"
| stats count AS Count BY RefundTender RefundTenderPaymentType, body.orderNumber add this here
| eval Refund = RefundTender . "-" . RefundTenderPaymentType
| table Refund , body.orderNumber
| chart count by Refund

Try this if it works

0 Karma

woodcock
Esteemed Legend

Like this:

... | stats count AS Count BY paymenttype RefunpaymentType
| eval Refund = paymenttype . "-" . RefunpaymentType
| table Refund Count
0 Karma

monipinni
Explorer

@woodcock : tried this search i got results but count is displaying is 1 instead of accurate count values

| search "body.refundTenderType"=* | search "body.refundTenders{}.paymentType"=* | rename body.refundTenderType as "RefundTender" | rename body.refundTenders{}.paymentType as "RefundTenderPaymentType" | stats count AS Count BY RefundTender RefundTenderPaymentType | eval Refund = RefundTender . "-" . RefundTenderPaymentType | table Refund , body.orderNumber | chart count by Refund

0 Karma

woodcock
Esteemed Legend

1 extra step that is not in my answer; do this:

... | search "body.refundTenderType"=* AND "body.refundTenders{}.paymentType"=* 
| rename body.refundTenderType as "RefundTender", body.refundTenders{}.paymentType as "RefundTenderPaymentType" 
| stats count AS Count BY RefundTender RefundTenderPaymentType 
| eval Refund = RefundTender . "-" . RefundTenderPaymentType 
| table Refund Count
0 Karma

mayurr98
Super Champion

try this:

|  eval field=paymenttype+"-"+RefunpaymentType | stats count by field
0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...