elastic stackにハマった話

23
Been Stuck In Elastic Stack Kazuhiro Kosaka Engineer, MDH, CyberAgent, Inc. Feb 10, 2017

Upload: kazuhiro-kosaka

Post on 21-Feb-2017

22 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Elastic Stackにハマった話

Been Stuck In Elastic StackKazuhiro Kosaka

Engineer, MDH, CyberAgent, Inc.

Feb 10, 2017

Page 2: Elastic Stackにハマった話

About Me• 小坂和弘 - Kazuhiro Kosaka @hyperdash• 2009- CyberAgent, Inc.• Designer/Front-end Engineer/Back-end Engineer• Motion Graphics, VJ

Page 3: Elastic Stackにハマった話

About Me• I love hiking

Page 4: Elastic Stackにハマった話

Summary

What To Talk?• Amazon Elasticsearch Service• v1.x v2.x

Page 5: Elastic Stackにハマった話

Summary

What NOT To Talk?• Private Elasticsearch Cluster / Elastic Cloud• v5.x

Page 6: Elastic Stackにハマった話

Summary

Elastic Stack?• Had been called ELK Stack

• Elasticsearch - Distributed Search/Analytics Engine• Logstash - Data Processing Pipeline• Kibana - Data Visualizer• Beats - Data Shipping Agents

Page 7: Elastic Stackにハマった話

Our Case広告運用・配信設定管理画面 ユーザ操作ログ

Page 8: Elastic Stackにハマった話

Our Case• Elasticsearch v1.5 on Amazon Elasticsearch Service• Logstash v2.3.1• Filebeat v1.2.1• m3.large / 3 instances• 400,000 docs / day

• 95% of logs are by 日予算自動アロケーション Batch• Will be separated into another index

• 主にユーザの操作履歴調査

Page 9: Elastic Stackにハマった話

Our Case

Page 10: Elastic Stackにハマった話

Stuck #1 / SettingsDataLoss を防ぐには?

• Filebeat uses a back-pressure sensitive protocol• Logstash < v5.1 has NO Persistent Queue

Page 11: Elastic Stackにハマった話

Stuck #1 / SettingsDataLoss を防ぐには?

Source: https://www.elastic.co/guide/en/logstash/5.0/deploying-and-scaling.html

Page 12: Elastic Stackにハマった話

Stuck #1 / SettingsDataLoss を防ぐには?

• Use Message Queue e.g. Kafka• Delete Filebeat registrar file and Re-ship data

• >= v5.1 Persistent Queue (beta) is enabled

Page 13: Elastic Stackにハマった話

Stuck #2 / JVMMemoryPressureES に Write できなくなったんですけど…

• m3.medium / 1 instance• JVMMemoryPressure ≒ 92-94 %• FreeStorageSpace looks okay

Page 14: Elastic Stackにハマった話

Stuck #2 / JVMMemoryPressureES に Write できなくなったんですけど…

Source: http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-handling-errors.html

• NOT a t2 instance• ???

Page 15: Elastic Stackにハマった話

Stuck #2 / JVMMemoryPressureES に Write できなくなったんですけど…

m3.medium / 1 instance

m3.large / 3 instances

Worked!

Page 16: Elastic Stackにハマった話

Stuck #2 / JVMMemoryPressureES に Write できなくなったんですけど…

• indices.fielddata.cache.size: unbounded (default)This allows ES to allocate unlimited memory for fielddata

• indices.fielddata.cache.size: 50 (%)

Page 17: Elastic Stackにハマった話

Stuck #2 / JVMMemoryPressureES に Write できなくなったんですけど…

Source: https://www.elastic.co/guide/en/elasticsearch/guide/current/_limiting_memory_usage.html

Page 18: Elastic Stackにハマった話

Stuck #2 / JVMMemoryPressureES に Write できなくなったんですけど…

• ES v1.x• Doc Values: Default OFF• Set “doc_values”: true in index template - mappings

Page 19: Elastic Stackにハマった話

Stuck #2 / JVMMemoryPressureES に Write できなくなったんですけど…

• ES >= v2.x• Doc Values: Default ON

Page 20: Elastic Stackにハマった話

Stuck #3 / RestrictionsAmazon Elasticsearch Service の制限

• Dynamic Scripting is not supported• Custom Plugins are not supported• Access Control

• Amazon ES is out of VPC• IP-Based, IAM-Based Access Control• logstash-output-amazon_es plugin is not stable??

Page 21: Elastic Stackにハマった話

Next Step

• Migrate to Elastic Stack v5.x• Elastic Cloud or Private Cluster?

• 管理画面上での操作ログ閲覧

Page 22: Elastic Stackにハマった話

Conclusion

• Amazon Elasticsearch Service

• Elastic Cloud• Easy & Handy (Fully-Managed)• The latest version is available anytime• Less Restrictions, or Elastic Cloud Enterprise (alpha)• Supported by Elastic

• Easy & Handy (Fully-Managed)• Restrictions• Supported by AWS

Page 23: Elastic Stackにハマった話

END

THANK YOU