Logstash template file does not exist or cannot be opened

Hi, I set up a template file in logstash.conf output like this,

output {
   elasticsearch {
     hosts => ["172.17.0.2:9200"]
     manage_template => false
     template => "/home/user_name/docker-elk/logstash/core_mapping_template.json"
     template_overwrite => true
     index => "%{host}-%{[@metadata][log_type]}-%{+YYYY.MM.dd}"
     document_type => "%{[@metadata][log_type]}"
   }
   stdout { codec => json }
}

the template.json is in the directory specified above, and logstash generated the following error,

logstash_1       | {:timestamp=>"2016-08-24T13:12:27.260000+0000", :message=>"Invalid setting for elasticsearch output plugin:\n\n  output {\n    elasticsearch {\n      # This setting must be a path\n      # File does not exist or cannot be opened /home/user_name/docker-elk/logstash/core_mapping_template.json\n      template => \"/home/user_name/docker-elk/logstash/core_mapping_template.json\"\n      ...\n    }\n  }", :level=>:error}

I have chmod the json file to 755.

I am running ELK using docker 1.11.2.

How to fix the issue?

cheers

If you are calling dynamic template from a file location, it should be set to true

1 Like

Hi, changed manage_template => true, the error persists.

So you're running Logstash in a Docker container? Is /home/user_name/docker-elk/logstash/core_mapping_template.json accessible inside that Docker container?

I have chmod the json file to 755.

A JSON file isn't executable so don't set the executable bit. Also, making sure the permissions of the file itself are relaxed isn't enough. All directories leading up to the file must grant executable permissions to the user that Logstash runs as.

1 Like