# He given configuration is invalid. Reason: Expected one of #, input, filter, output

**URL:** https://discuss.elastic.co/t/he-given-configuration-is-invalid-reason-expected-one-of-input-filter-output/202355
**Category:** Logstash
**Created:** [October 4, 2019, 1:53pm UTC](https://discuss.elastic.co/t/he-given-configuration-is-invalid-reason-expected-one-of-input-filter-output/202355 "2019-10-04T13:53:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kenorb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kenorb/32/55394_2.png) [@kenorb](https://discuss.elastic.co/u/kenorb)
#### Post date: [October 4, 2019, 1:53pm UTC](https://discuss.elastic.co/t/he-given-configuration-is-invalid-reason-expected-one-of-input-filter-output/202355/1 "2019-10-04T13:53:26Z")

</div>

I've got the following syntax error when running Logstash:

```
$ sudo -u logstash /usr/share/logstash/bin/logstash -V
logstash 7.1.0

$ sudo -u logstash /usr/share/logstash/bin/logstash -t -f /etc/logstash/logstash.yml
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
[WARN] 2019-10-04 13:51:54.891 [LogStash::Runner] multilocal - Ignoring the 'pipelines.yml' file because modules or command line options are specified
[FATAL] 2019-10-04 13:51:56.049 [LogStash::Runner] runner - The given configuration is invalid. Reason: Expected one of #, input, filter, output at line 214, column 1 (byte 6380) after # Settings file in YAML
#
# Settings can be specified either in hierarchical form, e.g.:
#
# pipeline:
# batch:
# size: 125
# delay: 5
#
# Or as flat keys:
#
# pipeline.batch.size: 125
# pipeline.batch.delay: 5
...
[ERROR] 2019-10-04 13:51:56.093 [LogStash::Runner] Logstash - java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit

$ tail /etc/logstash/logstash.yml
# * debug
# * trace
#
# log.level: info
#path.logs: /var/log/logstash
#
# ------------ Other Settings --------------
#
# Where to find custom plugins
# path.plugins: []

```

Basically I've commented out all the lines and Logstash still complaining about the syntax. Any ideas why Logstash errors?

Also I can see the following error in the logs:

> `[2019-10-04T13:41:57,572][ERROR][logstash.agent] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, input, filter, output at line 214, column 1 (byte 6380) after ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:41:in `compile\_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:49:in `compile_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:11:in `block in compile\_sources'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:10:in `compile\_sources'", "org/logstash/execution/AbstractPipelineExt.java:151:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:47:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java\_pipeline.rb:23:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:36:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:325:in `block in converge_state'"]}`

---

<div class="post-metadata">

### Author: ![ben.west](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben.west/32/55244_2.png) [@ben.west](https://discuss.elastic.co/u/ben.west)
#### Post date: [October 4, 2019, 2:16pm UTC](https://discuss.elastic.co/t/he-given-configuration-is-invalid-reason-expected-one-of-input-filter-output/202355/2 "2019-10-04T14:16:17Z")

</div>

It looks like you are passing the logstash configuration file as pipeline configuration.  
The `-f` option should point towards your pipeline config (a file which contains `input {}` `filter {}` and `output {}` blocks).

The logstash config file is specified via commandline using the option `--path.settings` and should be the directory in which your `logstash.yml` is.

---

<div class="post-metadata">

### Author: ![kenorb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kenorb/32/55394_2.png) [@kenorb](https://discuss.elastic.co/u/kenorb)
#### Post date: [October 4, 2019, 2:24pm UTC](https://discuss.elastic.co/t/he-given-configuration-is-invalid-reason-expected-one-of-input-filter-output/202355/3 "2019-10-04T14:24:35Z")

</div>

Thank you, I've specified `--path.settings`, but it still complains about the syntax, but this time doesn't tell which file it is.

```
# sudo -u logstash /usr/share/logstash/bin/logstash -t --path.settings /etc/logstash
Sending Logstash logs to /usr/share/logstash/logs which is now configured via log4j2.properties
[2019-10-04T14:19:57,172][FATAL][logstash.runner] The given configuration is invalid. Reason: Expected one of #, input, filter, output at line 46, column 1 (byte 1000) after 
[2019-10-04T14:19:57,211][ERROR][org.logstash.Logstash] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit

```

Logs (`logstash-plain.log`):

```
[2019-10-04T14:21:11,555][INFO][logstash.runner] Starting Logstash {"logstash.version"=>"7.1.0"}
[2019-10-04T14:21:13,893][ERROR][logstash.agent] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, input, filter, output at line 46, column 1 (byte 1000) after ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:41:in `compile_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:49:in `compile_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:11:in `block in compile_sources'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:10:in `compile_sources'", "org/logstash/execution/AbstractPipelineExt.java:151:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:47:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:23:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:36:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:325:in `block in converge_state'"]}
[2019-10-04T14:21:14,033][INFO][logstash.runner] Logstash shut down.

```

Ok, I've found which file it is (`/etc/logstash/conf.d/foo.conf`), based on the line.

After the config fixes, the following command works correctly:

```
sudo -u logstash /usr/share/logstash/bin/logstash -t --path.settings /etc/logstash

```

> [2019-10-04T14:24:22,219][INFO][logstash.runner] Using config.test\_and\_exit mode. Config Validation Result: OK. Exiting Logstash

Thanks.

---

<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: [November 1, 2019, 2:24pm UTC](https://discuss.elastic.co/t/he-given-configuration-is-invalid-reason-expected-one-of-input-filter-output/202355/4 "2019-11-01T14:24:46Z")

</div>

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