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!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...