0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ElasticSearch Service のディスク容量節約を実践してみる

Posted at

AWS の ElasticSearch Service を使ってログをインデクスしていますが、徐々に減っていく空きディスクに震える日々を過ごしていました。
以下の記事を参考にさせていただき、インデックス容量を削減を実践してみました。
https://qiita.com/aucfan-engineer/items/706b8571440a759aec1f

環境

インデックスに Logstash を使用しています。以下の環境で動かしています

  • Amazon Linux AMI release 2018.03
  • Logstash 6.7.1
  • OpenJDK 1.8.0_191
  • Elasticsearch 6.7

やったこと

基本的に文字列検索はしないため、フレーズクエリやスコアを無効にします。
Logstash 側にインデックステンプレートを用意して使用しています。

テンプレート作成

json 形式でテンプレートを作成し、 Logstash を動かす環境に配置します。
dynamic_templates で容量を食う設定を無効にします。

{
  "template" : "xxx-*",
  "mappings" : {
    "_default_" : {
      "dynamic_templates" : [
        {
          "string_fields" : {
            "match" : "*",
            "match_mapping_type" : "string",
            "mapping" : {
              "type" : "text",
              "norms" : false,
              "index_options": "freqs",
              "fields" : {
                "keyword" : { "type": "keyword", "ignore_above": 256 }
              }
            }
          }
        }
      ],
      "properties" : {
        "category": { "type": "keyword" },
        "env": { "type": "keyword" },
        "tags": { "type": "keyword" },
        ・・・
      }
    }
  }
}

Logstash 設定ファイル変更

Logstash の設定ファイルはいくつか要素がありますが、今回 output が関係するのでそこのみ記述します

・・・

output {
  elasticsearch {
    hosts => "xxxxxxxxxx.com:443"
    ssl => true
    index => "xxxxxx-%{+YYYY.MM.dd}"
    # ここから追加
    manage_template => true
    template => "{上記テンプレートファイルのパス}"
    template_name => "template_name"
    template_overwrite => true
  }
}

結果

3種類インデックスがあるうち、2種類この設定を行いました。設定反映後のグラフは下記になります。
Y 軸がストレージの残り、 X 軸が時間です

graph.png

下降気味だったストレージが設定反映後に使用する容量が減って上昇傾向になっているのが確認できました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?