The datetime zone id is not recognised for pattern 'yyyy-MM-dd HH:mm:ss'


#1

Hi

I wanted to have one place for setting the time zone.

This code is working:

    date {
       match => ["file_time", "yyyy-MM-dd HH:mm:ss"]
       target => "@timestamp"
        timezone => "America/New_York"
    }

Then I changed it to

    mutate {
        add_field => ["mytimezone", "America/New_York"]
        }

    date {
       match => ["file_time", "yyyy-MM-dd HH:mm:ss"]
       target => "@timestamp"
       timezone => "%{mytimezone}"
       }

I got "Configuration OK" with --configtest.

But I get an error:
Error: Cannot register filter date plugin. The error reported is:
The datetime zone id '%{mytimezone}' is not recognised for pattern 'yyyy-MM-dd HH:mm:ss'
You may be interested in the '--configtest' flag which you can


(Magnus Bäck) #2

I suspect your date filter is too old. Support for %{field} references in the timezone option was added fairly recently.


#3

Hi
I upgraded to Logstash 2.3.3 and still it did not work. I got wrong results.


(Magnus Bäck) #4

If you're more specific I'll try to help. Do you get the same error message or what's happening?


(Alexey) #5

hello, I have the same issue with Logstash 5.3.0

logstash@f866296b6901:~/bin$ logstash --version
logstash 5.3.0

$ logstash-plugin list --verbose logstash-filter-date
logstash-filter-date (3.1.3)

logstash.conf is pretty simple

    filter {
    	date {
    		match  => [ "[@metadata][timestamp]" , "ISO8601" ]
    		timezone => "%{mytz}"
    	}
     }

When I star LS I receive:

[ERROR][logstash.agent ] Cannot load an invalid configuration {:reason=>"The datetime zone id '%{mytz}' is not recognised"}

It's strange that there was a PR for that https://github.com/logstash-plugins/logstash-filter-date/pull/31

--

It's a bug https://github.com/logstash-plugins/logstash-filter-date/issues/97


(Guy Boertje) #6

@azhukov
after PR 31 the date filter had a rewrite to add more Java and less ruby.
tz interpolation does not work when ISO8601 is specified - it should work for patterns though.

I am fixing the date filter as we speak.


(Guy Boertje) #7

version 2.3.4 has a version of the date filter that supports tz interpolation


(system) #8