Splunk Search

How to convert a plain text field to a time format?

marstj
New Member

Hi, i have a field in my logs that is date and time but it is in plain text not in time format. The field looks like this "Field=(Y/M/D h.m)".

Any suggestion how i can convert it so i can use it in time based queries?

Thanks

0 Karma

richgalloway
SplunkTrust
SplunkTrust

To convert the time field at index time, edit the TIME_FORMAT attribute in your props.conf file. You may need to adjust other settings as well.

[mysourcetype]
TIME_PREFIX = FIELD=
TIME_FORMAT = %Y/%m/%d %H.%M

To convert the time field at search time, use the strptime function.

... | eval ts = strptime(field, "%Y/%m/%d %H.%M") | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Splunk Observability Synthetic Monitoring - Resolved Incident on Detector Alerts

We’ve discovered a bug that affected the auto-clear of Synthetic Detectors in the Splunk Synthetic Monitoring ...

Video | Tom’s Smartness Journey Continues

Remember Splunk Community member Tom Kopchak? If you caught the first episode of our Smartness interview ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud? Learn how unique features like ...