Getting Data In

Can you help me with a question about extracting timestamps?

manijain
New Member

I have below timestamps in my events

2018-09-14-19.50.21.057230
2018-09-14-19.51.10.675968

I only want to extract hh and mm from them i.e. 19.50 and 19.51

0 Karma
1 Solution

493669
Super Champion

Try this:

|eval Time=strftime(strptime(STATUS_TIME,"%Y-%m-%d-%H.%M.%S.%3N"),"%H.%M")

Try this run anywhere search-

|makeresults|eval STATUS_TIME="2018-09-14-19.50.21.057230"|eval Time=strftime(strptime(STATUS_TIME,"%Y-%m-%d-%H.%M.%S.%3N"),"%H.%M")

View solution in original post

493669
Super Champion

Try this:

|eval Time=strftime(strptime(STATUS_TIME,"%Y-%m-%d-%H.%M.%S.%3N"),"%H.%M")

Try this run anywhere search-

|makeresults|eval STATUS_TIME="2018-09-14-19.50.21.057230"|eval Time=strftime(strptime(STATUS_TIME,"%Y-%m-%d-%H.%M.%S.%3N"),"%H.%M")

manijain
New Member

Thanks a lot..this helps

0 Karma

kmorris_splunk
Splunk Employee
Splunk Employee

Are you trying to use these as the timestamp for the event, or do you simply want to extract the hour and minute into a field?

If the latter, then try:

eval hoursminutes=strftime(yourtimestampfield,"%H.%M")
0 Karma

manijain
New Member

There is an extracted field from the events the name for which is STATUS_TIME. I tried using what you gave, it doesn't help

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...