# How to add new config file to logstash which is created by docker compose?

**URL:** https://discuss.elastic.co/t/how-to-add-new-config-file-to-logstash-which-is-created-by-docker-compose/351655
**Category:** Logstash
**Tags:** docker
**Created:** [January 23, 2024, 6:37pm UTC](https://discuss.elastic.co/t/how-to-add-new-config-file-to-logstash-which-is-created-by-docker-compose/351655 "2024-01-23T18:37:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![shrm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shrm/32/131044_2.png) [@shrm](https://discuss.elastic.co/u/shrm)
#### Post date: [January 23, 2024, 6:37pm UTC](https://discuss.elastic.co/t/how-to-add-new-config-file-to-logstash-which-is-created-by-docker-compose/351655/1 "2024-01-23T18:37:35Z")

</div>

How to add a new config file to logstash which is created by docker-compose?  
I created my service with docker-compose and log stash is connected to kibana and elasticsearch.

Now I created a new config file for logstash but I don't know how to use it. I created the file in folder /elk/logstash/ in the host system. Unfortunately, all of the tutorials are based on the definition of the config file during the creation of the container, but I am seeking a way to update it after creation.  
To make it more informative, I use ubuntu 22.04 in a VPS, and here is the docker-compose creation yml file:

```auto
version: '3.6'
services:
  Elasticsearch:
    image: elasticsearch:7.16.2
    container_name: elasticsearch
    restart: always
    volumes:
    - elastic_data:/usr/share/elasticsearch/data/
    environment:
      ES_JAVA_OPTS: "-Xmx256m -Xms256m"
      discovery.type: single-node
    ports:
    - '9200:9200'
    - '9300:9300'
    networks:
      - elk

  Logstash:
    image: logstash:7.16.2
    container_name: logstash
    restart: always
    volumes:
    - ./logstash/:/logstash_dir
    command: logstash -f /logstash_dir/logstash.conf
    depends_on:
      - Elasticsearch
    ports:
    - '9600:9600'
    environment:
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    networks:
      - elk

  Kibana:
    image: kibana:7.16.2
    container_name: kibana
    restart: always
    ports:
    - '5601:5601'
    environment:
      - ELASTICSEARCH_URL=http://elasticsearch:9200
    depends_on:
      - Elasticsearch
    networks:
      - elk
volumes:
  elastic_data: {}

networks:
  elk:

```

I executed the docker up in the /elk/ folder and now I have the file in the pipeline folder but I don't know how to trigger logstash to pick it while it is created. Please make sure your answer is not based on the creation of the container again by "docker-compose up" which is not my point. Thanks

---

<div class="post-metadata">

### Author: ![strawgate](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/strawgate/32/131008_2.png) [@strawgate](https://discuss.elastic.co/u/strawgate)
#### Post date: [January 27, 2024, 3:13pm UTC](https://discuss.elastic.co/t/how-to-add-new-config-file-to-logstash-which-is-created-by-docker-compose/351655/2 "2024-01-27T15:13:13Z")

</div>

Please share your logstash and a sample pipeline configuration that does not work.

If you are dropping a pipeline in the pipeline folder, you may also need to include a reference to it in the pipelines.yml file [Multiple Pipelines | Logstash Reference [8.12] | Elastic](https://www.elastic.co/guide/en/logstash/current/multiple-pipelines.html) or reference it in your logstash.yml

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [January 27, 2024, 3:44pm UTC](https://discuss.elastic.co/t/how-to-add-new-config-file-to-logstash-which-is-created-by-docker-compose/351655/3 "2024-01-27T15:44:09Z")

</div>

> [@shrm](#):
>
> ```auto
> command: logstash -f /logstash_dir/logstash.conf
> 
> ```

The problem is that you are running the command line that explicitly only runs a specific logstash conf file.

> **[Configuring Logstash for Docker | Logstash Reference \[8.12\] | Elastic](https://www.elastic.co/guide/en/logstash/current/docker-config.html)**

As @strawgate said use pipeline.yml or simple load multiple conf files in the conf.d directory

---

<div class="post-metadata">

### Author: ![ITIC](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@ITIC](https://discuss.elastic.co/u/ITIC)
#### Post date: [January 29, 2024, 1:43pm UTC](https://discuss.elastic.co/t/how-to-add-new-config-file-to-logstash-which-is-created-by-docker-compose/351655/4 "2024-01-29T13:43:48Z")

</div>

Hi!

The way I do it is through a volume. In the `Logstash:` service definition, under `volumes:`, I have one pointing straight to the pipeline:

```auto
- logstash-pipeline:/usr/share/logstash/pipeline

```

Then I simply drop my `.yml` files (yes, I have multiple different files for different tasks) in that directory, on the host. You could also copy your `.yml` file(s) to the pipeline, but will still need the volume for persistence:

` docker cp <your.yml> logstash:/usr/share/logstash/pipeline/`

Then restart the logstash container for the changes to take effect.

As pointed out by @stephenb, you should not use the `command` line in your `docker-compose.yml`. Logstash will load any `.yml` file it finds in its `pipeline` directory.

Hope this helps!

---

<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: [February 26, 2024, 1:43pm UTC](https://discuss.elastic.co/t/how-to-add-new-config-file-to-logstash-which-is-created-by-docker-compose/351655/5 "2024-02-26T13:43:57Z")

</div>

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