Splunk Search

Epoch Search String Multiply

vtsguerrero
Contributor

Hello!

Can anyone please help me with this Search-String?
I have an Epoch Data inside my query like this:

**index=main StartDate_epoch=* | table StartDate_epoch | eval StartDate_epoch=strftime(StartDate_epoch, "%d/%m/%Y")**

Altough, it shows results like this: 31/12/9999
I saw in a website that we should first multiply the epoch date with 1000, how should I multiply this inside the search-string query?

http://www.epochconverter.com/programming/
Tags (4)
0 Karma
1 Solution

tom_frotscher
Builder

Hi,

your epoch timestamp is not really epoch, at least it is 3 digits too long. So it has higher resolution than normal epoch. Try this:

index=main StartDate_epoch=* | eval StartDate_epoch=StartDate_epoch/1000 | eval StartDate_epoch=strftime(StartDate_epoch, "%d/%m/%Y")

Here is a helpful "run everywhere" search that you can use to test things like these:

| stats count | eval StartDate_epoch=1410441296607 | eval StartDate_epoch=StartDate_epoch/1000 | eval StartDate_epoch=strftime(StartDate_epoch, "%d/%m/%Y")

View solution in original post

vtsguerrero
Contributor

For some reason, results are different from the converter web, but close enough I believe, thanks in advance @tom_frotscher!

0 Karma

tom_frotscher
Builder

Hi,

your epoch timestamp is not really epoch, at least it is 3 digits too long. So it has higher resolution than normal epoch. Try this:

index=main StartDate_epoch=* | eval StartDate_epoch=StartDate_epoch/1000 | eval StartDate_epoch=strftime(StartDate_epoch, "%d/%m/%Y")

Here is a helpful "run everywhere" search that you can use to test things like these:

| stats count | eval StartDate_epoch=1410441296607 | eval StartDate_epoch=StartDate_epoch/1000 | eval StartDate_epoch=strftime(StartDate_epoch, "%d/%m/%Y")

vtsguerrero
Contributor

I did it in Javascript and it worked, I dunno how to do it in Splunk, look, this is my JS Script for this situation:

<html>
<head>
<title>Test Script</title>
<script>

var StartDate_epoch=strftime = new Date(1410441296607 * 1000);
document.write(StartDate_epoch=strftime.toGMTStriing() + "<br>" + StartDate_epoch=strftime.tolocaleString());

</script>
</head>
<body style="font-size:32px">

</body>
</html>

How do I use this inside the search string??

0 Karma
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 ...