Splunk Search

How to use rex to extract only the date field?

fertlaloc
New Member

hi everyone

my log is: 2017-03-07T14:21:17.061-0600,,0,,,,,1,0,0,0,** 1753-01-01 00:00:00.0000000**,0,1753-01-01 00:00:00.0000000,, and I need

1.- In the bolded portion of the log, how can I use rex to extract only yyyy-mm-dd (1753-01-01, a normal date format)?
2.- when I have 1753 in my logs, how to show empty or Null?

thank yo very much

0 Karma

lguinn2
Legend

Try this

yoursearchhere
| rex ",.*?\s(?<myDate>\d{4}-\d{2}-\d{2})\s"
| replace "1753*" with "*" in myDate
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...