# Not loading pipeline - ConfigurationError

**URL:** <https://discuss.elastic.co/t/not-loading-pipeline-configurationerror/297422>\
**Category:** Logstash\
**Tags:** ingest-pipeline\
**Created:** [February 16, 2022, 10:49pm UTC](https://discuss.elastic.co/t/not-loading-pipeline-configurationerror/297422 "2022-02-16T22:49:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sconic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sconic/32/97508_2.png) [@Sconic](https://discuss.elastic.co/u/Sconic)\
**Post date:** [February 16, 2022, 10:49pm UTC](https://discuss.elastic.co/t/not-loading-pipeline-configurationerror/297422/1 "2022-02-16T22:49:52Z")

</div>

I've updated the output of our pipeline to change the index that some documents get added to but I'm getting a configuration error when trying to start Logstash, I can't for the life of me find what I'm missing. I'm using version 7.15.2.

```auto
output {
  if [@metadata][pipeline] {
    elasticsearch {
      hosts => "localhost:9200"
      manage_template => false
      if [service][type] == "postgres" {
        index => "%{[@metadata][beat]}-postgres-%{+YYYY.MM.dd}"
      } else {
        index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
      }
      pipeline => "%{[@metadata][pipeline]}"
    }
  } else {
    elasticsearch {
      hosts => "localhost:9200"
      manage_template => false
      index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
    }
  }
}

```

and the error:

```auto
Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of [\\t\\r\\n], \"#\", \"=>\" at line 50, column 10 (byte 1031) after output {\n# if [file] or [url] { \n# stdout { codec => rubydebug }\n# }\n if [@metadata][pipeline] {\n elasticsearch {\n hosts => \"localhost:9200\"\n manage_template => false\n if ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:32:in `compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:187:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:72:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:47:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:52:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:391:in `block in converge_state'"]}

```

Thank you all for your help.

---

<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:** [February 16, 2022, 11:14pm UTC](https://discuss.elastic.co/t/not-loading-pipeline-configurationerror/297422/2 "2022-02-16T23:14:56Z")

</div>

> [@Sconic](#):
>
> ```auto
> manage_template => false
> if [service][type] == "postgres" {
> 
> ```

You cannot have an conditional inside an output plugin config. What you could do in the filter section is

```
   if [@metadata][pipeline] {
       if [service][type] == "postgres" {
         mutate { add_field => { "[@metadata][indexName]" => "%{[@metadata][beat]}-postgres-%{+YYYY.MM.dd}" } }
       } else {
         mutate { add_field => { "[@metadata][indexName]" => "%{[@metadata][beat]}-%{+YYYY.MM.dd}" } }
       }
     }
   } else {
       mutate { add_field => { "[@metadata][indexName]" => "%{[@metadata][beat]}-%{+YYYY.MM.dd}" } }
   }

```

then change all your outputs to use `index => "%{[@metadata][indexName]}"`

---

<div class="post-metadata">

**Author:** ![Sconic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sconic/32/97508_2.png) [@Sconic](https://discuss.elastic.co/u/Sconic)\
**Post date:** [February 16, 2022, 11:56pm UTC](https://discuss.elastic.co/t/not-loading-pipeline-configurationerror/297422/3 "2022-02-16T23:56:16Z")

</div>

Awesome. Thanks @Badger, I'll fix that up now. And thank you for the super fast reply too 🙂

---

<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 16, 2022, 11:56pm UTC](https://discuss.elastic.co/t/not-loading-pipeline-configurationerror/297422/4 "2022-03-16T23:56:58Z")

</div>

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