Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
951 views
in Technique[技术] by (71.8m points)

kibana - Authorization error when trying to apply an index template to elasticsearch

so we have an elastic search service running in AWS, the elasticsearch version is 7.8.0. And I need to add an index template to limit the amount of shards that are allocated to new indices when they are added.

I followed this example of how to add an index template and got this very simple template:

PUT _index_template/shard_limitation
{
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1
    }
  }
}

When running this request from the inside Kibana's Dev Tools console I get the following error: {"Message":"Your request: '/_index_template/shard_limitation' is not allowed."}. As well as an Unauthorized - 401 icon. I'm running this command with the admin user.

I tested it locally (elastic search running on my machine) and it all works fine. Any idea why this might happen?

SOLUTION:

As was suggested by @Ajinkya, the correct way to do this is to not include the "_index" before the template api. The correct way to achieve what I was trying to do is to type the following:

PUT _template/shard_limitation
{
  "index_patterns": ["some-pattern"],
  "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

'_index_template' operation might not be supported in AWS elasticsearch. You can check supported operations for your AWS ES version here

You can still use '_template' API to add index template

PUT _template/shard_limitation
{
  "index_patterns": ["test*"],
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1
    }
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...