timefield is a date_time field and is mapped like that in elasticsearch without any problem. As you can see, I am trying to assign it to @timestamp using date filter, and it creates a _dateparsefailure. I have provided ISO8601 as described in the doc. I have also tried yyyy-MM-ddTHH:mm:ss.SSSZ, but it also creates error like [FATAL][logstash.runner ] An unexpected error occurred!.
@elasticheart, I don't see any problems with the configuration of your date filter. I set up a test case that eliminates the jdbc input since that should not affect the date parsing:
As you are using data from the JDBC input, that field is possibly already a date and not a string, which is what the date field expects. If you output the event to stdout with a rubydebug codec you should be able to see if it is printed surrounded by ", which I believe would indicate it is a string.
@danhermann there wont be any problem with your example, since you are creating a string field. In my case, the field is already a date field, and I want to assign it to @timestamp.
One option might be to modify your SQL to read it out as a correctly formatted string. If you need to process it using a date filter, e.g. to change timezone, you may want to add it as a string field and the run the date filter based on that.
@danhermann it works! But could you kindly tell me which one had good performance and utilize less CPU. A) Querying my timefield as string (using to_char of oracle) and using date filter, or B) using mutate filter?
@Christian_Dahlqvist I agree. But could you kindly tell me which one had good performance and utilize less CPU. A) Querying my timefield as string (using to_char of oracle) and using date filter, or B) using mutate filter? There is no need to change timezone because everything is in GMT.
I do not know. From a Logstash perspective reading it out as a correctly formatted string requires less processing, but that instead requires your database to do that work. In all I would expect this to have little impact on throughput.
@elasticheart, retrieving the date from the database as a date and just copying it to a new field is faster than converting from the string representation to a date although the performance difference between the two is pretty small.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.