Splunk Search

Events are getting matched, but why don't I see any table with messageid and timediff?

amitrinx
Explorer

I have 2 events having fields
1. id_cse_event: sqsmessageid,timestamp
2. Scim: sqs_message_id, timestamp.

I want to search all the messages published by id_cse_events in scim using messageid, then find the difference between the time stamps

This is the query i have wrote:
sourcetype=id-cse-events
| where isnotnull(sqsMessageId)
| eval sqsmsgid=sqsMessageId
| eval id_cse_time=timeStamp
| table sqsmsgid, id_cse_time
| map
[search sourcetype=scim |fields line.message.sqs_message_id, line.timestamp|search line.message.sqs_message_id="$sqsmsgid$"
| eval time_diff_in_seconds=strptime(id_cse_time,"%Y-%m-%dT%H:%M:%S")-strptime(line.timestamp,"%Y-%m-%dT%H:%M:%S") ]maxsearches=9999
| table line.message.sqs_message_id,time_diff_in_seconds

id_cse_time= 2023-01-27T09:55:45.970831Z
scim timestamp = 2023-01-27T08:24:28.601+0000



The events are getting matched, but i don't see any table with messageid and timediff.
Can anyone help?

Labels (2)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Rather than using map, try gathering the events with stats

sourcetype=id-cse-events OR sourcetype=scim
| eval sqsmsgid=coalesce(sqsMessageId,line.message.sqs_message_id)
| stats values(timeStamp) as id_cse_time values(line.timestamp) as line_timestamp by sqsmsgid
| eval time_diff_in_seconds=strptime(id_cse_time,"%Y-%m-%dT%H:%M:%S")-strptime(line.timestamp,"%Y-%m-%dT%H:%M:%S")
| table sqsmsgid,time_diff_in_seconds

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Rather than using map, try gathering the events with stats

sourcetype=id-cse-events OR sourcetype=scim
| eval sqsmsgid=coalesce(sqsMessageId,line.message.sqs_message_id)
| stats values(timeStamp) as id_cse_time values(line.timestamp) as line_timestamp by sqsmsgid
| eval time_diff_in_seconds=strptime(id_cse_time,"%Y-%m-%dT%H:%M:%S")-strptime(line.timestamp,"%Y-%m-%dT%H:%M:%S")
| table sqsmsgid,time_diff_in_seconds

amitrinx
Explorer

With this query i can only see the timestamps of id_cse_events not for the scim

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Please can you share some events from both sourcetypes (anonymised of course), preferably in code blocks </> to prevent information being removes by the formatting process.

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 ...