# Logstash: Filter out the service to file

**URL:** <https://discuss.elastic.co/t/logstash-filter-out-the-service-to-file/128136>\
**Category:** Logstash\
**Created:** [April 16, 2018, 8:46am UTC](https://discuss.elastic.co/t/logstash-filter-out-the-service-to-file/128136 "2018-04-16T08:46:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawad846](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@jawad846](https://discuss.elastic.co/u/jawad846)\
**Post date:** [April 16, 2018, 8:46am UTC](https://discuss.elastic.co/t/logstash-filter-out-the-service-to-file/128136/1 "2018-04-16T08:46:19Z")

</div>

Hi folks,

I just want to filter out only apache and MySQL logs from the logstash output,  
I had configured the pipeline.conf file its not working.

please suggest me to solve this

```
# INPUT HERE
input {
beats {
        port => 5044
}
}
# FILTER HERE
filter{
if [source]=="/var/log/apache2/error.log"
{
mutate {
         add_tag => ["apache_logs"]
 }
}
}
# OUTPUT HERE
output {
   if "apache_logs" in [tags] {
            file {
           path => "/home/ubuntu/apache.log"
   }
  }
}

```

@magnusbaeck

---

<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:** [April 16, 2018, 8:48am UTC](https://discuss.elastic.co/t/logstash-filter-out-the-service-to-file/128136/2 "2018-04-16T08:48:06Z")

</div>

Use a `stdout { codec => { rubydebug }` output to dump an example event so we can see what it looks like.

---

<div class="post-metadata">

**Author:** ![jawad846](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@jawad846](https://discuss.elastic.co/u/jawad846)\
**Post date:** [April 16, 2018, 8:56am UTC](https://discuss.elastic.co/t/logstash-filter-out-the-service-to-file/128136/3 "2018-04-16T08:56:22Z")

</div>

> [@magnusbaeck](#):
>
> stdout { codec =\> { rubydebug }

its not working, i need to put in separate file

@magnusbaeck

---

<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:** [April 16, 2018, 11:26am UTC](https://discuss.elastic.co/t/logstash-filter-out-the-service-to-file/128136/4 "2018-04-16T11:26:02Z")

</div>

> its not working, i need to put in separate file

I don't understand what you mean.

---

<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:** [May 14, 2018, 11:26am UTC](https://discuss.elastic.co/t/logstash-filter-out-the-service-to-file/128136/5 "2018-05-14T11:26:05Z")

</div>

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