How to convert format "yyyy-MM-dd HH:mm:ss in logstash?

I fetch the data through Oracle, and the database has a field updated_at in the format "yyyy-MM-dd HH:mm:ss". However, it has been automatically changed to ISO8601 format in logstash. So I try to change the format "yyyy-MM-dd HH:mm:ss", but I get an error like _dateparsefailure. Here is my config file. What is the problem?

input {
   jdbc {
        jdbc_validate_connection => true
        jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/ojdbc8.jar"
        jdbc_driver_class => "Java::oracle.jdbc.OracleDriver"
        jdbc_connection_string => <connection string>
        jdbc_user => <my username>
        jdbc_password => <my password>
        use_column_value => true
        statement => "SELECT * FROM IP_INFO"
        schedule => "*/1 * * * *"
        charset => "UTF-8"
        enable_metric => false


filter {
    date {
        match => [
            "updated_at", "yyyy-MM-dd HH:mm:ss"
        target => "updated_at"

output {
  stdout {
    codec => rubydebug


    "@timestamp" => 2020-10-14T07:34:03.755Z,
    "updated_at" => 2020-10-14T04:44:37.000Z,
    "tags" => [
        [0] "_dateparsefailure"
    "created_at" => 2020-09-29T15:56:37.000Z

So, I just convert updated_at and created_at field to "yyyy-MM-dd HH:mm:ss". Can you help me?

Note that the field does not have quotes around it. It is not a string, it is converted to a Logstash::Timestamp object by the jdbc filter. A date filter only parses strings, it produces Logstash::Timestamp objects, it cannot parse them.

Since you want a timestamp in the end you can just delete the date filter. If you wanted to keep it as a string you could use mutate+convert to switch it back to a string. If you wanted a string with a different format you would use a ruby filter and strftime.

thank you

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.