# Replacing @timestamp with custom date

**URL:** <https://discuss.elastic.co/t/replacing-timestamp-with-custom-date/111781>\
**Category:** Logstash\
**Created:** [December 14, 2017, 1:52pm UTC](https://discuss.elastic.co/t/replacing-timestamp-with-custom-date/111781 "2017-12-14T13:52:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![munjadd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/munjadd/32/25574_2.png) [@munjadd](https://discuss.elastic.co/u/munjadd)\
**Post date:** [December 14, 2017, 1:52pm UTC](https://discuss.elastic.co/t/replacing-timestamp-with-custom-date/111781/1 "2017-12-14T13:52:51Z")

</div>

Hi,

I am using filebeat to send lines from a dhcp log (from windows server dhcp), and i am trying to replace the @timestamp field. Here is an example line from the dhcp log file:

`11,12/14/17,14:22:04,Renew,10.1.65.60,pcname.domain.com,00A0D4645F14,,3853582496,0,,,,0x4D53465420352E30,MSFT 5.0,,,,0`

Using this filter:

```
filter {
 if [type] == "dhcp" {
  grok {
    patterns_dir => "/etc/logstash/conf.d/patterns"
    match => { "message" => "%{NUMBER:dhcpevent},%{DHCPDATE:timestamp},%{WORD:dhcpaction},%{IP:clientip},%{DATA:hostname},%{WORD:macaddress}" }
  }
  #turn timestamp from grok into @timestamp
  date {
    match => ["timestamp", "dd/MM/yy,HH:mm:ss"]
    target => "@timestamp"
  }
 }
}

```

And this grok pattern: DHCPDATE %{MONTHNUM}/%{MONTHDAY}/%{YEAR},%{TIME}

But it is not working, here is the rubydebug output:

```
{
        "offset" => 1935569,
    "input_type" => "log",
     "dhcpevent" => "11",
        "source" => "C:\\Windows\\System32\\dhcp\\DhcpSrvLog-Thu.log",
       "message" => "11,12/14/17,14:22:04,Renew,10.1.65.60,pcname.domain.com,00A0D4645F14,,3853582496,0,,,,0x4D53465420352E30,MSFT 5.0,,,,0",
          "type" => "dhcp",
          "tags" => [
        [0] "beats_input_codec_plain_applied",
        [1] "_dateparsefailure"
    ],
      "hostname" => "pcname.domain.com",
    "@timestamp" => 2017-12-14T13:23:02.140Z,
      "clientip" => "192.168.5.60",
      "@version" => "1",
          "beat" => {
        "hostname" => "somehostname",
            "name" => "somehostname",
         "version" => "5.4.0"
    },
          "host" => "somehostname",
    "macaddress" => "00A0D4645F14",
    "dhcpaction" => "Renew",
     "timestamp" => "12/14/17,14:22:04"
}

```

What am i doing wrong?

---

<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:** [December 14, 2017, 3:09pm UTC](https://discuss.elastic.co/t/replacing-timestamp-with-custom-date/111781/2 "2017-12-14T15:09:29Z")

</div>

Your date format is MM/dd/yyyy, not dd/MM/yyyy.

---

<div class="post-metadata">

**Author:** ![munjadd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/munjadd/32/25574_2.png) [@munjadd](https://discuss.elastic.co/u/munjadd)\
**Post date:** [December 14, 2017, 4:05pm UTC](https://discuss.elastic.co/t/replacing-timestamp-with-custom-date/111781/3 "2017-12-14T16:05:18Z")

</div>

You are right, after changing the format it works. Can't believe i missed this...

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 11, 2018, 4:05pm UTC](https://discuss.elastic.co/t/replacing-timestamp-with-custom-date/111781/4 "2018-01-11T16:05:24Z")

</div>

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