Splunk Search

Transaction with a starting event but no ending event? Job started and still running and has not ended...

sjringo
Communicator

Hi, I have the following SPL working fine when I have a starting event and ending event in my logs.

If I have a starting event but no ending event I get no results and would like to show at least starting event info but am having some troubles.

Is there a way to fake out the ending event to be the starting event just to get some data ?

Or are there any other approaches that might make this work ?

index=anIndex sourcetype=aSourceType (aString1 AND "START of script") OR (aString2 AND "COMPLETED") earliest=@d latest=now

| rex "(?<event_name>(START of script)|(COMPLETED OK))"
| eval event_name=CASE(event_name="START of script", "script_start", event_name="COMPLETED OK", "script_complete")
| eval event_time=strftime(_time, "%Y-%m-%d %H:%M:%S")
| eval {event_name}_time=_time
| transaction host job_name startswith=(event_name="script_start") endswith=(event_name="script_complete")
| eval aTime1= _time - (strptime(strftime(_time,"%Y-%m-%dT%H:%M:%S.%3N")." CDT","%Y-%m-%dT%H:%M:%S.%N%Z") - _time)
| eval eventStartTimeCDT=strftime(aTime1, "%H:%M:%S %p")
| eval endTime = _time + duration
| eval eventEndTimeCDT=strftime(endTime, "%H:%M:%S %p")
| eval dayNumber = strftime(endTime, "%w")

| eval "Start / End Job's"="aString1 / aString2"
| eval "Host Name"=if (host="aHostName1", "aHostName1", "aHostName2")
| eval "Duration"=tostring(duration, "duration")
| eval "Day" = strftime(endTime, "%a. %b. %e, %Y")
| eval "Start Time"=eventStartTimeCDT
| eval "End Time"=eventEndTimeCDT
| eval "Due By Time" = if (dayNumber == 0, "02:00 PM", "07:00 AM")

| table "Host Name", "Day", "Start / End Job's", "Start Time", "End Time", "Due By Time", "Duration"

 

Labels (1)
0 Karma
1 Solution

isoutamo
SplunkTrust
SplunkTrust

Hi

you should look keeporphans parameter https://docs.splunk.com/Documentation/Splunk/9.0.1/SearchReference/Transaction

also keepevicted could help you

r. Ismo

View solution in original post

isoutamo
SplunkTrust
SplunkTrust

Hi

you should look keeporphans parameter https://docs.splunk.com/Documentation/Splunk/9.0.1/SearchReference/Transaction

also keepevicted could help you

r. Ismo

sjringo
Communicator

Keeporphans=true did the trick.

I saw that earlier but the way I read it, was not making sense.

Thanks...

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...