logstash icon indicating copy to clipboard operation
logstash copied to clipboard

discrepency between grok pattern TIMESTAMP_ISO8601 and ISO8601 in date filter

Open robin13 opened this issue 12 years ago • 10 comments

I'm trying to import a log (elasticsearch incidentally...) which has a log format like this:

[2014-06-20 07:30:05,987][INFO ][snapshots ] [es101] snapshot [backup:kibana-20140620073002] is done

This is my filter:

        grok {
            match => [
                "message", "\[%{TIMESTAMP_ISO8601:timestamp}\]\[%{DATA:level}\s*\]\[%{DATA:loggerName}\]\s*\[%{DATA:machineName}\] %{GREEDYDATA:message}"
            ]
            overwrite => [ "message" ]
        }

        date {
            match => [ "timestamp", "ISO8601" ]
            remove_field => [ "timestamp" ]
        }

The grok matches the timestamp, but the date filter does not...

I can make it work by replacing the date filter with this:

        date {
            match => [ "timestamp", "yyyy-MM-dd HH:mm:ss,SSS" ]
            remove_field => [ "timestamp" ]
        }

Seems that these could/should be homogeneous...

Cheers! -Robin-

robin13 avatar Jun 23 '14 07:06 robin13

Background information in LOGSTASH-180 jira ticket in particular in this comment

Also solution proposal in #769

wiibaa avatar Jun 23 '14 12:06 wiibaa

where are these pattern names like "ISO8601" defined?

bpesics avatar Jul 23 '14 12:07 bpesics

@bpesics I suppose you seek the definition in logstash grok patterns that allows either a space or a T

https://github.com/elasticsearch/logstash/blob/master/patterns/grok-patterns#L68

otherwise you need to know that the date filter internally use jodatime, and have a look to http://joda-time.sourceforge.net/cal_iso.html

HTH

wiibaa avatar Jul 23 '14 12:07 wiibaa

or simply the documentation of the date filter match config http://logstash.net/docs/1.4.2/filters/date#match

wiibaa avatar Jul 23 '14 12:07 wiibaa

thanks, i've seen that just overlooked it ;-)

On Wed, Jul 23, 2014 at 1:10 PM, Wiibaa [email protected] wrote:

or simply the documentation of the date filter *match config * http://logstash.net/docs/1.4.2/filters/date#match

— Reply to this email directly or view it on GitHub https://github.com/elasticsearch/logstash/issues/1464#issuecomment-49865123 .

bpesics avatar Jul 23 '14 14:07 bpesics

It's rough that the date filter fails silently. grok adds a _grokparsefailure tag when it fails - Could the date similarly add a _dateparsefailure when the date fails to parse?

edit - added #1615 rather than continuing to threadjack this issue.

chris-martin avatar Aug 08 '14 00:08 chris-martin

Closed via https://github.com/elasticsearch/logstash/pull/769

suyograo avatar Dec 14 '14 02:12 suyograo

Seems the pattern accepts a comma separator before fractions of a second, but ISO1806 match does not. Had to explicitly use "YYYY-MM-dd HH:mm:ss,SSS" as my match. Using logstash 1.5.4

Vlad777 avatar Aug 28 '15 19:08 Vlad777

Sorry, but why is this closed? The date filter still doesn't accept a comma between the time element and its fraction when using "ISO8601" (https://en.wikipedia.org/wiki/ISO_8601#cite_ref-15). Or are you saying the Yoda implementation is wrong and you can do nothing about this?

rawbertl avatar Oct 20 '15 07:10 rawbertl

@rawbertp from a quick look to joda, it should be accepting either dot or comma but it enforces the use of 'T' and reject the space, please upvote https://github.com/logstash-plugins/logstash-filter-date/issues/32 and manually define your date pattern in the date filter configuration as a workaround

wiibaa avatar Oct 20 '15 07:10 wiibaa