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

Labels (1)
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
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...