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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...