# Remove blank fields from output file

**URL:** <https://discuss.elastic.co/t/remove-blank-fields-from-output-file/75886>\
**Category:** Logstash\
**Created:** [February 21, 2017, 1:30pm UTC](https://discuss.elastic.co/t/remove-blank-fields-from-output-file/75886 "2017-02-21T13:30:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarun\_Kalluri](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@Tarun\_Kalluri](https://discuss.elastic.co/u/Tarun_Kalluri)\
**Post date:** [February 21, 2017, 1:30pm UTC](https://discuss.elastic.co/t/remove-blank-fields-from-output-file/75886/1 "2017-02-21T13:30:42Z")

</div>

I am pretty new to using log stash, so I need to know how to remove a line which does not match the grok pattern completely from the output. I have a 500 line input out of which 4-5 lines match my pattern. Presently, it shows brackets with empty contents for all lines which do not match the pattern and valid entries are sparse in between. I am using rubydebug or json output, no luck trying drop filter or conditionals.

---

<div class="post-metadata">

**Author:** ![lueneburger](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@lueneburger](https://discuss.elastic.co/u/lueneburger)\
**Post date:** [February 21, 2017, 4:40pm UTC](https://discuss.elastic.co/t/remove-blank-fields-from-output-file/75886/2 "2017-02-21T16:40:44Z")

</div>

Hi @Tarun_Kalluri

not sure if you can drop empty lines within logstash, but you could work with IF

what kind of events? syslogs?

SYSLOGBASE is a grok pattern  
`SYSLOGBASE %{SYSLOGTIMESTAMP:timestamp} (?:%{SYSLOGFACILITY} )?%{SYSLOGHOST:logsource} %{SYSLOGPROG}:`

```
grok {
		match => ["message", "%{SYSLOGBASE} %{GREEDYDATA:message}"]
		overwrite => ["message"]
		}

IF [program] =~ /^name$/ {
    grok {
          filter....
          }
}

```

at the out you doing the same with IF to only sending the logs you need to ES.

---

<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:** [February 22, 2017, 6:40am UTC](https://discuss.elastic.co/t/remove-blank-fields-from-output-file/75886/3 "2017-02-22T06:40:49Z")

</div>

> I need to know how to remove a line which does not match the grok pattern completely from the output.

```plaintext
filter {
  if "_grokparsefailure" in [tags] {
    drop { }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Tarun\_Kalluri](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@Tarun\_Kalluri](https://discuss.elastic.co/u/Tarun_Kalluri)\
**Post date:** [February 22, 2017, 9:05am UTC](https://discuss.elastic.co/t/remove-blank-fields-from-output-file/75886/5 "2017-02-22T09:05:49Z")

</div>

This is it. I had removed the "tags" field from the output, so "\_grokparsefailure" did not come to me. Thanks nevertheless.

---

<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:** [March 22, 2017, 9:06am UTC](https://discuss.elastic.co/t/remove-blank-fields-from-output-file/75886/6 "2017-03-22T09:06:17Z")

</div>

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