Splunk Search

How to join search and use join ?

hrishi_deshpand
Explorer

First Event

INFO | 2021-10-18 05:17 AM | BUSINESS RULE | Payload for ID#: 40658606156551247672591634534230307 with status Approved is published

Second Event

msg INFO | 2021-10-14 10:38 PM |  Message consumed: {"InputAmountToCredit":"22.67","CurrencyCode":"AUD","Buid":"1401","OrderNumber":"877118406","ID":"58916"}

 

I want to have sum of InputAmountToCredit based on status . status can vary to different statuses and ID is common field for both the events what is best way to sum the amount with the same status for specified timeframe

 

Thanks for all the support.

Labels (4)
0 Karma

hrishi_deshpand
Explorer

index = pcf_logs cf_org_name = creorg OR cf_org_name = SvcITDnFAppsOrg cf_app_name=VerifyReviewConsumerService host="*" | eval _raw = msg | rex "InputAmountToCredit\"\:\"(?<PayloadAmount>[^\"]+)" | rex "Request\#\:\s*(?<ID1>\d+) with (?<Status>\w+.\w+)" | rex "CRERequestId\"\:\"(?<ID2>[^\"]+)" | eval ID=coalesce(ID1,ID2)|stats latest(Status) as Status values(PayloadAmount) as Amount by ID

 

I am using this to generate report I want but as per my understanding I should create a summary index by using 

| stats values(*) as * by ID

 and then by using stats result I should be able to do chart or another stats or whatever. Just because  

| stats values(*) as * by ID

 this gives me all the data related to ID and I can play with it the way I want after creating the index. Is my understanding is correct?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Yes, your understanding is correct.  Be aware, however, that the values() function may produce a multi-value field.  Some commands you might use after stats may not handle multi-value commands well (or at all) so additional massaging of the data may be necessary.

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Assuming the fields are extracted already, you can use the stats command to group results by a shared field.

... | stats values(*) as * by ID
---
If this reply helps you, Karma would be appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Splunk Auto Ingestion Parallel Pipeline Scaling

Why this feature matters Many Splunk environments experience ingestion pressure long before the host is fully ...

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...