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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...