Admin Manual

 


About the Splunk Admin Manual
How Splunk Works

Configure timestamp recognition

This documentation does not apply to the most recent version of Splunk. Click here for the latest version.

Configure timestamp recognition

Configure how Splunk recognizes timestamps by editing props.conf. Splunk uses strptime() formatting to identify timestamp values in your events. Specify what Splunk recognizes as a timestamp by setting a strptime() format in the TIME_FORMAT= key.

When forwarding data using the SplunkLightForwarder application, all timestamp recognition/extraction will take place on the receiving/indexing instance.

Learn about Splunk's enhanced strptime() format support.

Note: If your event has more than one timestamp, set Splunk to recognize the correct timestamp with positional timestamp extraction.


Configure timestamp extraction in props.conf

Use $SPLUNK_HOME/etc/system/README/props.conf.example as an example, or create your own props.conf. Make any configuration changes to a copy of props.conf in $SPLUNK_HOME/etc/system/local/, or your own custom application directory in $SPLUNK_HOME/etc/apps/. For more information on configuration files in general, see how configuration files work.

Configure any of the following attributes in props.conf to set Splunk's timestamp recognition. Refer to $SPLUNK_HOME/etc/system/README/props.conf.spec for full specification of the keys.

[<spec>]
DATETIME_CONFIG = <filename relative to $SPLUNK_HOME>
MAX_TIMESTAMP_LOOKAHEAD = <integer>
TIME_PREFIX = <regular expression>
TIME_FORMAT = <strptime-style format>
TZ = <posix timezone string>
MAX_DAYS_AGO = <integer>
MAX_DAYS_HENCE = <integer>

[<spec>]

DATETIME_CONFIG = <filename relative to $SPLUNK_HOME>

MAX_TIMESTAMP_LOOKAHEAD = <integer>

TIME_PREFIX = <regular expression>

TIME_FORMAT = <strptime-style format>

TZ = <timezone string>

MAX_DAYS_AGO = <integer>

Note: You must configure this setting if your data is more than 1000 days old.

MAX_DAYS_HENCE = <integer>

Note: If your machines have the wrong date set or are in a timezone that is one day ahead, set this value to at least 3.


Enhanced strptime support

Configure timestamp parsing in props.conf with the TIME_FORMAT= key. Splunk implements an enhanced version of Unix strptime() that supports additional formats (allowing for microsecond, millisecond, any time width format, and some additional time formats for compatibility). See the table below for a list of the additionally supported strptime() formats.

In previous versions, Splunk parsed timestamps using only the standard Linux strptime() conversion specifications. Now, in addition to standard Unix strptime() formats, Splunk's strptime() implementation supports recognition of the following date-time formats:

%N For GNU date-time nanoseconds. Specify any sub-second parsing by providing the width: %3N = milliseconds, %6N = microseconds, %9N = nanoseconds.
%Q,%q For milliseconds, microseconds for Apache Tomcat. %Q and %q can format any time resolution if the width is specified.
%I For hours on a 12-hour clock format. If %I appears after %S or %s (like "%H:%M:%S.%l") it takes on the log4cpp meaning of milliseconds.
%+ For standard UNIX date format timestamps.
%v For BSD and OSX standard date format.
%z, %:z, %::z, %:::zGNU libc support for RFC 822 / SMTP header timezones. %z maps to -0800 for US pacific time. %:z -08:00, %::z -08:00:00, %:::z -08
%o For AIX timestamp support (%o used as an alias for %Y).
%p The locale's equivalent of AM or PM. (Note: there may be none.)

strptime() format expression examples

Below are some sample date formats with strptime() expressions that handle them.


1998-12-31 %Y-%m-%d
98-12-31 %y-%m-%d
1998 years, 312 days %Y years, %j days
Jan 24, 2003 %b %d, %Y
January 24, 2003 %B %d, %Y
2007年1月22日 下午03時25分26秒 %Y年%m月%d日 下午%H時%M分%S
q|25 Feb '03 = 2003-02-25| q|%d %b '%y = %Y-%m-%d|


Examples

Your data might contain an easily recognizable timestamp to extract such as:

...FOR: 04/24/07 PAGE 01...

The entry in props.conf is:

[host::foo]
TIME_PREFIX = FOR: 
TIME_FORMAT = %m/%d/%y

Your data might contain other information that Splunk parses as timestamps, for example:

...1989/12/31 16:00:00 ed May 23 15:40:21 2007...

Splunk extracts the date as Dec 31, 1989, which is not useful. In this case, configure props.conf to extract the correct timestamp from events from host::foo:

[host::foo]
TIME_PREFIX = \d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} \w+\s
TIME_FORMAT = %b %d %H:%M:%S %Y

This configuration assumes that all timestamps from host::foo are in the same format. Configure your props.conf stanza to be as granular as possible to avoid potential timestamping errors.

This documentation applies to the following versions of Splunk: 3.3 , 3.3.1 , 3.3.2 , 3.3.3 , 3.3.4 , 3.4 , 3.4.1 , 3.4.2 , 3.4.3 , 3.4.5 , 3.4.6 , 3.4.8 , 3.4.9 , 3.4.10 , 3.4.11 , 3.4.12 , 3.4.13 , 3.4.14 View the Article History for its revisions.


You must be logged into splunk.com in order to post comments. Log in now.

Was this documentation topic helpful?

If you'd like to hear back from us, please provide your email address:

We'd love to hear what you think about this topic or the documentation as a whole. Feedback you enter here will be delivered to the documentation team.

Feedback submitted, thanks!