ELK5.x->6.xアップグレードピット記録

2815 ワード

背景
dockerに基づいて構築されたELKシステムに基づいて、filebeatはredisに収集を担当します.ミラーを5からアップグレードx->6.x,アップグレード後kibanaで作成したインデックスがすべて失効していることがわかりました.最後に、検索中にfilebeatのフィールドdocument_が見つかりました.typeが廃棄され、logstashのgrokがフィルタリング中にindexを動的に追加できず、indexがkibanaで失効する.
解決策
元のfilebeat出力フィールドを
// filebeat.yml
#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- type: log

  # Change to true to enable this prospector configuration.
  enabled: true
  fields_under_root: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /mnt/docker-data/logstash/nginx/error.log
  document_type: nginx-error

次のように変更します(filedフィールドを追加します.fields_under_root:trueはすべてのfiledの下のフィールドをrootノードに昇格させます).
// filebeat.yml update
filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- type: log

  # Change to true to enable this prospector configuration.
  enabled: true
  fields_under_root: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /mnt/docker-data/logstash/nginx/error.log
  fields:
    document_type: nginx-error



// logstash pipeline conf
output {
    elasticsearch {
            hosts => ["elasticsearch:9200"]
            manage_template => true
            index => "logstash-test-%{[document_type]}-%{+YYYY-MM-DD}"
    }

}

上記のコードのpipeline部分では、インデックスを追加する最適化にはif文がすべて使用されています.コードは多くの栄誉を持っています.これでプロファイルがよりきれいになります.