Splunk Search

strptime() returning UNIX epoch time adjusted by timezone

pedropiin
Path Finder

Hi everyone.

I'm trying to link my dashboard to a separate platform and the url of this new platform needs to contain a timestamp in epoch time. I have a table such that each row represents a cycle and I have a column that redirects the user to a separate platform passing into the url the epoch time of that row's timestamp.

The issue is that, for some reason, Splunk seems to be converting the timestamp to epoch + my timezone.

So, for example, on the screenshot below, you can see the timestamp of a certain row in UTC as 16:33:27.967

pedropiin_0-1752515647244.png

and, to debug, I built a new column such that whenever I click on it, it redirects me to an url that's simply the timestamp converted to epoch time. The code is of the form:

<table> 
  <search>
    <query>
      ...
    </query>
  </search>
  <drilldown>
    <condition field="Separate Platform">
      <eval token="epochFromCycle">case($row.StartTime$=="unkown", null(), 1==1, strptime($row.StartTime$, "%Y-%m-%dT%H:%M:%S.%Q"))</eval>
      <link target="_blank">
        <![CDATA[ 
          $epochFromCycle$ 
        ]]>
      </link>
    </condition>
  </drilldown>
</table>

But, when clicking on this "Separate Platform" column for the timestamp shown on the screenshot, I get the epoch time 1752521607. When looking into "epochconverter.com":

pedropiin_1-1752516089058.png

As stated on the screenshot, I'm at GMT-03. But the issue happens exactly the same way for a coworker who's located at GMT-04: for the same splunk timestamp, he clicks on the column to generate the link, and the epoch time that splunk returns is in fact 4 hours ahead (in this case, it returns the epoch equivalent of 8:33:27 PM).

What am I missing?

Thanks in advance, 
Pedro





Labels (1)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

With strptime Splunk always uses the timezone of the user calling the function unless the time string to be parsed contains timezone information and the time format uses it. So you could just set a static GMT timezone spec and parse from there.

But.

Since you're parsing this from a row of search result why do the strftime/strptime both ways? Just use epoch timestamp returned from the search.

View solution in original post

pedropiin
Path Finder

😅😅😅😅you're right... It works perfectly...

Thank you so much, @PickleRick !

0 Karma

PickleRick
SplunkTrust
SplunkTrust

With strptime Splunk always uses the timezone of the user calling the function unless the time string to be parsed contains timezone information and the time format uses it. So you could just set a static GMT timezone spec and parse from there.

But.

Since you're parsing this from a row of search result why do the strftime/strptime both ways? Just use epoch timestamp returned from the search.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...