Reporting

How to change timestamp to include another field value?

POR160893
Builder

Hi,

I have an index with one field as a timestamp, "SESSION_TIME", and another field, "SEQUENCE". The "SEQUENCE" field is unique for each event and i am tasked to replace the seconds part of each timestamp with the respective "SEQUENCE" number.

This is what I currently wrote but I clearly wrote it incorrect:
eval xxx = strftime(SESSION_TIMESTAMP,"%S" = "SEQUENCE")

Can you please help?


Thanks,
Patrick

0 Karma

POR160893
Builder

The SESSION_timestamp is a String value like this 2022-04-20 12:23:43.
The SEQUENCE is an integer value like 101.
I need to replace the second part of each timestamp with the respective SEQUENCE value.
So, in this example, the value I would want is 2022-04-20 12:23:101.

Can you please help?

(I gave you Karma btw 😀)

0 Karma

sperkins
Path Finder

Convert the time to epoch, reformat it without the seconds, and then concatenate with strcat::
| eval time_epoch = strptime('SESSION_timestamp', "%Y-%m-%d %H:%M:%S")
| convert ctime(time_epoch) as hour_minute timeformat="%Y-%m-%d %H:%M"
| strcat hour_minute ":" SEQUENCE combo_time

 

combo_time= 2022-04-20 12:23:101

POR160893
Builder

When I run this query, it does not show the date before the SEQUENCE number ....

POR160893_0-1650481252477.png

 

0 Karma

sperkins
Path Finder

Does the strptime format match the time format of the SESSION_timestamp in your data?

 

POR160893
Builder

No worries, this worked when I capitalised the field nameL

POR160893_0-1650481998356.png

 

sperkins
Path Finder

Fantastic!! 

POR160893
Builder

SESSION_TIMESTAMP="2022-04-20 14:03:41" is the format

sperkins
Path Finder

Ahhh change the eval to capitalize the field name
| eval time_epoch = strptime(SESSION_TIMESTAMP, "%Y-%m-%d %H:%M:%S")

isoutamo
SplunkTrust
SplunkTrust

Hi

what is your actual issue which you are trying to solve? I suppose that you will get more issues with this e.g. when value of SEQUENCE is outside of 0 to 59?

Is your SESSION_TIME in epoc or human readable mode and if later what is the format?

r. Ismo

POR160893
Builder

The SESSION_timestamp is a String value like this 2022-04-20 12:23:43.
The SEQUENCE is an integer value like 101.
I need to replace the second part of each timestamp with the respective SEQUENCE value.
So, in this example, the value I would want is 2022-04-20 12:23:101.

Can you please help?

(I gave you Karma btw 

POR160893_0-1650477084063.png

 

)

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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...