# Date Filtering from a Text File

**URL:** <https://discuss.elastic.co/t/date-filtering-from-a-text-file/57895>\
**Category:** Logstash\
**Created:** [August 12, 2016, 7:54am UTC](https://discuss.elastic.co/t/date-filtering-from-a-text-file/57895 "2016-08-12T07:54:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ash.vaidya94](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@ash.vaidya94](https://discuss.elastic.co/u/ash.vaidya94)\
**Post date:** [August 12, 2016, 7:54am UTC](https://discuss.elastic.co/t/date-filtering-from-a-text-file/57895/1 "2016-08-12T07:54:58Z")

</div>

Hi,

My text file reads something like -

03 Aug 2016 05:55:38,759|INFO |snjcprddex36|DataElt|||||03 Aug 2016 05:55:38,759|INFO |snjcprddex36|DataElt|||||OUT\_OF\_SCOPE

Is there any way I can manually filter the date and time and create a separate field?

Thanks

---

<div class="post-metadata">

**Author:** ![purbon](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@purbon](https://discuss.elastic.co/u/purbon)\
**Post date:** [August 12, 2016, 8:16am UTC](https://discuss.elastic.co/t/date-filtering-from-a-text-file/57895/2 "2016-08-12T08:16:27Z")

</div>

HI,  
yes, in logstash you can use this collection of filters to get what you aim for:

1. Use the [split](https://www.elastic.co/guide/en/logstash/current/plugins-filters-split.html) filter to break you line in fields, your delimiter here is clearly the `|` character, isn't?
2. After that you have an event with multiple fields, one per each bucket result of the splitting.
3. Now you can use the [date](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html) filter with the datetime field and parse them.

For exact documentation I've link each filter documentation for you.

Hope it helps,

- purbon

---

<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:** [August 12, 2016, 10:46am UTC](https://discuss.elastic.co/t/date-filtering-from-a-text-file/57895/3 "2016-08-12T10:46:47Z")

</div>

It's not entirely clear to me if the example above is a single line that should be split into multiple events, a single line with a single event, or two lines that should result in two events.

> Use the split filter to break you line in fields, your delimiter here is clearly the | character, isn't?

The split filter splits a field into multiple events. You probably meant the mutate filter's split option, but I think the csv filter would be a better match.

---

<div class="post-metadata">

**Author:** ![purbon](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@purbon](https://discuss.elastic.co/u/purbon)\
**Post date:** [August 12, 2016, 11:22am UTC](https://discuss.elastic.co/t/date-filtering-from-a-text-file/57895/4 "2016-08-12T11:22:29Z")

</div>

@magnusbaeck you're right, the event line is a bit confusing, I agree using CSV filter here will work, apologies if the message has understood as misleading.

---

<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:43am UTC](https://discuss.elastic.co/t/date-filtering-from-a-text-file/57895/5 "2017-07-06T04:43:42Z")

</div>


