# Config very repetitive, possible to be more DRY?

**URL:** <https://discuss.elastic.co/t/config-very-repetitive-possible-to-be-more-dry/221088>\
**Category:** Logstash\
**Created:** [February 26, 2020, 5:41pm UTC](https://discuss.elastic.co/t/config-very-repetitive-possible-to-be-more-dry/221088 "2020-02-26T17:41:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![McPo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mcpo/32/63196_2.png) [@McPo](https://discuss.elastic.co/u/McPo)\
**Post date:** [February 26, 2020, 5:41pm UTC](https://discuss.elastic.co/t/config-very-repetitive-possible-to-be-more-dry/221088/1 "2020-02-26T17:41:53Z")

</div>

Hi, I have noticed that logstash config appears to be very repetitive, for example we make use of "jdbc\_streaming" filter 21 times. This result in having to define jdbc\_user, jdbc\_password, jdbc\_driver\_class, jdbc\_driver\_library, jdbc\_connection\_string 21 times over, despite being the same each time.

Is there some way to define a base block/macro/template, and then extend/modify it each time in use. i.e

```
template {
    name => "my_jdbc_streaming"
    jdbc_streaming {
        jdbc_user => "xxx"
        jdbc_password => "xxx"
        jdbc_driver_class => "Java::com.mysql.jdbc.Driver"
        jdbc_driver_library => "/usr/share/java/mysql-connector-java.jar"
        jdbc_connection_string => "xxx"
    }
}

filter {
    my_jdbc_streaming {
        statement => "yyy"
		parameters => { "yyy" => "yyy" }
        target => "yyy"
        add_field => { "yyy" => "yyy" }
        remove_field => ["yyy"]
    }
    my_jdbc_streaming {
        statement => "xxx"
		parameters => { "xxx" => "xxx" }
        target => "xxx"
        add_field => { "xxx" => "xxx" }
        remove_field => ["xxx"]
    }
}

```

While I am showing jdbc\_streaming as an example, I am also interested in a general solution. Is there any way to create you own template filter or function (Without creating a full blown Java plugin).

On a side note, I assume there is no way do to a break or continue (so you can have multiple conf files, but ensure a conf file only works one type of event) i.e

```
filter {
	if [@metadata][component] != "component-x" {
		break
	}
	....
}

```

Im aware I could place the rest of the code (...) into the if statement and make it an equals comparison, however it would mean the code in the rest of the filter would "have" to be indented and I would prefer to avoid it. (This is a very minor issue, just wanted to gather any other solution). I attempted to use drop(), but that drops the event across all files (which I dont want).

Thank you,  
Emmet

---

<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 25, 2020, 5:41pm UTC](https://discuss.elastic.co/t/config-very-repetitive-possible-to-be-more-dry/221088/2 "2020-03-25T17:41:54Z")

</div>

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