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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...