[ERROR][logstash.outputs.elasticsearch] Failed to install template. {:message=>"Got response code '400' contacting Elasticsearch at URL 'http://localhost:9200/_template/jose_prueba_v14'"

Good afternoon,

I'm having problems with logstash when putting a template file to perform a mapping.

in my logstash .conf file, I put "output {
elasticsearch {
hosts => ['localhost: 9200']
index => 'jose_test_v14'
manage_template => true
template => '/etc/logstash/conf.d/v14.json'
template_name => 'jose_test_v14'
template_overwrite => true

}
stdout {}
}

and within V14, I have the structure of the:
{
"template": "jose_pruebe_v14",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"index": {
"query": {"default_field": "@message"},
"store": {"compress": {"stored": true, "tv": true}}
}
},
"mapping": {
"_Doc": {
"_all": {"enabled": false},
"_source": {"compress": true},
"dynamic_templates": [
{
"string_template": {
"match": "*",
"mapping": {"type": "string", "index": "not_analyzed"},
"match_mapping_type": "string"
}
}
],
"properties": {
"location": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},

but when I run:
Failed to install template. {: message => "Got response code '400' contacting Elasticsearch at URL 'http: // localhost: 9200 / _template / jose_pruebe_v14'",

I do not know what is wrong so that I do not get the template for the mapping, since the dates, I do not want them with the elastic format it sets by default but

    "date_variable": {
      "type": "date",
      "format": "yyyy-MM-DD"
    },

any guidance that can help me to find the problem?
I have been looking at some people who have had the same problem, but I have not found the solution so that this does not happen.

attentively

José

What error is logged in the elasticsearch log?

Hello Badger,

in the elasticsearch log, i havent error.
the error is in the log of logstash.

[2020-10-20T07:42:44,095][INFO ][logstash.outputs.elasticsearch] Installing elasticsearch template to _template/jose_prueba_v15
[2020-10-20T07:42:44,135][ERROR][logstash.outputs.elasticsearch] Failed to install template. {:message=>"Got response code '400' contacting Elasticsearch at URL 'http://localhost:9200/_template/jose_prueba_v15'", :class=>"LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError", :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb:80:in perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:291:in perform_request_to_url'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:278:in block in perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:373:in with_connection'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:277:in perform_request'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:285:in block in Pool'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/http_client.rb:352:in template_put'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/http_client.rb:86:in template_install'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/template_manager.rb:28:in install'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/template_manager.rb:16:in install_template'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/common.rb:129:in install_template'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-9.4.0-java/lib/logstash/outputs/elasticsearch/common.rb:50:in block in setup_after_successful_connection'"]}
[2020-10-20T07:42:44,235][INFO ][logstash.pipeline ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x556ebe27 run>"}
[2020-10-20T07:42:44,275][INFO ][filewatch.observingtail ] START, creating Discoverer, Watch with file and sincedb collections
[2020-10-20T07:42:44,278][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>}
[2020-10-20T07:42:44,496][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9605}

I have a elasticsearch:
Version: 6.8.11, Build: default/deb/00bf386/2020-07-09T19:08:08.940669Z, JVM: 11.0.8

and Logstash:
logstash 6.8.12

and my template.json
{
"template": "jose_prueba_v15",
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0,
"index" : {
"query" : { "default_field" : "@message" },
"store" : { "compress" : { "stored" : true, "tv": true } }
}
},
"mapping": {
"_doc": {
"_all": { "enabled": false },
"_source": { "compress": true },
"dynamic_templates": [
{
"string_template" : {
"match" : "*",
"mapping": { "type": "string", "index": "not_analyzed" },
"match_mapping_type" : "string"
}
}
],
"properties": {
"Localidad": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Fecha": {
"type": "date",
"format": "yyyy-MM-DD"
}
}
}
}
}
it is validated and say me that it is correct.

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