Getting Data In

How do I deal w. single digit months/days in vix.input.1.et.regex?

jimjh
Path Finder

I have directory paths that look like

/year=2014/month=6/day=4/hour=1/

However, using the following regex is suboptimal, because yyyyMdH can cause ambiguity:

vix.input.1.et.regex = /year=(\d+)/month=(\d+)/day=(\d+)/hour=(\d+)/
vix.input.1.et.format = yyyyMdH

For example, given /year=2014/month=7/day=15/hour=9, Hunk will extract the digits, concatenate them into a string, and try to parse it as such:

scala> new SimpleDateFormat("yyyyMdH").parse("20147159")
res0: java.util.Date = Thu Jul 03 11:00:00 PDT 2014

which is incorrect. What regex should I use in this case?

Tags (2)
0 Karma
1 Solution

jimjh
Path Finder

Moving the = symbol into the capturing groups allows you to remove any ambiguity.

 vix.input.1.et.regex = /year(=\d+)/month(=\d+)/day(=\d+)/hour(=\d+)/
 vix.input.1.et.format = =yyyy=M=d=H

View solution in original post

jimjh
Path Finder

Moving the = symbol into the capturing groups allows you to remove any ambiguity.

 vix.input.1.et.regex = /year(=\d+)/month(=\d+)/day(=\d+)/hour(=\d+)/
 vix.input.1.et.format = =yyyy=M=d=H
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...