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

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

This is strange as comments are allowed in config files: configuration-file-structure

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?

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

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

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

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.

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!

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