# Time without a date field

**URL:** <https://discuss.elastic.co/t/time-without-a-date-field/27282>\
**Category:** Logstash\
**Created:** [August 12, 2015, 6:25pm UTC](https://discuss.elastic.co/t/time-without-a-date-field/27282 "2015-08-12T18:25:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaellizhou](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellizhou/32/4143_2.png) [@michaellizhou](https://discuss.elastic.co/u/michaellizhou)\
**Post date:** [August 12, 2015, 6:25pm UTC](https://discuss.elastic.co/t/time-without-a-date-field/27282/1 "2015-08-12T18:25:28Z")

</div>

I have logs that only have a time field i.e. HH:mm:ss.SSS but for some reason there are no dates! I want to include today's date to this field called logstoretime. Because if I do not specify a date filter the time difference from when log gets shipped to when it is processed is to large of a gap ~10minutes. So essentially I want it to log by depending on the day it will pull that date and use my HH:mm:ss.SSS

Anyone with this experience?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 12, 2015, 11:53pm UTC](https://discuss.elastic.co/t/time-without-a-date-field/27282/2 "2015-08-12T23:53:27Z")

</div>

You can do this with a [date filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html), eg;

```auto
date {
  match => ["logstoretime", "HH:mm:ss.SSS"]
}

```

---

<div class="post-metadata">

**Author:** ![michaellizhou](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellizhou/32/4143_2.png) [@michaellizhou](https://discuss.elastic.co/u/michaellizhou)\
**Post date:** [August 13, 2015, 12:01am UTC](https://discuss.elastic.co/t/time-without-a-date-field/27282/3 "2015-08-13T00:01:58Z")

</div>

Yup figured an easy way out ( had this problem earlier in a post...but its time to really fix this issue)

what you can do is add a field

```
 add_field => {"logdate" => "%{+YYYY-MM-dd}"}

```

I can merge the 2 fields so now the issue is how do I would use a date filter. Because now my issue is when I merge the two fields it becomes an array. What I know from date filter it does not play nicely with arrays. So need to cleanly add this date without turning into a messy array or try and append this field to logstoretime.

Thanks.  
M

Some extra details on what it will look like

> ```
> "logdate" => [
> [0] "2015-08-12",
> [1] "07:46:18,960"
> ]
> 
> ```

> ```
> "@timestamp" => "1970-01-01T07:46:18.960Z",
> 
> ```

---

<div class="post-metadata">

**Author:** ![Vesela\_Houba](https://avatars.discourse-cdn.com/v4/letter/v/da6949/32.png) [@Vesela\_Houba](https://discuss.elastic.co/u/Vesela_Houba)\
**Post date:** [October 5, 2016, 11:02am UTC](https://discuss.elastic.co/t/time-without-a-date-field/27282/4 "2016-10-05T11:02:21Z")

</div>

If anyone hits this thread, this is what I'm currently using

> ...  
> mutate {
> 
> # this will only work on logs created the same day as read
> 
> add\_field =\> {"logdate" =\> "%{+YYYY-MM-dd}"}
> 
> # merge with existing time field
> 
> add\_field =\> {"App\_timestamp2" =\> "%{logdate}\_%{App\_timestamp}"}  
> }  
> date {  
> match =\> ["App\_timestamp2", "YYYY-MM-dd\_HH:mm:ss.SSS"]  
> timezone =\> "America/Chicago"
> 
> # remove temporary date\_time field
> 
> remove\_field =\> ["logdate","App\_timestamp2"]  
> }  
> ...

---

<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, 4:35am UTC](https://discuss.elastic.co/t/time-without-a-date-field/27282/5 "2017-07-06T04:35:41Z")

</div>


