Splunk Search

How to correlate across two lists in a stats

t_splunk_d
Path Finder

 

I want to correlate across two lists and display the results.

Log data:

06/10/2023 05:04:12  ACMIUY-6500-2345-20230610050412.pdf
06/10/2023 05:05:12  ACMIUY-6500-2345-20230610050412-success.csv

06/10/2023 07:14:22 DCCOUB-86895-20230610071422.pdf

Note: The data is in the same index and I don't want to use join

mysearch | stats list(file_sent) list(file_received) list(sent_time) list(received_time)

 

Sent Time File_Sent Received TimeFile_ReceivedElapsed_time
06/10/2023 05:04:12ACMIUY-6500-2345-20230610050412.pdf06/10/2023 05:05:12ACMIUY-6500-2345-20230610050412-success.csv00:01:00
06/10/2023 07:14:22DCCOUB-86895-20230610071422.pdfPendingPending-

 

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<fullfilename>\S+)$"
| rex field=fullfilename "(?<filename>\S+)(?<event>\.pdf|\-success\.csv)$"
| eval sentTime=if(event=".pdf",_time,null())
| eval receivedTime=if(event=".pdf",null(),_time)
| eval fileSent=if(event=".pdf",fullfilename,null())
| eval fileReceived=if(event=".pdf",null(),fullfilename)
| stats values(sentTime) as sentTime values(fileSent) as fileSent values(receivedTime) as receivedTime values(fileReceived) as fileReceived by filename
| eval elapseTime=tostring(receivedTime-sentTime,"duration")

View solution in original post

t_splunk_d
Path Finder

I also see for some file received the file name is:
PD0018MM-220385-20230609211505.20230609211740-success.csv 

How to modify so that the filename is extracted as PD0018MM-220385-20230609211505

| rex field=fullfilename "(?<filename>\S+)(?<event>\.pdf|\-success\.csv)$"

Also how display "Pending" if no corresponding file_received for the file_sent?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=fullfilename "(?<filename>[^\.\s]+)(?<event>\.pdf|\-success\.csv)$"

You could also add

| fillnull value="Pending" receivedTime fileReceived

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<fullfilename>\S+)$"
| rex field=fullfilename "(?<filename>\S+)(?<event>\.pdf|\-success\.csv)$"
| eval sentTime=if(event=".pdf",_time,null())
| eval receivedTime=if(event=".pdf",null(),_time)
| eval fileSent=if(event=".pdf",fullfilename,null())
| eval fileReceived=if(event=".pdf",null(),fullfilename)
| stats values(sentTime) as sentTime values(fileSent) as fileSent values(receivedTime) as receivedTime values(fileReceived) as fileReceived by filename
| eval elapseTime=tostring(receivedTime-sentTime,"duration")
Get Updates on the Splunk Community!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

New Release | Splunk Cloud Platform 10.1.2507

Hello Splunk Community!We are thrilled to announce the General Availability of Splunk Cloud Platform 10.1.2507 ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

&#x1f5e3; You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...