本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Amazon OpenSearch Service 的跟踪分析
您可以使用 OpenSearch 可观察性插件中包含的跟踪分析,从而分析来自分布式应用程序的跟踪数据。Trace Analytics 需要 OpenSearch 或 Elasticsearch 7.9 或更高版本。
在分布式应用程序中,单个操作(如用户单击按钮)可触发一系列扩展事件。例如,应用程序前端可能会调用后端服务,后端服务调用另一个服务,该服务可查询数据库,该服务处理查询并返回结果。然后,第一个后端服务向前端发送确认,这将更新 UI。
您可以使用跟踪分析来帮助您可视化此事件流并识别性能问题。
注意
本文档简要概述了跟踪分析。有关全面的文档,请参阅开源 OpenSearch 文档中的 Trace Analytics
先决条件
跟踪分析要求您将工具
将工具插入添加到应用程序后,OpenTelemetry Collector
最后,您可以使用 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 方法和路径将跟踪组合在一起,以便您可以查看与特定操作相关的平均延迟、错误率和趋势。对于更集中的视图,请尝试按跟踪组名称进行筛选。
要向下钻取组成跟踪组的迹线,请选择右侧列中的迹线数。然后选择一个单独的跟踪获取详细的摘要。
服务视图列出了应用程序中的所有服务,以及显示各种服务之间如何相互连接的交互式地图。与控制面板(有助于按操作识别问题)不同,服务图可帮助您按服务识别问题。尝试按错误率或延迟进行排序,了解应用程序的潜在问题区域。