# INDEX作成時に自動でAliasを設定したい

**URL:** <https://discuss.elastic.co/t/index-alias/207991>\
**Category:** 日本語による質問・議論はこちら\
**Created:** [November 15, 2019, 4:43am UTC](https://discuss.elastic.co/t/index-alias/207991 "2019-11-15T04:43:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tsgkdt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsgkdt/32/39151_2.png) [@tsgkdt](https://discuss.elastic.co/u/tsgkdt)\
**Post date:** [November 18, 2019, 4:49am UTC](https://discuss.elastic.co/t/index-alias/207991/2 "2019-11-18T04:49:25Z")

</div>

IndexTemplateで指定しておく方法ではどうでしょうか？

> **[Index templates | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#_index_template_with_index_aliases)**

aliasを含んだテンプレートを作成しておくことで、Logstashがtest-2019.11.18のようなindexを作成されたときtestというエイリアスをつける、ということができるようになるかと思います。

```json
PUT _template/template_1
{
  "index_patterns": ["test-*"],
  "aliases": {
    "test": {}
  },
以下略

```

テンプレート作成もLogstash側に任せたいということであれば、Logstashのoutput/elasticsearchでalias指定を含んだtemplateファイルを指定しておくことも考えられます。

その場合の指定方法はこちらが参考になるかと思います。

> [@Logstashでindexを作成する際のmapping](https://discuss.elastic.co/t/logstash-index-mapping/206134/2):
>
> Logstashのoutput-elasticsearchでデータを送ってIndexを作成する場合、そのときはtemplateを使ってmapping情報が構成されます。 ですので、templateをどう指定できるかと考えた方が良いかと思います。 詳しくは以下を見てください。 [https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-manage\_template](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-manage_template) a template is applied to Elasticsearch during Logstash’s startup if one with the name template\_name does not already exist. manate\_template(初期値true)の他にテンプレートをどのように指定できるか、という観点では以下の３つがポイントになるかと思います。 template template\_name t…

ご参考になれば幸いです。

---

_[View the full topic](https://discuss.elastic.co/t/index-alias/207991)._
