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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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