Getting Data In

Getting date from filename and time from logs

silvermail
Path Finder

Hello,

I am not sure if this is possible, but I have a file named called php_201000618.txt and inside the logs it contain something like:

----------Time 20:54:17----------
HTTP/1.1 200 OK
Date: Sun, 6 Jun 2010 19:33:17 GMT
Server: Apache
Content-Length: 51
Keep-Alive: timeout=300, max=636

I need to get the date from the filename 20100618 and the time from 20:54:17. Is it possible to split the timestamp recognition precedence into two components?

I know it may seem easier to get it from the line "Date: Sun, 6 Jun 2010 19:33:17 GMT", but this line does not exist in all the lines - and the only reliable place is to get the date from the filename as well as the header "----------Time 20:54:17----------"

Right now I have a props.conf that shows:

TIME_PREFIX = ^----------Time
TIME_FORMAT = %H:%M:%S

Time extraction is working fine, but I am getting some random dates which I am not sure why this is happening.

Thanks for any suggestions.

Tags (1)

kenkenou
Explorer

I set TIME_PREFIX TIME_FORMAT and plus LOOK_AHEAD(how long the time string is) then ,it works well.

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

Try this: http://blogs.splunk.com/2009/12/02/configure-splunk-to-pull-a-date-out-of-a-non-standard-filename/

Yours might not be so complicated, but the general idea holds.

gkanapathy
Splunk Employee
Splunk Employee

There is not, but if you make sure the datetime.xml contains only date formats that will definitely fail in the file, then it should fall through to the filename.

0 Karma

silvermail
Path Finder

Thanks Gerald. I have my own datetime.xml defined already, and it's working great for some events, but for certain events Splunk is pulling the date from some other values in the logs.

So that is the reason why I'm asking if it's possible to change the timestamp recognition precedence so that it will hit my datetime.xml first before going to some other places to look for the date.

Thanks for the response though, always appreciative of your help.

0 Karma

Rob
Splunk Employee
Splunk Employee

You may want to take a look at the following answer that has been posted. I believe that it answers your question as well.

http://splunk-base.splunk.com/answers/12015/setting-date-on-event-based-on-filename

hexx
Splunk Employee
Splunk Employee

The link provided by Rob has been "updated" to better suit your use-case 🙂 Take a look at it now!

0 Karma

silvermail
Path Finder

Thanks Rob, but the example you have mentioned isn't what I was looking for. Thanks anyway...

0 Karma
Get Updates on the Splunk Community!

Splunk Forwarders and Forced Time Based Load Balancing

Splunk customers use universal forwarders to collect and send data to Splunk. A universal forwarder can send ...

NEW! Log Views in Splunk Observability Dashboards Gives Context From a Single Page

Today, Splunk Observability releases log views, a new feature for users to add their logs data from Splunk Log ...

Last Chance to Submit Your Paper For BSides Splunk - Deadline is August 12th!

Hello everyone! Don't wait to submit - The deadline is August 12th! We have truly missed the community so ...