# Replacing @timestamp with log timestamp

**URL:** <https://discuss.elastic.co/t/replacing-timestamp-with-log-timestamp/99354>\
**Category:** Logstash\
**Created:** [September 5, 2017, 3:26am UTC](https://discuss.elastic.co/t/replacing-timestamp-with-log-timestamp/99354 "2017-09-05T03:26:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scayzer65](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@scayzer65](https://discuss.elastic.co/u/scayzer65)\
**Post date:** [September 5, 2017, 3:26am UTC](https://discuss.elastic.co/t/replacing-timestamp-with-log-timestamp/99354/1 "2017-09-05T03:26:46Z")

</div>

Hi

I have a Windows FTP Server and the FTP application is producing real-time logs. I would like to replace the default @timestamp with the timestamp from the log. The message filter is working fine but when i add the date filter to replace the @timestamp everything falls in a heap.

I am a complete novice when it comes to Grok patterns so I am reaching out to anyone who can give me a bit of guidance and explain what I am doing wrong.

Sample FTP log

```
08 Aug 2017 00:00:05	Default Site	10.xxx.xxx.xxx userid	LogOut	

```

The following timestamp pattern and filter works when no date filter has been added.

```
FTP_STAMP %{MONTHDAY} %{MONTH} %{YEAR} %{HOUR}:%{MINUTE}:%{SECOND}

input{
    beats{
        port => "5043"
    }
}

filter {
    if [type] == "log" {
        grok {
            patterns_dir => ["/etc/logstash/patterns"]
            match => { "message" => "%{FTP_STAMP:ftpstamp}%{DATA:LOGLEVEL}%{IPV4:client}%{SPACE}%{USERNAME:userid}%{SPACE}%{GREEDYDATA:message}" }
        }
        date {
           match => ["ftpstamp" , "dd MMM yyyy HH:mm:ss"]
           target => "@timestamp"
        }
    }
}

output{
    elasticsearch {
        hosts => ["10.xxx.xxx.xxx:9200"]
        index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
        document_type => "%{[@metadata][type]}"
    }
}
```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 5, 2017, 5:50am UTC](https://discuss.elastic.co/t/replacing-timestamp-with-log-timestamp/99354/2 "2017-09-05T05:50:30Z")

</div>

Please show an example event produced by this configuration. Copy/paste from Kibana's JSON tab.

---

<div class="post-metadata">

**Author:** ![scayzer65](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@scayzer65](https://discuss.elastic.co/u/scayzer65)\
**Post date:** [September 9, 2017, 2:17am UTC](https://discuss.elastic.co/t/replacing-timestamp-with-log-timestamp/99354/3 "2017-09-09T02:17:24Z")

</div>

Hi

Sorry for the late reply but after a lot of head scratching I realised that the problem was not related to the grok pattern I submitted it was actually a fault with the Elasticsearch setup. It seemed that even simple grok patterns were failing to work that had previously been ok. I started from scratch by purging my setup from the server and re-installing Logstash, Elasticsearch and Kibana. I started filebeat on the windows server and added the filter I sent in the post and guess what? It worked.

Thanks once again

SC

---

<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:** [October 7, 2017, 2:17am UTC](https://discuss.elastic.co/t/replacing-timestamp-with-log-timestamp/99354/4 "2017-10-07T02:17:35Z")

</div>

Closed on October 7, 2017, 2:17am UTC

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