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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...