Splunk Search

Self Join and override Values

akshaysaraf
Explorer

Need some help with a query

Sample Data:

 

{
	id: “123”,
	start_time: “2020-08-01 15:00:00”,
	end_time: “2020-08-01 16:00:00”,
	status: “FAIL”
}

{
	id: “124”,
	start_time: “2020-08-01 16:05:00”,
	end_time: “2020-08-01 16:30:00”,
	status: “SUCCESS”,
	original_id: “123”
}

 

Expected output (in table format) should only have 1 record:

idstart_timeend_timestatus
1232020-08-01 15:00:002020-08-01 16:30:00SUCCESS

 

This event shows data from id=123, but overrides some field like end_time and Status from latter event.

Goal : When we have data where id=original_id then we override some fields from latter event to former  event.

Labels (2)
0 Karma
1 Solution

to4kawa
Ultra Champion

your_search | spath | eval id = coalesce(original_id,id) | stats earliest(start_time) as start_time latest(end_time) as end_time latest(status) as status by id

View solution in original post

0 Karma

to4kawa
Ultra Champion

your_search | spath | eval id = coalesce(original_id,id) | stats earliest(start_time) as start_time latest(end_time) as end_time latest(status) as status by id

0 Karma

akshaysaraf
Explorer

That works, Thank you so much.

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...