Splunk Search

How can we use if else case condition in case of NaN, so that I can use now() in case of NaN?

dkssingh2005
Explorer

while searching through all time  in filter  drop down, i am getting NaN value for "$tokLatest$", I don't know why its coming. For others like- week to date, month to date its coming fine. Only issue  is coming for All time.

 

I don't know why its coming. Below is the code snippets. Any solution for this???????

How  can we use if else case condition in case of NaN.  so that I can use now() in case of NaN. Any solution?????????

<search>
<query> |makeresults
</query>
<earliest>$timepicker.earliest$</earliest>
<latest>$timepicker.latest$</latest>
<progress>
<eval token="tokEarliest">strptime($job.earliestTime$,"%Y-%m-%dT%H:%M:%S.%3N%z")</eval>
<eval token="tokLatest">strptime($job.latestTime$,"%Y-%m-%dT%H:%M:%S.%3N%z")</eval>
<eval token="tokEarliest1">strftime(relative_time(tokEarliest,"-330m"),"%Y-%m-%d %H:%M:%S.%3N")</eval>
<eval token="tokEarliest1">strftime(relative_time(tokLatest,"-330m"),"%Y-%m-%d %H:%M:%S.%3N")</eval>
</progress>
</search>
<description>draft event ingestion rate by wfm at day or hour level</description>
<fieldset submitButton="true" autoRun="false">
<input type="time" token="timepicker" searchWhenChanged="false">
<label>Time Range</label>
<default>
<earliest>-24h@h</earliest>
<latest>now</latest>
</default>
</input>

</fieldset>

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try these changes

<eval token="tokLatest">if(isnull($job.latestTime$),now(),strptime($job.latestTime$,"%Y-%m-%dT%H:%M:%S.%3N%z")</eval>
<eval token="tokEarliest1">strftime(relative_time($tokEarliest$,"-330m"),"%Y-%m-%d %H:%M:%S.%3N")</eval>
<eval token="tokLatest1">strftime(relative_time($tokLatest$,"-330m"),"%Y-%m-%d %H:%M:%S.%3N")</eval>

View solution in original post

dkssingh2005
Explorer

@ITWhisperer , Thanks for your's solution

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try these changes

<eval token="tokLatest">if(isnull($job.latestTime$),now(),strptime($job.latestTime$,"%Y-%m-%dT%H:%M:%S.%3N%z")</eval>
<eval token="tokEarliest1">strftime(relative_time($tokEarliest$,"-330m"),"%Y-%m-%d %H:%M:%S.%3N")</eval>
<eval token="tokLatest1">strftime(relative_time($tokLatest$,"-330m"),"%Y-%m-%d %H:%M:%S.%3N")</eval>
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...