# Importing Logstash configuration from another file

**URL:** https://discuss.elastic.co/t/importing-logstash-configuration-from-another-file/198056
**Category:** Logstash
**Created:** [September 4, 2019, 1:38pm UTC](https://discuss.elastic.co/t/importing-logstash-configuration-from-another-file/198056 "2019-09-04T13:38:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![corramatteo](https://avatars.discourse-cdn.com/v4/letter/c/a6a055/32.png) [@corramatteo](https://discuss.elastic.co/u/corramatteo)
#### Post date: [September 4, 2019, 1:38pm UTC](https://discuss.elastic.co/t/importing-logstash-configuration-from-another-file/198056/1 "2019-09-04T13:38:37Z")

</div>

Hi guys,  
I was wondering if it is possible to include a Logstash configuration from a file to another one.  
And if it is possible, what is the best way?  
Below I will make an example about what I want to achieve.

In a configuration file, for example a.conf, I have the following basic configuration.

```auto
    input {
            syslog {
                    port => 5514
                    codec => plain { charset => "ISO-8859-1" }
            }
    }

    filter {
           ...include b.conf
    }

    output {
                    elasticsearch {
                            hosts => ["https://localhost:9200"]
                            index => "xxxx_%{+YYYY.MM.dd}"
                            user => "logstash_user"
                            password => "xxxxx"
                    }
    }

```

In b.conf, I have this code:

```auto
    grok {
            match => { "message" => "<134>@{%{GREEDYDATA:total_message}}" }
            tag_on_failure => ["_grok_nomatch"]
            add_tag => ["_grok_success"]
    }
    kv {
            source => "total_message"
            field_split_pattern => "; "
            tag_on_failure => ["_kv_nomatch"]
            add_tag => ["_kv_success"]
    }
    geoip {
            source => "ipAddress"
    }

```

So I would like to 'import' the b.conf configuration file in a.conf.

Regards,  
Matteo.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [September 4, 2019, 1:47pm UTC](https://discuss.elastic.co/t/importing-logstash-configuration-from-another-file/198056/2 "2019-09-04T13:47:54Z")

</div>

If you point path.config to a directory then logstash will concatenate all the files in the directory into a single configuration. So you can approximate what you want by having a set of files

```
01input.conf
02b-filters.conf
03output.conf

```

Otherwise use a pre-processor to do includes, e.g. m4.

---

<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: [October 2, 2019, 1:47pm UTC](https://discuss.elastic.co/t/importing-logstash-configuration-from-another-file/198056/3 "2019-10-02T13:47:55Z")

</div>

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