# Converting time into @timestamp

**URL:** https://discuss.elastic.co/t/converting-time-into-timestamp/32846
**Category:** Logstash
**Created:** [October 23, 2015, 11:28am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846 "2015-10-23T11:28:29Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![zappe](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zappe](https://discuss.elastic.co/u/zappe)
#### Post date: [October 23, 2015, 11:28am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/1 "2015-10-23T11:28:29Z")

</div>

I'm trying to get my time into @timestamp but are failing.

Lines looks like this "20151012 08:57:43 ..."

And I use the following config:

grok {  
match =\> { "message" =\> "(?\d{1,8}.\d{1,2}[:]?\d{1,2}[:]\d{1,2})%{SPACE}% ... }

```
  }

```

date {  
locale =\> "en"  
match =\> ["date", "YYYYMMdd HH:mm:ss"]  
}

I get no errors.  
Do I need to convert "date"?

---

<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: [October 23, 2015, 2:12pm UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/2 "2015-10-23T14:12:05Z")

</div>

Your date filter works fine:

```
$ cat test.config 
input { stdin {} }
output { stdout { codec => rubydebug } }
filter {
  date {
    match => ["message", "YYYYMMdd HH:mm:ss"]
  }
}
$ echo '20151012 08:57:43' | /opt/logstash/bin/logstash -f test.config
Logstash startup completed
{
       "message" => "20151012 08:57:43",
      "@version" => "1",
    "@timestamp" => "2015-10-12T06:57:43.000Z",
          "host" => "lnxolofon"
}
Logstash shutdown completed

```

Have you verified that the `date` field contains what you expect? Have you tried cranking up logging with `--verbose` or `--debug`?

---

<div class="post-metadata">

### Author: ![zappe](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zappe](https://discuss.elastic.co/u/zappe)
#### Post date: [October 26, 2015, 7:15am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/3 "2015-10-26T07:15:29Z")

</div>

Yes "date" field works. I can see that in Kibana.

So then I assume it's something I missed in the Kibana config?  
Should I start a new thread in that area?

---

<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: [October 26, 2015, 7:31am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/4 "2015-10-26T07:31:49Z")

</div>

Sorry, I don't get what the problem is. First you said that `@timestamp` isn't populated but now you say that the date filter works. To me that's contradictory.

---

<div class="post-metadata">

### Author: ![zappe](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zappe](https://discuss.elastic.co/u/zappe)
#### Post date: [October 26, 2015, 7:34am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/5 "2015-10-26T07:34:13Z")

</div>

It's not.  
The "date" field has the correct information, i.e. 20151012 08:57:43.  
But @timestamp is not populated correctly with that information when I see it Kibana, instead @timestamp has the date and time of when I imported the data.

---

<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: [October 26, 2015, 7:39am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/6 "2015-10-26T07:39:14Z")

</div>

Sorry, I misread. Okay, so `date` is okay and my previous example indicated that the date filter works with the input given and produces a `@timestamp` with the expected result. I suggest you try the same thing on your side, preferably with a `stdout { codec => rubydebug }` output. If that also works, inspect the resulting document directly in Elasticsearch. Somewhere along this chain you're going to find the problem.

---

<div class="post-metadata">

### Author: ![zappe](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zappe](https://discuss.elastic.co/u/zappe)
#### Post date: [October 26, 2015, 8:05am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/7 "2015-10-26T08:05:24Z")

</div>

No worries!  
I tried that and it gave me some strange output

"message" =\> "20151004 18:38:23 ...",  
"@timestamp" =\> "2015-01-04T17:38:23.000Z",  
"date" =\> "20151004 18:38:23",

How is that possible?

---

<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: [October 26, 2015, 8:45am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/8 "2015-10-26T08:45:02Z")

</div>

Your date pattern is wrong. I suspect you have "mm" instead of "MM" for the month. The one-hour difference in the time is because `@timestamp` is UTC and your timezone is UTC+1 (on Jan 4 anyway; on Oct 4 it's probably UTC+2).

---

<div class="post-metadata">

### Author: ![zappe](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zappe](https://discuss.elastic.co/u/zappe)
#### Post date: [October 26, 2015, 9:10am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/9 "2015-10-26T09:10:08Z")

</div>

Actually I had DD instead of dd.

Now it's all working.

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: [July 6, 2017, 5:25am UTC](https://discuss.elastic.co/t/converting-time-into-timestamp/32846/10 "2017-07-06T05:25:24Z")

</div>


