Amazon OpenSearch Service 的跟踪分析 - 亚马逊 OpenSearch 服务
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

Amazon OpenSearch Service 的跟踪分析

您可以使用 OpenSearch 可观察性插件中包含的跟踪分析,从而分析来自分布式应用程序的跟踪数据。Trace Analytics 需要 OpenSearch 或 Elasticsearch 7.9 或更高版本。

在分布式应用程序中,单个操作(如用户单击按钮)可触发一系列扩展事件。例如,应用程序前端可能会调用后端服务,后端服务调用另一个服务,该服务可查询数据库,该服务处理查询并返回结果。然后,第一个后端服务向前端发送确认,这将更新 UI。

您可以使用跟踪分析来帮助您可视化此事件流并识别性能问题。

注意

本文档简要概述了跟踪分析。有关全面的文档,请参阅开源 OpenSearch 文档中的 Trace Analytics

Trace analytics dashboard showing time spent by service and span detail for various operations.

先决条件

跟踪分析要求您将工具添加到应用程序中,并使用 OpenTelemetrt 支持的库生成跟踪数据,例如 Jaeger 或者 Zipkin。此步骤完全发生在 OpenSearch Service 之外。Amazon OpenTelemetry 文档的 Distro 包含许多可用帮助您入门的编程语言示例应用程序,包括 Java、Python、Go 和 JavaScript。

将工具插入添加到应用程序后,OpenTelemetry Collector 从应用程序接收数据并将其格式化为 OpenTelemetry 数据。请参阅 GitHub 上的接收器列表。AmazonOpenTelemetry 的 Distro 包括 Amazon X-Ray 接收器

最后,您可以使用 Amazon OpenSearch Ingestion 将该 OpenTelemetry 数据格式化,以便与 OpenSearch 结合使用。

OpenTelemetry Collector 示例配置

要将 OpenTelemetry Collector 与 Amazon OpenSearch Ingestion 一起使用,请尝试以下示例配置:

extensions: sigv4auth: region: "us-east-1" service: "osis" receivers: jaeger: protocols: grpc: exporters: otlphttp: traces_endpoint: "https://pipeline-endpoint.us-east-1.osis.amazonaws.com/opentelemetry.proto.collector.trace.v1.TraceService/Export" auth: authenticator: sigv4auth compression: none service: extensions: [sigv4auth] pipelines: traces: receivers: [jaeger] exporters: [otlphttp]

OpenSearch Ingestion 示例配置

若要将跟踪数据发送到 OpenSearch Service 域,请尝试以下示例 OpenSearch Ingestion 管道配置。有关创建管道的说明,请参阅创建 Amazon OpenSearch Ingestion 管道

version: "2" otel-trace-pipeline: source: otel_trace_source: "/${pipelineName}/ingest" processor: - trace_peer_forwarder: sink: - pipeline: name: "trace_pipeline" - pipeline: name: "service_map_pipeline" trace-pipeline: source: pipeline: name: "otel-trace-pipeline" processor: - otel_traces: sink: - opensearch: hosts: ["https://domain-endpoint"] index_type: trace-analytics-raw aws: # IAM role that OpenSearch Ingestion assumes to access the domain sink sts_role_arn: "arn:aws:iam::{account-id}:role/pipeline-role" region: "us-east-1" service-map-pipeline: source: pipeline: name: "otel-trace-pipeline" processor: - service_map: sink: - opensearch: hosts: ["https://domain-endpoint"] index_type: trace-analytics-service-map aws: # IAM role that the pipeline assumes to access the domain sink sts_role_arn: "arn:aws:iam::{account-id}:role/pipeline-role" region: "us-east-1"

您在 sts_role_arn 选项中指定的管道角色必须具有接收器的写权限。有关为管道角色配置权限的说明,请参阅在 Amazon OpenSearch Ingestion 中设置角色和用户

探索跟踪数据

控制面板视图按 HTTP 方法和路径将跟踪组合在一起,以便您可以查看与特定操作相关的平均延迟、错误率和趋势。对于更集中的视图,请尝试按跟踪组名称进行筛选。

Dashboard showing latency metrics for HTTP GET /dispatch trace group with 717.58 ms average latency.

要向下钻取组成跟踪组的迹线,请选择右侧列中的迹线数。然后选择一个单独的跟踪获取详细的摘要。

服务视图列出了应用程序中的所有服务,以及显示各种服务之间如何相互连接的交互式地图。与控制面板(有助于按操作识别问题)不同,服务图可帮助您按服务识别问题。尝试按错误率或延迟进行排序,了解应用程序的潜在问题区域。

Services dashboard showing performance metrics for 6 microservices, including latency and error rates.