# \[LogStash::Runner\]: Exception on end of comment line - 'The given configuration is invalid. Reason: Expected'

**URL:** <https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564>\
**Category:** Logstash\
**Created:** [February 22, 2019, 11:16am UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564 "2019-02-22T11:16:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![henkepa](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@henkepa](https://discuss.elastic.co/u/henkepa)\
**Post date:** [February 22, 2019, 11:16am UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564/1 "2019-02-22T11:16:30Z")

</div>

OS: Redhat 7  
Logstash Version: 6.5.1

The following logstash pipeline.conf:

```
# !!!Attenttion: Comments can raise exceptions -> be aware!!!
input {
    beats {
        port => "5044"
        host => "0.0.0.0"
    }
}
output {
    if [input][type] == "log" {
        elasticsearch {
            hosts => ["10.10.158.141:9200"]
            manage_template => false
            index => "whatever-%{+YYYY.MM.dd}"
			}
		}
	}

```

Raises the exception:

```
[LogStash::Runner] runner - The given configuration is invalid. Reason: Expected at line 1, column 63 (byte 63) after 
# !!!Attenttion: Comments can raise exceptions -> be aware!!!

```

The config file pasted here is an abstraction of the config that originally lead to my problem.  
This started to appear suddenly after a change of the config.  
As I have the config files in a repository, I first thought it might be a hidden character or something like that and so I rolled it back to a previous version of the config file, but the problem remained.  
Logstash Runner still returned an error in a comment line. So I removed the line and checked again -\> then I saw the same exception but on the next comment line. It resulted in removing all comments from the file and finally there were no more exceptions and it ran fine again.

Afterwards I exchanged with a colleague and he told me he had exactly the same issue before and that he had to remove all comments as well to get it working.

What is interesting here ist that the runner always complains about the last character in the line, which is simply a carriage return with line feed

---

<div class="post-metadata">

**Author:** ![pjanzen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjanzen/32/13756_2.png) [@pjanzen](https://discuss.elastic.co/u/pjanzen)\
**Post date:** [February 23, 2019, 10:46am UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564/2 "2019-02-23T10:46:27Z")

</div>

This is strange as comments are allowed in config files: [configuration-file-structure](https://www.elastic.co/guide/en/logstash/6.5/configuration-file-structure.html)

I wonder is it the !!! that it is complaining about, if it is I would say that is a bug as it should ignore the line starting with "#"

What error/warning do you see on the last carriage return?

---

<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 23, 2019, 1:42pm UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564/3 "2019-02-23T13:42:56Z")

</div>

> [@henkepa](#):
>
> What is interesting here ist that the runner always complains about the last character in the line, which is simply a carriage return with line feed

So it is a Windows style line ending on a UNIX server?

---

<div class="post-metadata">

**Author:** ![henkepa](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@henkepa](https://discuss.elastic.co/u/henkepa)\
**Post date:** [February 25, 2019, 9:30am UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564/4 "2019-02-25T09:30:17Z")

</div>

I can say that "!!!" is not the root cause. It fails in the same way when I remove "!!!"

---

<div class="post-metadata">

**Author:** ![henkepa](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@henkepa](https://discuss.elastic.co/u/henkepa)\
**Post date:** [February 25, 2019, 9:33am UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564/5 "2019-02-25T09:33:45Z")

</div>

Yes, that could be. I simply pasted the whole config from a textfile on Windows to nano.

In order to check if this is the root cause, I now deleted the whole line within nano and wrote a new comment by hand -\> same error

---

<div class="post-metadata">

**Author:** ![pjanzen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjanzen/32/13756_2.png) [@pjanzen](https://discuss.elastic.co/u/pjanzen)\
**Post date:** [February 25, 2019, 2:30pm UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564/6 "2019-02-25T14:30:56Z")

</div>

You can try to convert the file on the box just to make sure there are no funny caracters.

Have a [look here, its all about converting files.](https://tipstricks.itmatrix.eu/converting-windows-text-files-to-linux/)

---

<div class="post-metadata">

**Author:** ![henkepa](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@henkepa](https://discuss.elastic.co/u/henkepa)\
**Post date:** [March 12, 2019, 1:41pm UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564/7 "2019-03-12T13:41:36Z")

</div>

thanks man, you pointed me to the problem. I was trying dos2unix and it did not help. Close to getting crazy I saw that nano for whatever reason detected a mac format (no mac was involved at all) -\>mac2unix finally solved it!

---

<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:** [April 9, 2019, 1:41pm UTC](https://discuss.elastic.co/t/logstash-runner-exception-on-end-of-comment-line-the-given-configuration-is-invalid-reason-expected/169564/8 "2019-04-09T13:41:39Z")

</div>

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