# Removing header in log file using logstash

**URL:** <https://discuss.elastic.co/t/removing-header-in-log-file-using-logstash/64675>\
**Category:** Logstash\
**Created:** [November 2, 2016, 6:49am UTC](https://discuss.elastic.co/t/removing-header-in-log-file-using-logstash/64675 "2016-11-02T06:49:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VijayKarthikeyan](https://avatars.discourse-cdn.com/v4/letter/v/8491ac/32.png) [@VijayKarthikeyan](https://discuss.elastic.co/u/VijayKarthikeyan)\
**Post date:** [November 2, 2016, 6:49am UTC](https://discuss.elastic.co/t/removing-header-in-log-file-using-logstash/64675/1 "2016-11-02T06:49:37Z")

</div>

Hi,

I have a log file which has a header as the first line to represent the log line's type. While parsing with logstash, it happened to parse the header along with the other log lines also but I need to remove the header as i dont want it to be indexed in Elasticsearch.

for example:

Level Date and Time Source Event ID Task Category

Information 10/27/2016 12:18:34 AM Microsoft-Windows-Security-Auditing 4689 Process Termination "A process has exited."

Error 10/27/2016 12:18:34 AM Microsoft-Windows-Security-Auditing 4699 Deadlock "A process has ended in error."

Here, the line that starts with "Level" is a header line. I have to remove this line while parsing.  
Please help me doing this.

There may be a possibility that I may have a log file without header also. How should I handler in that case?

Note: This is not a csv file which I am dealing with. It is a normal log file wherein fields are separated by spaces.

---

<div class="post-metadata">

**Author:** ![jsvd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsvd/32/6203_2.png) [@jsvd](https://discuss.elastic.co/u/jsvd)\
**Post date:** [November 2, 2016, 10:17am UTC](https://discuss.elastic.co/t/removing-header-in-log-file-using-logstash/64675/2 "2016-11-02T10:17:31Z")

</div>

you can either rely on grok as the first filter with the message format (which will tag the header as \_grokparsefailure because it doesn't match the line format), or use a conditional like:

```auto
if [message] =~ /^Level Date/ {
  drop {}
}

```

---

<div class="post-metadata">

**Author:** ![VijayKarthikeyan](https://avatars.discourse-cdn.com/v4/letter/v/8491ac/32.png) [@VijayKarthikeyan](https://discuss.elastic.co/u/VijayKarthikeyan)\
**Post date:** [November 4, 2016, 12:08pm UTC](https://discuss.elastic.co/t/removing-header-in-log-file-using-logstash/64675/3 "2016-11-04T12:08:01Z")

</div>

Thanks jsvd. I haven't tried it yet. But once I looked at it, I will let you know the result

---

<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:31am UTC](https://discuss.elastic.co/t/removing-header-in-log-file-using-logstash/64675/4 "2017-07-06T04:31:05Z")

</div>


