# Forward only ERROR or Warn log lines to Splunk

**URL:** <https://discuss.elastic.co/t/forward-only-error-or-warn-log-lines-to-splunk/232561>\
**Category:** Logstash\
**Created:** [May 14, 2020, 6:36am UTC](https://discuss.elastic.co/t/forward-only-error-or-warn-log-lines-to-splunk/232561 "2020-05-14T06:36:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shivhare](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Shivhare](https://discuss.elastic.co/u/Shivhare)\
**Post date:** [May 14, 2020, 6:36am UTC](https://discuss.elastic.co/t/forward-only-error-or-warn-log-lines-to-splunk/232561/1 "2020-05-14T06:36:43Z")

</div>

Need your expert advise on how can I configure my logstash.conf file to forward only the ERROR OR WARN log lines to Splunk. I have done some online research that a grok filter or wrapping the output with if condition can be used in order the acheive the required result.

I prefer not to send the data with INFO OR DEBUG logging levels to Splunk, therefore, looking forward to getting some clean solution to implement it in logstash config file to control the data which is sent to Splunk.

Please advise how logstash.conf should be updated to achieve the required result.

I would appreciate if you could share a working example on the same.

Many thanks!

---

<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:** [May 14, 2020, 7:08am UTC](https://discuss.elastic.co/t/forward-only-error-or-warn-log-lines-to-splunk/232561/2 "2020-05-14T07:08:24Z")

</div>

Costing a bit too much is it 😉

If you have a field that you've extracted with grok, you can then use a drop filter with a conditional to drop the non error or warning logs. What that looks like depends on your log format.

---

<div class="post-metadata">

**Author:** ![Shivhare](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Shivhare](https://discuss.elastic.co/u/Shivhare)\
**Post date:** [May 14, 2020, 7:25am UTC](https://discuss.elastic.co/t/forward-only-error-or-warn-log-lines-to-splunk/232561/3 "2020-05-14T07:25:21Z")

</div>

Exactly, the cost is insane. 🙂

Ok, thank you very much for your help. I will check. Would it be possible without grok? Please can you advise if the below will work.

If [level] =="ERROR OR [level]=="WARN" {

Output { ----  
}

}

I am not clear on the keyword level here, is that already defined in logstash?

Thanks!

---

<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:** [May 14, 2020, 8:13am UTC](https://discuss.elastic.co/t/forward-only-error-or-warn-log-lines-to-splunk/232561/4 "2020-05-14T08:13:17Z")

</div>

If the `level` field is not separate to Logstash, it wont be able to do this without grok.

Don't forget you can put all this in Elasticsearch too!

---

<div class="post-metadata">

**Author:** ![Shivhare](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Shivhare](https://discuss.elastic.co/u/Shivhare)\
**Post date:** [May 14, 2020, 8:27am UTC](https://discuss.elastic.co/t/forward-only-error-or-warn-log-lines-to-splunk/232561/5 "2020-05-14T08:27:59Z")

</div>

Thanks Mark! Much appreciated.

---

<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:** [June 11, 2020, 8:30am UTC](https://discuss.elastic.co/t/forward-only-error-or-warn-log-lines-to-splunk/232561/6 "2020-06-11T08:30:35Z")

</div>

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