# Datetime from MySQL via JDBC --\> @timestamp assignment fails with \_dateparsefailure

**URL:** https://discuss.elastic.co/t/datetime-from-mysql-via-jdbc-timestamp-assignment-fails-with-dateparsefailure/211531
**Category:** Logstash
**Created:** [December 11, 2019, 10:04pm UTC](https://discuss.elastic.co/t/datetime-from-mysql-via-jdbc-timestamp-assignment-fails-with-dateparsefailure/211531 "2019-12-11T22:04:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Chris1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris1234/32/59224_2.png) [@Chris1234](https://discuss.elastic.co/u/Chris1234)
#### Post date: [December 11, 2019, 10:04pm UTC](https://discuss.elastic.co/t/datetime-from-mysql-via-jdbc-timestamp-assignment-fails-with-dateparsefailure/211531/1 "2019-12-11T22:04:18Z")

</div>

I'm using the jdbc plugin to grab table data from a MySQL database. One of the fields in the MySQL database ("created\_at") is of type DATETIME which I need to assign to the @timestamp.

Here's part of my logstash.conf:

```
filter {
    date {
        match => [ "created_at","yyyy-MM-dd HH:mm:ss.SSSZ",
                                "yyyy-MM-dd HH:mm:ss.SSS",
                                "yyyy-MM-dd HH:mm:ss",
                                "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
                                "yyyy-MM-dd'T'HH:mm:ss.SSS",
                                "yyyy-MM-dd'T'HH:mm:ss",
                                "ISO8601",
                                "UNIX_MS",
                                "UNIX" ]
        add_field => { "debug" => "timestampMatched"}
        }
    }

```

Here's output (using rubydebug):

```
{
         "user_id" => 563,
      "created_at" => 2017-10-11T21:34:07.000Z,
      "spent_time" => 10,
        "@version" => "1",
      "@timestamp" => 2019-12-11T21:40:19.200Z,
            "tags" => [
        [0] "_dateparsefailure"
    ],
              "id" => 1415
}

```

There are no errors or exceptions in the log file.

If I test this config using echo + command line:

```
echo '2017-10-11T21:34:07.000Z' | logstash -f logstash.conf

```

.... I get the expected response (@timestamp is set to incoming time):

```
{
    "@timestamp" => 2017-10-11T21:34:07.000Z,
         "debug" => "timestampMatched",
      "@version" => "1",
          "host" => "Xxxxxx.local",
       "message" => "2017-10-11T21:34:07.000Z"
}

```

All the other variations work, too, using the command line.

I've run with the '_--debug --config.debug=true_' flags but still I see no exceptions or errors to aid in debugging.

I'm using "logstash.version"=\>"6.5.4"

How can peel back the layers to see what's going on?  
How can I debug this further?

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [December 11, 2019, 10:23pm UTC](https://discuss.elastic.co/t/datetime-from-mysql-via-jdbc-timestamp-assignment-fails-with-dateparsefailure/211531/2 "2019-12-11T22:23:41Z")

</div>

> [@Chris1234](#):
>
> "created\_at" =\> 2017-10-11T21:34:07.000Z,

That is already a LogStash::Timestamp (you can tell because there are no quotes around the value), and a date filter [cannot](https://github.com/logstash-plugins/logstash-filter-date/issues/95) parse that. Basically the jdbc plugin already did the conversion for you.

---

<div class="post-metadata">

### Author: ![Chris1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris1234/32/59224_2.png) [@Chris1234](https://discuss.elastic.co/u/Chris1234)
#### Post date: [December 11, 2019, 10:37pm UTC](https://discuss.elastic.co/t/datetime-from-mysql-via-jdbc-timestamp-assignment-fails-with-dateparsefailure/211531/4 "2019-12-11T22:37:28Z")

</div>

Ah, that's helpful and the link in your post gave me the fix I needed.

**The Answer**

Since, as Badger has explained, "created\_at" was already a LogStash::Timestamp and the date filter can't parse that (despite my lengthy list of parsing options), I need to turn the "created\_at" to a string so it can be parsed.

I added this part to my config, just above the date

```
mutate {
    convert => { "created_at" => "string"}
    }

```

That worked! The @timestamp now matches the passed-in "created\_at".

Thanks for the help!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 8, 2020, 10:37pm UTC](https://discuss.elastic.co/t/datetime-from-mysql-via-jdbc-timestamp-assignment-fails-with-dateparsefailure/211531/5 "2020-01-08T22:37:33Z")

</div>

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