# Simple Logstash Date Filter

**URL:** <https://discuss.elastic.co/t/simple-logstash-date-filter/134084>\
**Category:** Logstash\
**Created:** [May 31, 2018, 4:03pm UTC](https://discuss.elastic.co/t/simple-logstash-date-filter/134084 "2018-05-31T16:03:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AloysiusParedes](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@AloysiusParedes](https://discuss.elastic.co/u/AloysiusParedes)\
**Post date:** [May 31, 2018, 4:03pm UTC](https://discuss.elastic.co/t/simple-logstash-date-filter/134084/1 "2018-05-31T16:03:27Z")

</div>

I am parsing JSON, and one of my fields are:

> ```
> "myDateTime":"20180510T042139.680 GMT"
> 
> ```

Here is my Logstash Config:

> ```
> input{
> file{
> type => "test"
> codec => json{ }
> path => "/home/my-dev/Documents/test/*.json"
> start_position => "beginning"
> sincedb_path => "/dev/null"
> close_older => 60
> max_open_files => 1000
> }
> }
> 
> filter{
> json{ source => "message" }
> if [type] == "test" {
> date{ match => ["myDateTime","yyyyMMdd'T'HHmmss.SSS ZZZ"] }
> }
> }
> 
> output{
> if [type] == "test" {
> stdout{ codec => rubydebug }
> elasticsearch{ 
> hosts => ["127.0.0.1:9200"]
> index => "test"
> codec => json
> }
> }
> }
> 
> ```

This is my Logstash stdout:

> ```
> May 31 11:20:51 my-VirtualBox logstash[15734]: Sending Logstash's logs to /var/log/logstash which is now configured via log4j2.properties
> May 31 11:21:02 my-VirtualBox logstash[15734]: {
> May 31 11:21:02 my-VirtualBox logstash[15734]: "AccountCode" => "BASIC",
> May 31 11:21:02 my-VirtualBox logstash[15734]: "myDateTime" => "20180510T042139.680 GMT",
> May 31 11:21:02 my-VirtualBox logstash[15734]: "@version" => "1",
> May 31 11:21:02 my-VirtualBox logstash[15734]: "type" => "test",
> May 31 11:21:02 my-VirtualBox logstash[15734]: "host" => "prismdev-VirtualBox",
> May 31 11:21:02 my-VirtualBox logstash[15734]: "path" => "/home/my-dev/Documents/test/test.json",
> May 31 11:21:02 my-VirtualBox logstash[15734]: "@timestamp" => 2018-05-10T04:21:39.680Z
> May 31 11:21:02 my-VirtualBox logstash[15734]: }
> 
> ```

But when I go to Kibana, I can only see @timestamp for a Time Filter when creating my Index Pattern. Any ideas on what I am doing wrong?

---

<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:** [May 31, 2018, 4:44pm UTC](https://discuss.elastic.co/t/simple-logstash-date-filter/134084/2 "2018-05-31T16:44:34Z")

</div>

> [@AloysiusParedes](#):
>
> But when I go to Kibana, I can only see @timestamp for a Time Filter when creating my Index Pattern.

That is to be expected. The date filter successfully parses the myDateTime field and puts the result in @timestamp.

---

<div class="post-metadata">

**Author:** ![AloysiusParedes](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@AloysiusParedes](https://discuss.elastic.co/u/AloysiusParedes)\
**Post date:** [May 31, 2018, 5:06pm UTC](https://discuss.elastic.co/t/simple-logstash-date-filter/134084/3 "2018-05-31T17:06:30Z")

</div>

right, but Kibana doesn't recognize the "myDateTime" field as a date type of field, it is still a "string" rather than a "date".

---

<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:** [May 31, 2018, 5:15pm UTC](https://discuss.elastic.co/t/simple-logstash-date-filter/134084/4 "2018-05-31T17:15:09Z")

</div>

Right, myDateTime is not a date. It is a string. You could use the target option on the date filter to overwrite myDateTime with a date, which (in a new index) should be a date.

---

<div class="post-metadata">

**Author:** ![AloysiusParedes](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@AloysiusParedes](https://discuss.elastic.co/u/AloysiusParedes)\
**Post date:** [May 31, 2018, 5:19pm UTC](https://discuss.elastic.co/t/simple-logstash-date-filter/134084/5 "2018-05-31T17:19:19Z")

</div>

That fixed it! Thanks 🙂

---

<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:** [June 28, 2018, 5:19pm UTC](https://discuss.elastic.co/t/simple-logstash-date-filter/134084/6 "2018-06-28T17:19:23Z")

</div>

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