Splunk Search

How to add a lapsed time to a field's timestamp

MeMilo09
Path Finder

Howdy,

Been researching on how to give time for the next sequential event to occur, but have not found a way. Lets say field X occurred and the next event to take place is field Y, but field Y is null  if under 24 hrs give Length_of_Time in min once Y happens.

Issue is if its the same day and Y still has not occurred following X -- , give X 24 hours to happen from the time field Y  happened before marking it as failure of error... So far this is what I have... 

 

 

|  eval X = strptime(StartTime,"%Y-%m-%d %H:%M:%S.%q"),
 Y =strptime(EndTime,"%Y-%m-%d %H:%M:%S.%6N")

note: 86400 is 24 hrs in seconds 

| eval Length_of_Time = if(isNull(Y)AND Y-X < 86400 AND 86400<=X,round((X-Y)/60,0))

 

 

 

Labels (2)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It is unclear to me what you are trying to achieve here - if Y is null, what are you expecting from any further calculations involving Y? Assuming StartTime is a timestamp field, X will probably always be greater than 86400. Assuming you do have actual datetimes in X and Y, the description would suggest that Y occurs after X, so X-Y will be negative.

Please can you clarify, perhaps with some real examples of the event you are dealing with?

0 Karma

MeMilo09
Path Finder

Hi,

my bad for the confusion, I am temporary away from my work station and don’t have the actual code at the moment 


Y can take upto 24 hours to show up after x - making it null until the 24 hours complete. 

so I was thinking I could include a lapse of time of 24 hours after x took place. 


 

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