aws black belt online seminar amazon elasticsearch service · 2020. 1. 27. · 2017.12.06 【aws...
TRANSCRIPT
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アマゾン ウェブ サービス ジャパン株式会社
ソリューションアーキテクト 半場 光晴
2017.12.06
【AWS Black Belt Online Seminar】Amazon Elasticsearch Service
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
自己紹介
• 名前
半場 光晴 (はんば みつはる)
• 所属
アマゾン ウェブ サービス ジャパン株式会社
技術統括本部
メディア・エンターテインメント ソリューション部
ソリューション アーキテクト
• 好きな AWS サービス
Amazon Kinesis、Amazon S3、Amazon EMR
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Black Belt Online Seminar へようこそ!
質問を投げることができます!Adobe Connect の Q&A ウィンドウから、質問を書き込んでください(書き込んだ質問は、主催者にしか見えません)
今後のロードマップに関するご質問はお答えできませんのでご了承ください
Twitter へツイートする際はハッシュタグ #awsblackbelt をご利用ください
①Q&Aウィンドウ右下のフォームに質問を書き込んで
ください
②吹き出しマークで送信してください
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Black Belt Online Seminar とはAWSJ の Tech メンバが AWS に関する様々な事を紹介するオンラインセミナーです
【火曜 12:00~13:00】主に AWS のソリューションや業界カットでの使いどころなどを紹介(例:IoT、金融業界向け etc.)
【水曜 18:00~19:00】主に AWS サービスの紹介やアップデートの解説(例:EC2、RDS、Lambda etc.)
※開催曜日と時間帯は変更となる場合がございます。最新の情報は下記をご確認下さい。
オンラインセミナーのスケジュール & 申し込みサイト• https://aws.amazon.com/jp/about-aws/events/webinars/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
内容についての注意点
• 本資料では 2017 年 12 月 6 日時点のサービス内容および価格についてご説明しています。最新の情報は AWS 公式ウェブサイト (http://aws.amazon.com) にてご確認ください
• 資料作成には十分注意しておりますが、資料内の価格と AWS 公式ウェブサイト記載の価格に相違があった場合、AWS 公式ウェブサイトの価格を優先とさせていただきます
• 価格は税抜表記となっています。日本居住者のお客様が東京リージョンを使用する場合、別途消費税をご請求させていただきます
• AWS does not offer binding price quotes. AWS pricing is publicly available and is subject to change in accordance with the AWS Customer Agreement available at http://aws.amazon.com/agreement/. Any pricing information included in this document is provided only as an estimate of usage charges for AWS services based on certain information that you have provided. Monthly charges will be based on your actual use of AWS services, and may vary from the estimates provided.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
1. Amazon Elasticsearch Service (ES) のサービス紹介
2. Amazon ES の構成概要
3. Amazon ES の最近の主なアップデートと関連情報
4. Amazon ES と関連するサービスやソフトウェア
5. まとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
1. Amazon Elasticsearch Service (ES) のサービス紹介
2. Amazon ES の構成概要
3. Amazon ES の最近の主なアップデートと関連情報
4. Amazon ES と関連するサービスやソフトウェア
5. まとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• 分散検索・分析エンジン
• Elasticsearch と Kibana を使用したマネージドサービス
• フル・マネージド - 管理ゼロ
• 高可用性と信頼性
• 他の AWS サービスと緊密に統合
Amazon Elasticsearch
Service(Amazon ES)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IT 運用監視 セキュリティ情報やイベントの管理
アプリケーションの
監視や分析
IoT/TSDB の
監視やデータ分析
アプリケーションの
検索機能
ターゲテイング
広告
Amazon ES の主たるユースケース
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ログ分析
デジタルマーケティング、運用インテリジェンス、不正検出、広告技術、ゲーム、IoT などの幅広いアプリケーションに対して、Web サイト、モバイルデバイス、サーバー、センサーなどによって生成された非構造化および半構造化ログを分析する
フルテキスト検索
テキストマッチング、ファセッティング、フィルタリング、あいまい検索、自動補完、ハイライトなどの機能をサポートし、多様なドキュメントセットで豊富な検索とナビゲーションを提供する
分散検索エンジン
AZ をまたぎ統合されたレプリケーションを使用して、数十億のドキュメントを格納および検索できる、使いやすく高性能な JSON ドキュメント指向プラットフォームを使用して、アプリケーションに検索の力を与える
リアルタイムアプリケーション監視
ほぼリアルタイムで分析するためにデータをインデックス化し(1秒未満)、視覚化し、統計的集計を実行して根本的な原因を特定し、問題を修正することによって、顧客対応アプリケーションおよび Web サイト全体にアクティビティログを捉える
クリックストリーム分析
デジタルコンテンツのリアルタイムメトリクスを提供し、作成者とマーケティング担当者が顧客とつながることを可能する数十億の小さなメッセージをElasticsearch に流し込み、そこでデータを集約、フィルタリング、および処理してコンテンツパフォーマンスダッシュボードを提供する
Amazon ES が力になるもの
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Easy to Use
プロダクション対応の Elasticsearchクラスターを数分でデプロイ
ソフトウェアパッチ、障害からの回復、バックアップ、監視など、時間のかかる管理タスクを簡素化
Open
Elasticsearch オープンソース API に直接アクセスする
すべてのコードとアプリケーションに対して、オープンソースのElasticsearch API と完全に互換性がある
Secure
ユーザとエンドポイントのためのきめ細かなアクセス制御を備えたAWS Identity and Access Management(IAM)ポリシーによるセキュアなElasticsearchクラスター
セキュリティパッチを自動的に適用し、Elasticsearch 環境を安全に保つ
Available
2 つの AZ 間でデータを複製するゾーンアウェアネスを使用して高可用性を実現する
クラスターの正常性を監視し、障害の発生したノードをサービスの中断なしで自動的に置き換える
AWS Integrated
Amazon Kinesis Firehose、AWS IoT、Amazon CloudWatch Logs と統合して、データをシームレスに処理
監査のための AWS CloudTrail、セキュリティのための AWS IAM、クラウドオーケストレーションの AWS CloudFormation
Scalable
1 つのノードから 100 ノードまでのクラスターのスケール
SSD を搭載した EBS ボリュームを含む様々なインスタンスタイプとストレージオプションから選択して、パフォーマンス要件を満たすようにクラスターを構成する
Amazon ES の利点
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES を検索・分析アプリケーションとして利用している、様々な業種のお客様 1/2
Media & Entertainment
Online Services
Technology その他にも
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES を検索・分析アプリケーションとして利用している、様々な業種のお客様 2/2
https://youtu.be/oJUpUQ_yNVw
https://github.com/ExpediaDotCom/cloudtrail-log-analytics
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
1. Amazon ES のサービス紹介
2. Amazon ES の構成概要
3. Amazon ES の最近の主なアップデートと関連情報
4. Amazon ES と関連するサービスやソフトウェア
5. まとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service
• Elasticsearch の Terminology
• Document
• ユニークな ID を持つ(RDB のrow に近い)
• Field を持つ(RDB の column に近い)
• 同じ Field の Document の集合体を Type(RDB の table に近い)
– Elasticsearch 6.x から 9.x にかけて、段階的に、Type は廃止されていく予定となっている
https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service• Elasticsearch の Terminology
• Index
• Document の集合体(RDB の database に近い)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service• Elasticsearch の Terminology
• Shard
• Document は Index 内の複数の Shard に分散して配置される
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service• Elasticsearch の Terminology
• Node
• 物理・仮想インスタンス
• 複数の Shard を保持
• Cluster
• ひとつ、もしくは、複数のノードからなる
• 複数の Index を保持することができる
• Amazon ES における Domain
• Managed Elasticsearch Cluster
• ひとつの domain に、複数の Index や Type を定義できる
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch ServiceAmazon ES の Deployment
• 各ノード EBS ボリュームはサイズ指定可能(最大 1.5TB)
• ノードの最大数は 100
node node
EBS EBS
node
node
node
Master Nodes Data Nodes
Cluster Node
Shard 3
node
EBS
node
EBS
Shard 1
Shard 4
Shard 2
https://aws.amazon.com/jp/blogs/news/get-started-with-amazon-elasticsearch-service-how-many-shards-do-i-need/
http://aws.typepad.com/sajp/2017/01/get-started-with-amazon-elasticsearch-service-how-many-data-instances-do-i-need.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch ServiceAmazon ES の Deployment
• 各ノード EBS ボリュームはサイズ指定可能(最大 1.5TB)
• ノードの最大数は 100
node node
EBS EBS
node
node
node
Master Nodes Data Nodes
Cluster Node
Shard 3
node
EBS
node
EBS
Shard 1
Shard 4
Shard 2
https://aws.amazon.com/jp/blogs/news/get-started-with-amazon-elasticsearch-service-how-many-shards-do-i-need/
データノードの台数は?
Index ごとの Shard の数は?
http://aws.typepad.com/sajp/2017/01/get-started-with-amazon-elasticsearch-service-how-many-data-instances-do-i-need.html
ストレージのサイズは?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service• dedicated master nodes
• ノードを管理するマスター専用ノード
• Split Brain を考慮して 3 台構成がオススメ– https://www.elastic.co/guide/en/elasticsearch/reference/5.5/modules-node.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service• Zone awareness - 複数の AZ を使う設定
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES のデプロイの注意点• スケーリングは、各種メトリクスを見ながら、ご自身
で対応する必要がある
• 構成を後から簡単に変更することができる
• 構成変更は、Blue/Green デプロイで実行される
• スケールコントロールの観点で、特に注意を払うべき代表的なメトリクス
• クラスターの JVMMemoryPressure
• クラスターの FreeStorageSpace
• マスターの CPUUtilization
• プラグインを自由にインストールすることはできない
• マネージドサービスであるため、セキュリティや可用性を担保する必要があるため
• 商用プラグインに該当するような機能は、IAM やCloudWatch、Kinesisで補う
Amazon Elasticsearch Service
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Supported APIs
Amazon Elasticsearch Service
http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-supported-es-operations.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service
• コンソールで JSON をやりくりするのは辛い?
• Amazon ES 5.1 以降ならば、Kibana の Console を活用できる
• 以前から Chrome プラグイン・Kibana プラグインとしてよく知られていた Sense が、Elasticsearch に統合された
https://www.elastic.co/guide/en/kibana/5.5/console-kibana.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Amazon ES の CloudWatch メトリクス
Amazon Elasticsearch Service
Metric for ClusterClusterStatus.green FreeStorageSpaceClusterStatus.yellow ClusterUsedSpaceClusterStatus.red ClusterIndexWritesBlockedNodes JVMMemoryPressureSearchableDocuments AutomatedSnapshotFailureDeletedDocuments CPUCreditBalanceCPUUtilization KibanaHealthyNodes
Metric for dedicated master nodes
MasterCPUUtilization
MasterFreeStorageSpace
MasterJVMMemoryPressure
MasterCPUCreditBalance
MasterReachableFromNodehttp://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/es-metricscollected.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service
日本語解析
• ICU と Kuromoji プラグインは、Amazon ES にインストール済み
• analysis-icu (ノーマライズ)
• analysis-kuromoji (形態素解析)
https://www.elastic.co/guide/en/elasticsearch/plugins/5.5/analysis-icu.html
https://www.elastic.co/guide/en/elasticsearch/plugins/5.5/analysis-kuromoji.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service
ICU: International Components for Unicode
• ICU で出来ること => Unicode の正規化
• 具体的には
– ㌕ => キログラム
– ① => 1
• 使い方の詳細は↓の README を参照– https://github.com/elastic/elasticsearch-analysis-icu
• ICU のホームページ– http://site.icu-project.org/
– http://icu-project.org/apiref/icu4j/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch Service
Kuromoji
• https://www.atilika.com/ja/kuromoji/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch ServiceKuromoji
• 英語: This is a pen.
• This 名詞(主語) / is 動詞 / a 不定冠詞 / pen 名詞
• 日本語: これはペンです。
• これ名詞(主語) / は 助詞 / ペン 名詞 / です 助動詞
• 日本語はスペースで区切られていない
• 日本語用の解析が必要
• Kuromoji の由来• http://shinodogg.com/?p=3346
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elasticsearch ServiceKuromoji のデモ
• http://www.atilika.org/
コードサンプル
コンパイル
実行結果
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
1. Amazon ES のサービス紹介
2. Amazon ES の構成概要
3. Amazon ES の最近の主なアップデートと関連情報
4. Amazon ES と関連するサービスやソフトウェア
5. まとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
無料利用枠の提供を開始
• t2.micro.elasticsearch または t2.small.elasticsearch インスタンスタイプが対象
• t2.micro.elasticsearch インスタンスタイプは、Elasticsearch 2.3 と 1.5 でのみサポートしている
• シングル-AZ の t2.micro.elasticsearch またはt2.small.elasticsearch インスタンスを 1 ヶ月に最大 750 時間、月あたり 10GB の EBS ストレージ
• Magnetic または General Purpose SSD が対象
• 無料利用枠のリミットを超えると、使用する追加リソース分のAmazon ES サービス料金が請求される
https://aws.amazon.com/about-aws/whats-new/2017/01/amazon-elasticsearch-service-free-tier-now-available-on-t2-small-elasticsearch-instances/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
最大 100 ノード、150TB ストレージをサポート
• 単一ドメインでサポートするインスタンスの最大数を 100 に増加
• これにより、選択したインスタンスタイプによっては、ドメインあたりの最大ストレージ容量も 150TB に増加
• C4、M4、R4インスタンスタイプの多くで、最大 1.5TB の EBS ボリュームをサポート
• ちなみに、EBS PIOPS は最大 16,000 IOPS をサポート
• これにより、大規模なアナリティック・ワークロードに対して最大5倍のデータを保存および分析し、パフォーマンス要件を満たすために検索アプリケーションを水平に拡張できる
• 5 倍 = 現在の最大インスタンス数:100 / これまでの最大インスタンス数:20
• デフォルトのドメインごとの制限 20 インスタンスを超えて増加を要求するには、サービス制限緩和のリクエストを送信するだけ
https://aws.amazon.com/about-aws/whats-new/2017/04/amazon-elasticsearch-service-now-supports-up-to-100-nodes-and-150-tb-storage-capacity-per-domain/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Elasticsearch 5.5 サポート
https://aws.amazon.com/about-aws/whats-new/2017/09/elasticsearch-5_5-now-available-on-amazon-elasticsearch-service/
• Amazon ES の Elasticsearch 5.5 では、5.3 のスタックよりも、さらにいくつかの機能拡張が提供されている
• より速いパフォーマンス:Apache Lucene 6.6.0 で強化された Elasticsearch 5.5 では、より効率的なレンジクエリ、ネストされたクエリへのスピードブースト、最適化された大量クエリなど、多数のクエリ最適化機能を提供する
• Kibana 5.5 の機能強化:注目すべき Kibana の機能強化には、探している視覚化を簡単に見つけるための新しいビジュアライゼーション作成ワークフロー、時系列データ用の特別なインターフェイスを提供する新しい時系列ビジュアルビルダー機能、期待される範囲内でデータを提示するのを容易にするゲージおよび目標チャートの視覚化、が含まれる
• ストアドスクリプトのサポート:ストアドスクリプトのサポートが追加され、ネットワークのペイロードが大幅に削減される、ストアドスクリプトは、Painless、Lucene Expressions、および Mustache スクリプト言語で使用でき、既存のインラインスクリプトのサポートを補完する
• 自動スナップショットからのセルフサービスリストア:Amazon ES ドメインのセルフサービスリストアは、サービスによって自動化されたスナップショットから利用できるようになった。すべての自動化されたスナップショットは、Elasticsearch API またはキュレーター CLI から復元することができる。復元リクエストをサポートに依頼する必要はなくなった(ドメインのマイグレーションには、自動スナップショットを利用できない)
• 設定可能なMax Clause Count:デフォルトの MaxClauseCount 設定は 1024 だが、ドメインの設定で、その「高度な設定」で上書きできるようになった
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES とスクリプト
• インラインに加えて、ストアドスクリプトもサポート
• サポートするスクリプト言語は、セキュアかつビルトインの 3 種
• Painless
• Lucene Expressions
• Mustache
• Painless – 汎用、Elasticsearch のデフォルトのスクリプト言語でもある
• Lucene Expressions – カスタムランキング・ソーティング用途
• Mustache – サーチテンプレート用途
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/modules-scripting.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
バックアップ&リストア1. 自動スナップショット – AWS が自動で取得するもの
• Daily – 1 日 1 回 Automated snapshot start hour で指定• リストアはAWS技術サポートへお問い合わせ
1. 手動スナップショット - お客さまがご自身で取得• _snapshot API を実行する• Elasticsearch のフォーマットでお客さまの S3 バケット
自動と手動どちらも、任意のタイミングで、セルフリストア可能
Amazon ES とバックアップ&リストア
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES とバージョンアップ
移行元 Ver 移行先 Ver 移行プロセスのポイント
5.1 or 5.3 5.5 移行元バージョンで手動スナップショットを作り、移行先バージョンでそのスナップショットからリストアを実行する
2.3 5.x まず、Index またはアプリケーションへの調整が必要かどうか、Elasticsearch のドキュメント*を確認する(注意:Elasticsearch の移行プラグインは利用できません)その後、移行元バージョンで手動スナップショットを作り、移行先バージョンでそのスナップショットからリストアを実行する*https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking-changes-5.0.html
1.5 5.x 移行元バージョンのスナップショットは、移行先バージョンと互換性がないため、手動でIndex を再作成する必要がある(注意:1.5 のスナップショットは 2.3 と互換性があるが、Amazon ES 2.3 のドメインは _reindex 操作をサポートしていないので Index を再作成できないため、1.5 で作成された Index では、2.3 のスナップショットを 5.x にリストアできない)
1.5 2.3 まず、Elasticsearch プラグイン _plugin/migration を使用し、直接、移行先バージョンにアップグレードできるかを確認する(注意:移行前にデータの変更が必要になる場合あり)
ウェブブラウザで、http://<domain_endpoint>/_plugin/migration/ を開き、[Run checks now] を選択し、結果に応じて、手順に従いデータを変更する詳細については、Elasticsearch のドキュメント*を要確認
その後、移行元バージョンで手動スナップショットを作り、移行先バージョンでそのスナップショットからリストアを実行する*https://www.elastic.co/guide/en/elasticsearch/reference/2.0/breaking-changes.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Slow logs サポート
https://aws.amazon.com/about-aws/whats-new/2017/10/optimize-your-amazon-elasticsearch-service-domains-using-slow-logs/
• Amazon ES を使用すると、検索(Search)や索引付け(Indexing)操作の最適化とトラブルシューティングに役立つ情報を提供する Slow logs を有効にできるようになりました
• Slow logs は CW Logs に公開され、自由にオン/オフできます
• お客様の使用状況に基づいて発生する CW 料金の支払いのみが必要で、追加の Amazon ES 料金は適用されません
• AWS ES コンソール、CLI、または API を使用して、ドメインごとに個別に、索引付け(Indexing)および検索操作(Search)の Slow logs を有効にすることができます
• 検索操作(Search)は、Query と Fetch のフェーズそれぞれで Slow Logs を取得できます
• ロギングレベルは 4 段階:trace, debug, info, warn
• Elasticsearch の Index ごとに、Slow とする閾値を設定します
• CW Logs に書き込むための適切な IAM 権限を ES ドメインに付与してください
curl -XPUT http://<your domain’s endpoint>/index/_settings -d '{"index.search.slowlog.threshold.query.<level>":"10s"}'
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VPC サポート 1/2
https://aws.amazon.com/about-aws/whats-new/2017/10/amazon-elasticsearch-service-announces-support-for-amazon-virtual-private-cloud-vpc/
• 各ドメインごとにファイアウォールルールと IP ベースのアクセスポリシーを設定して維持することなく、VPC から Amazon ES へのアクセスを簡単に設定できる
• この新機能により、パブリックインターネットを経由することなく、Amazon VPC と Amazon ES 間のすべてのトラフィックを AWS ネットワーク内に維持することができる
• Amazon ES の VPC サポートにより、セキュリティが強化され、ネットワーク管理が簡素化される
• 追加コストなしで利用可能
• VPC サポートにより、Amazon ES ドメインは VPC 内から IP アドレスを得られるようになり、これらのドメインはパブリックインターネットから安全に隔離された状態に保たれる
• 既存の VPC の SG を使用してアクセスを制御できる
• AWS の IAM ポリシーを適用することで、アクセス制御をさらに強化することができる
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VPC サポート 2/2
https://aws.amazon.com/about-aws/whats-new/2017/10/amazon-elasticsearch-service-announces-support-for-amazon-virtual-private-cloud-vpc/
• VPC 内でドメインを起動することも、パブリックエンドポイントを使用することもできるが、二者択一
• VPC 内で新しいドメインを起動すると、後でそれを切り替えてパブリックエンドポイントを使用することはできず、パブリックエンドポイントを持つドメインを作成した場合も、後で VPC 内に配置することはできない
• 代わりに、新しいドメインを作成してデータを移行する必要がある
• ドメインを起動する VPC のハードウェアテナンシーは必ず Default
• VPC 内にドメインを配置した後、別の VPC にドメインを移動することはできない
• ただし、サブネットとセキュリティグループの設定を変更することはできる
• Amazon ES は、VPC 内に存在するドメインの KFH との統合をサポートしていない
• Amazon ES で KFH との統合を使用するには、パブリックエンドポイントを使用する必要がある
• VPC 内に存在するドメインの Kibana にアクセスするには、ユーザーは VPC にアクセスできる必要がある
• ネットワーク構成によって詳細は異なるが、VPN または管理対象ネットワークに接続するか、プロキシサーバーを使用する可能性がある
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES パブリックエンドポイントの利用
1. Amazon ES ドメイン• IAM はこのドメインへのアクセス
を許可する• 追加の IP ベースのアクセスポリ
シーは、プロキシサーバーへのアクセスを提供する
2. VPC サブネット内に存在し、Amazon EC2 インスタンス上で実行されているプロキシサーバー
3. EC2 インスタンス上で実行されている他のアプリケーション• Sig V4 の署名プロセスを使用し
て、Amazon ESに認証済みの要求を送信する
4. Kibana クライアントはプロキシ経由でAmazon ES ドメインに接続する
https://aws.amazon.com/blogs/database/set-access-control-for-amazon-elasticsearch-service/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
1. Amazon ES のサービス紹介
2. Amazon ES の構成概要
3. Amazon ES の最近の主なアップデートと関連情報
4. Amazon ES と関連するサービスやソフトウェア
5. まとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• イベントの処理フロー
https://www.elastic.co/guide/en/logstash/5.5/input-plugins.html
Amazon ES と Logstash 1/4
https://www.elastic.co/guide/en/logstash/5.5/filter-plugins.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
便利な Filter 機能• 代表的な Filter のひとつ – Grok
• 任意のテキストを解析し、それを構造化する• 厄介な構造化されていないログデータを構造
化されクエリ可能なものに解析する最良の方法、とも言われている
• Syslogログ、Apacheやその他のWebサーバーログ、mysqlログなどのログ形式に最適
• 正規表現の上に成り立っているので、正規表現も扱える
• つまり、Grok パターンは、一行ずつデータを照合するために使用される正規表現の名前付き集合になる• Athena や Glue でも活用できる
• GitHub で、様々な Grok パターンが公開されている
Amazon ES と Logstash 2/4
https://github.com/logstash-plugins/logstash-patterns-core/tree/master/patterns
https://www.elastic.co/guide/en/logstash/5.5/plugins-filters-grok.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Logstash – AWS プラグイン• AWS のクレデンシャルを使ってセキュアに Amazon ES にデータ投入
https://www.elastic.co/guide/en/logstash/5.5/advanced-pipeline.html
Amazon ES と Logstash 3/4
https://github.com/awslabs/logstash-output-amazon_es
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Logstash - AWS プラグイン
• Input
• S3 input プラグイン– バケットとファイル名のパターンを指定
– https://www.elastic.co/guide/en/logstash/5.5/plugins-inputs-s3.html
• DynamoDB input プラグイン– DynamoDB Streams のデータを読み込み
– https://github.com/awslabs/logstash-input-dynamodb
• Output
• Amazon Elasticsearch Service output プラグイン– Sig V4 でセキュアにAmazon ES にインデクシング
– https://github.com/awslabs/logstash-output-amazon_es
Amazon ES と Logstash 4/4
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IAM Integration
• IP アドレスベースの制限• 例) Kibana へのアクセスは社内の IP アドレスレンジからのみ
• Signed requests with Signature Version 4• 例) AWS のクレデンシャルを使ってセキュアにアクセス
• Logstash プラグイン: https://github.com/awslabs/logstash-output-amazon_es
• Fine-grained アクセスコントロール• 例) ドメイン内の Index 毎にアクセス権限を分ける
Logstash Amazon ESData Source
Amazon ES と AWS IAM 1/10
Sig V4
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
role
Elastic IP address
role
policy
policypolicy
ユーザーポリシーやロール
インスタンスなどロールや IP
Amazon ES ドメインポリシー
• IAM はすべての適用可能なアイデンティティやポリシーに基づいて認証が働く
ユーザーベースポリシー リソースベースポリシー
Amazon ES と AWS IAM 2/10
http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html¥
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• 競合するポリシータイプに対して、常に Deny が勝る• 明示的にポリシーを指定しない場合、Deny がデフォルト
リソースベースポリシーで Allow
リソースベースポリシーで Deny
リソースベースポリシーで Deny/Allow
の指定なし
ユーザーベースポリシーで Allow
Allow Deny Allow
ユーザーベースポリシーで Deny
Deny Deny Deny
ユーザーベースポリシーで Deny/Allow
の指定なし
Allow Deny Deny
Amazon ES と AWS IAM 3/10
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IAM ポリシーの構造の概要
{
"Version": "2012-10-17",
"Statement": [ {
"Effect":...
"Principal": ...
"Action": [...],
"Resource": ...,
"Condition": ...
} ]
}
• Effect: Allow or Deny• Principal: AWS アカウント ID• Action
• サービスアクション• HTTP メソッド
• Resource: Amazon ES domain/Index• Condition: IP アドレスなど
Amazon ES と AWS IAM 4/10
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
基本的な IP ベースアクセスの例
Amazon ESIAM
Elastic IP
address
• 既知のIPアドレスからのアクセス• ドメインのポリシーは、Deny/Allow するアクションを制御する• アクセスは匿名になる
Policy
Amazon ES と AWS IAM 5/10
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• リソースベースポリシーによるIPベースの制御
• Allow - すべてのユーザー、すべてのアクション、すべての Index
{"Sid": "","Effect": "Allow","Principal": { "AWS": "*” },"Action": "es:*","Resource": "arn:aws:es:us-east-1:12345678910:domain/test/*”"Condition": {
"IpAddress": {"aws:SourceIp": [”1.2.3.4"]
} }}
Amazon ES と AWS IAM 6/10
IP ベースアクセス用のポリシーの例
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ESIAM
• アクセス/秘密鍵で認証されたIDでアクセスする• ポリシーの解釈は前述のとおり• 署名されたリクエストによるアクセス
PolicyAWS SigV4
signing
Lambda
AWS SigV4
signing
Amazon ES と AWS IAM 7/10
基本的なアイデンティティベースアクセスの例
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• リクエストには署名が必須
• Allow - User-name-1 は、すべての Index に対して、すべてのアクション
{"Sid": "","Effect": "Allow","Principal": {
"AWS": ["arn:aws:iam::12345678910:user/user-name-1”
]},"Action": "es:*","Resource": "arn:aws:es:us-east-1:12345678910:domain/test/*”
}
Amazon ES と AWS IAM 8/10
アイデンティティベースアクセス用のポリシーの例
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES へのアクセスの構成例
Application
Amazon ES - search
Amazon ES - monitor
User
Amazon RDSUpdater
Kibana
Proxy
Administrator
DevOps/IT
Amazon ES と AWS IAM 9/10
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES にアクセスするための IAM ロールを、それぞれ作成する
例 Administrator IT/DevOps Application Updater Proxy
タイプ ユーザーベース ユーザーベース リソースベース リソースベース リソースベース
アクション • es:CreateElasticsearchDomain• es:Describe*• es:DeleteElasticsearchDomain• es:ListDomainNames• es:AddTags• es:ListTags• es:RemoveTags• es:Update*
• es:ESHttpGet• es:ESHttpPut• es:ESHttpDelete• es:ESHttpPost
• es:Describe*• es:ListDomainNames• es:AddTags• es:ListTags• es:RemoveTags• es:Update*
es:ESHttpGet es:ESHttpPost es:ESHttpGet
リソース Amazon ES searchAmazon ES monitor
Amazon ES searchAmazon ES monitor
Amazon ES search Amazon ES search Amazon ES monitor
IP なし なし EIP EIP EIP
Amazon ES と AWS IAM 10/10
https://youtu.be/lY5olliJ16E
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES と Beats
• Beats は、単一目的のデータ送信のためのプラットフォーム、軽量エージェントとしてインストールし、数百または数千台のマシンから Logstash、または、Elasticsearch にデータを送信する
• Beats から Amazon ES にドキュメントを書き込むことは、特定の条件下で、できる
• AWS Signature Version 4 が必要なければ、書き込める
• Sig V4 が必要な場合には、Beats から、Logstash を経由して、Amazon ES にドキュメントを書き込むことができる
• logstash-output-amazon-es プラグインを利用して、Sig V4 にサインする
• Sig V4 が必要か否かは、Amazon ES のドメインに対して設定する IAM リソースベースポリシー のPrincipal 属性に指定した値によって決まる
• Amazon ES 自体に Beats をインストールすることはできない
https://www.elastic.co/products/beatshttps://www.elastic.co/products/logstash
Amazon ES
Sig V4
https://github.com/awslabs/logstash-output-amazon_es
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ES と Amazon Kinesis 1/2
• ELK だけでなく、EKK という選択肢もある!
• ELK(Elasticsearch, Logstash, Kibana)
• EKK(Elasticsearch, Kinesis, Kibana)
https://aws.amazon.com/jp/blogs/devops/from-elk-stack-to-ekk-aggregating-and-analyzing-apache-logs-with-amazon-elasticsearch-service-amazon-kinesis-and-kibana/
Amazon Kinesis
IAM Amazon
CloudWatch
Amazon ES
Sig V4
Amazon Kinesisenabled app
Sig V4
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Data producer
AmazonS3
AmazonAthena
Lambda function
Amazon Kinesis
Analytics
Amazon Kinesis Streams
AmazonSNS
Lambda function
①可視化
②仮説検証
③自動化
Amazon Kinesis
Firehose
AmazonElasticsearch
Service
Lambda function
AmazonS3
(Reference data source)
Amazon ES と Amazon Kinesis 2/2
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CloudWatchMetrics
Amazon Linux Ubuntu
Windows Red Hat Linux
CloudWatchLogs
CloudWatchAlarm
SNS
Log Agent Log Agent
Log Agent Log Agent
VPC Flow Log
Amazon ES
Amazon ES と Amazon CloudWatch 1/2
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CloudWatch Logs
• Stream to Amazon Elasticsearch Service
Amazon ES と Amazon CloudWatch 2/2
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS IoT との連携• http://aws.typepad.com/aws_japan/2016/03/aws-iot-update.html
Amazon ES と AWS IoT
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• 検索用途に、ファイルのメタデータや場合によってはファイル内容をインデックスする
• リポジトリを最新に保つために、S3 イベント通知から Lambda をトリガーする
Amazon ES とデータレイク
https://aws.amazon.com/blogs/database/indexing-metadata-in-amazon-elasticsearch-service-using-aws-lambda-and-python/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
1. Amazon ES のサービス紹介
2. Amazon ES の構成概要
3. Amazon ES の最近の主なアップデートと関連情報
4. Amazon ES と関連するサービスやソフトウェア
5. まとめ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS SDK
AWS CLI
AWS CloudFormation
Elasticsearchdata nodes
Elasticsearchmaster nodes
Elastic LoadBalancing
AWS IAM
CloudWatchCloudTrail
Amazon Elasticsearch Service domain
Internet oryour VPC
AWS Console
https://aws.amazon.com/blogs/database/set-access-control-for-amazon-elasticsearch-service/
Elasticsearch のデプロイと管理が容易
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
オープンソース互換
No Lock In!
オープンソースの Elasticsearchへの/からの、ただ置換するだけの、変更のいらない、ほとんどリスクのない移行が可能
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Log shipper
REST
CWL Agent
EC2 Instances
Amazon Kinesis
AmazonRDS
AmazonDynamoDB
AmazonSQS
Queue
LogShippers
Amazon Elasticsearch
Service
Amazon CloudWatch
AWSLambda
AWSCloudTrail
Access Logs
Amazon VPC Flow
Logs
Amazon S3 bucket
AWS IoT
Amazon Kinesis Firehose
AWS エコシステムとの統合
Amazon ECS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
さいごに
• Amazon ES Developer Guide• http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/
• AWS Centralized Logging
• https://aws.amazon.com/answers/logging/centralized-logging/
• AWS Database Blog• https://aws.amazon.com/blogs/database/category/analytics/amazon-elasticsearch-
service/
• AWS Big Data Blog• https://aws.amazon.com/blogs/big-data/category/analytics/amazon-elasticsearch-
service/
• Amazon Web Services Blog (日本)• https://aws.amazon.com/jp/blogs/news/category/analytics/amazon-elasticsearch-
service/
IAM でセキュアに!そして、EKK!
Amazon Elasticsearch
Service(Amazon ES)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
オンラインセミナー資料の配置場所
AWS クラウドサービス活用資料集• http://aws.amazon.com/jp/aws-jp-introduction/
AWS Solutions Architect ブログ• 最新の情報、セミナー中の Q&A 等が掲載されています
• http://aws.typepad.com/sajp/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.