Amazon Elasticsearch · 2020-04-30 · 在 aws...

47

Transcript of Amazon Elasticsearch · 2020-04-30 · 在 aws...

Page 1: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon
Page 2: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

深入洞察 - 使用 Amazon Elasticsearch 服务进行日志分析

章平,AWS 解决方案架构师

分 会 场 三 : 大 数 据 分 析

Page 3: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

议程

Amazon Elasticsearch 概览

Amazon Elasticsearch 使用案例场景

如何使用 Amazon Elasticsearch 进行日志分析

Page 4: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

数据来源: TechCrunch survey of popular open source software from April’17

什么是 Elasticsearch

• 流行的搜索数据库

• ELK 组合 Elasticsearch, Logstash & Kibana

• 基于 Apache Lucene 分布式搜索分析引擎

• 简单数据注入和可视化

Page 5: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

机器数据驱动 Elasticsearch 增长

机器生成的数据增长 10倍 于业务数据…

IT & DevOps: 数据库, 服务器, 存储, 网络

IoT 和移动设备: 游戏, 传感器, 网络内容

云上架构

Page 6: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Elasticsearch 演变为分析引擎

自然语言Boolean 查询

关联查询

文本搜索

大量注入近似实时

分布式存储

流数据

基于时间的可视化嵌套统计

基于时间的工具

分析

00101101001011100010

1111001100000011000100110010001100110011

0100001101010011

Page 7: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

挑战

高度分散的 TB 级日志数据,缺乏统一收集和指标运营团队不大

扩展性限制了当前和未来需求

成本经济,没有数据锁定

实时观察日志数据,更快发现并解决问题

案例:日志分析

方案

在 AWS 构建统一的日志管理方案,统一跨应用的日志分析接口

应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon Elasticsearch

10 i3.4xlarge Amazon ES 数据节点—33 TB. 可扩展到 110 TB

Kibana 集成到 Amazon Elasticsearch,接近实时的分析和面板

好处

节省 90% 成本

全托管服务—“更少管理,更多效率” 更专注于开发业务

减少发现和修复客户故障的时间,提高客户体验

关键 AWS 服务:

Amazon Kinesis Data Firehose

Amazon CloudWatch

Amazon Elasticsearch Service

Page 8: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

案例:应用监控快速而且可靠的应用发布和性能监控,加速业务

挑战

大量日志数据,如何经济有效监控日志?

没有大量人力来维护基础设施

数据扩展

方案

AWS CloudTrail 日志, 应用日志, Docker 日志 打到 Amazon Elasticsearch

创建集中日志服务

Kibana 用于可视化及 Elasticsearch 查询

好处

快速洞察:

实时发现和解决问题

安全:

集成 AWS IAM

扩展:

简单扩展集群以容纳更多日志数据

关键 AWS 服务

Amazon Elasticsearch Service

Page 9: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

案例: 全文搜索

问 题

Amazon Elasticsearch 自动部署和管理工具,简化了开发流程,优化了搜索体验

好 处

方 案

消费者业务快速增长,需要可扩展的商业搜索方案

Amazon Elasticsearch Service for Nike Core

Search

Page 10: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Amazon Elasticsearch :

Elasticsearch & Kibana 全托管服务

简单部署使用

可扩展

Page 11: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

无缝集成数据注入、安全、审计、流程功能

Amazon Elasticsearch 带来好处

马上使用,无需学习新 APIs 或技能 几分钟部署 Elasticsearch 集群 几下点击或者一个 API,即可调

整集群大小

部署于 VPC 内,以安全组和 IAM 策略限制访问

跨可用区副本,自动监控和修复

支持 OS APIs 和工具调用 使用简单 可扩展

安全 高可用 紧密集成

Page 12: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

应用数据服务器、应用、网络、AWS 等日志

Amazon Elasticsearch Service Domain

with index(es)

类似数据库的工作方式

1. 以 REST APIs 发送 JSON 格式数据

2. 数据建立索引- 所有字段都可以搜索,包括嵌套JSON

3. 通过 REST APIs 查询,字段匹配,Boolean 表达式,包括排序和分析

1

2

3

用户、分析师、运维、安全

Page 13: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

AWS Cloud

服务架构

VPC

Data Nodes Master Nodes

AWS Management

Console

AWS Command Line Interface

AWS Tools and SDKs

AWS CloudFormation

AWS Identity and

Access

Management

(IAM)

Elastic Load Balancing

(ELB)

AWS

CloudTrail

Amazon

CloudWatch

AWS Database

Migration

Service

Amazon Kinesis

Data FirehoseAmazon

CloudWatch

Logs

Amazon ES Domain

Page 14: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

搜索

Page 15: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

搜索流程

展示 应用 数据库

CDN 页面 业务逻辑主要业务数据

高速数据:库存、点击、评分、位置

搜索内容

Amazon CloudFront Amazon EC2 Amazon EC2

Amazon RDS

Amazon DynamoDB

Amazon Elasticsearch

Service

Page 16: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

数据结构化:标题, 描述, 评分

搜索文档分类结构化

Page 17: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

{

"id" : "tt0371746",

"title" : "Iron Man",

"release_date" : "2008-04-14T00:00:00Z",

"actors" : [

"Robert Downey Jr.",

"Gwyneth Paltrow",

"Terrence Howard"

],

"directors" : [

"Jon Favreau"

],

"rating" : 7.9,

"rank" : 171,

"running_time_secs" : 7560,

"genres" : [

"Action",

"Adventure",

"Sci-Fi"

],

"plot" : "When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.",

}

Elasticsearch 以结构化JSON 存储字段和值

Page 18: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

以 API 方式发送数据到 Elasticsearch

POST endpoint/index/type/id{

Document

}

POST endpoint/index/_bulk{ Command }

{ Document }

{ Command }

{ Document }

一般采用自动化的注入工具

Page 19: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

通过查询 API 从 Elasticsearch 获取数据

Amazon ES Domain

Page 20: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

查询引擎匹配请求字段和值

ID

Field: value

Field: value

Field: value

Field: value

Page 21: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

All docs

1/51/5 1/5 1/5 1/5

Index

ID

Field: value

Field: value

Field: value

Field: value

数据存储于由分片构成的索引

Page 22: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

分片:主分片或者副本

Index

主分片

副本

ID

Field: value

Field: value

Field: value

Field: value

Page 23: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Elasticsearch 分片分布到数据节点

查询

更新

Page 24: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

UltraWarm: Amazon Elasticsearch 新存储层

Page 25: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

UltraWarm 架构

Amazon S3

Active Backup Backup

UltraWarm UltraWarm UltraWarm

Data

Node

Data

Node

Data

NodeData

Node

Kibana

Page 26: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

UltraWarm 存储: 优化成本,扩展和持久性

数据存储在 S3

无需副本和快照

100% 存储利用率

为所用存储付费

Page 27: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

UltraWarm 节点: 优化性能

性能提高:

• 命中缓存的查询热数据

• 未缓存的数据比之前磁盘类型的实例性能提高2倍

• 近期未缓存查询几秒内完成

• 优化的 Nitro 实例提供 S3 访问高带宽• 重要数据和元数据分级缓存• 优化查询引擎,从 S3 预取数据到本地• 无论数据在本地缓存还是 S3,查询完全透明,

无需修改现有程序

Page 28: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

日志分析

Page 29: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

每行日志都有多个字段,包含搜索和分析所需要的数据

Page 30: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

日志数据聚合分析

Amazon ES Domain

Page 31: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

按照日期创建索引

创建索引以特定字符串开头,例如 logs_

按照数据量,设置特定间隔,例如每天

按天创建索引简化管理。删除最旧的索引释放空间

logs_11.26.2018

logs_11.25.2018

logs_11.24.2018

logs_11.23.2018

logs_11.22.2018

logs_11.21.2018

logs_11.20.2018

Page 32: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Kibana:轻量实时的可视化工具

Page 33: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Kibana 展示的后台过程

Page 34: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

日志分析流程

数据生成 收集

持久存储

转换

分析报告

Page 35: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Amazon S3 事件触发

Page 36: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Amazon Kinesis 方法

Page 37: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Amazon Kinesis Firehose 方法

Page 38: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

数据安全

• 与 DNS 终端节点交互• Cognito 验证以及第三方集成• VPC 限制 IP

• IAM 控制访问• KMS 本地加密

• TLS 传输加密

Instance

Storage

Page 39: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

CloudWatch 监控集群

Page 40: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

CloudWatch logs 检查 Elasticsearch 日志

• 控制台简单设置• 集成 CloudWatch Logs

• 设置阈值以记录慢查询和慢索引

• 查看 ERROR 和 WARN日志

查询更新

搜索慢速日志

索引慢速日志

错误日志

Page 41: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

简单配置主节点

• 主节点作为协调,集群高可用• 支持 3 个主节点• 可配置 1 或者 3 可用区

Amazon ES Domain

VPC

Availability Zone 1

Availability Zone 2

Page 42: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

一键高可用方案

Elasticsearch

data node

Elasticsearch

master node

Availability Zone 1 Availability Zone 2 Availability Zone 3

Elasticsearch

data node

Elasticsearch

master nodeElasticsearch

master node

Elasticsearch

data node

Page 43: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

基于日志发送警报定义监控触发器和动作 数据可视化或者查询 发送通知到 SNS, Slack,

或者自定义方式

Page 44: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

如何收费

实例, EBS 存储, 数据传输

预留实例更加节省费用

Page 45: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Apache 2.0 - 许可分发的增强版 Elasticsearch企业级安全警报SQL 支持

Page 46: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Open Distro for Elasticsearch – 特性

安全

处理加密,细粒度访问控制,审计日志,合规

警报

监控数据并自动发送警报

SQL

支持 SQL 查询

性能分析器

分析性能瓶颈

Page 47: Amazon Elasticsearch · 2020-04-30 · 在 aws 构建统一的日志管理方案,统一跨应用的日志分析接口 应用流数据通过 Kinesis Firehose 到 S3/Athena 和 Amazon

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

我们希望您在这里找到感兴趣的内容!

也请帮助我们完成投票打分和反馈问卷。

欲获取关于 AWS 的更多信息和技术内容,可以通过以下方式找到我们:

感谢参加 AWS INNOVATE 2020 在线技术大会

微信订阅号:AWS 云计算(awschina)

新浪微博:https://www.weibo.com/amazonaws/

视频中心:http://aws.amazon.bokecc.com/

更多线上活动 :https://aws.amazon.com/cn/about-aws/events/webinar/

微信服务号:AWS Builder 俱乐部(amazonaws)

抖音:亚马逊云计算(抖音号:266052872)

博客:https://aws.amazon.com/cn/blogs/china/

AWS 中国账户注册

AWS 全球账户注册