LOGSTASH-INPUT-JDBC take MySQL data date format processing

Source: Internet
Author: User
Tags logstash

Use Logstash to fetch a datetime type number from MySQL. In stdout view the data JSON format takes a field value similar to 2018-03-23T04:18:33.000Z, because you want to use this field as a @timestamp, use the date of Logstash to match.

    date {      match => ["start_time","ISO8601"]    }

But the actual discovery of each document will be accompanied [_dataparserfail] by a label, Miss no Sister
Google after a while finally understand, Link: HTTPS://DISCUSS.ELASTIC.CO/T/TROUBLE-MATCHING-TIMESTAMP/83768/4

Because the data from MySQL Start_time is already a time data type, then use date to deal with the natural failure, if you want to use this field as a @timestamp, the solution for foreigners is as follows:
In your SQL query, typecast the timestamp as a string.
Use a mutate filter's convert option to typecast the field to a string prior to the date filter.
Use a mutate filter to copy the timestamp into @timestamp and overwrite the existing value (with the Replace option).

I use the method:

    mutate {      add_field => {"temp_ts" => "%{start_time}"}    }    date {      match => ["temp_ts","ISO8601"]      remove_field => ["temp_ts"]    }

LOGSTASH-INPUT-JDBC take MySQL data date format processing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.