Amazon OpenSearch Service 的追蹤分析
您可以使用屬於 OpenSearch 可觀測性外掛程式一部分的 Trace Analytics,分析來自分散式應用程式的追蹤資料。Trace Analytics 需要 OpenSearch 或 Elasticsearch 7.9 或更高版本。
在分散式應用程式中,單一操作 (例如使用者按一下按鈕) 可觸發一系列延伸事件。例如,應用程式前端可能會呼叫後端服務,這會呼叫另一個服務,查詢資料庫,處理查詢並傳回結果。然後,第一個後端服務會將確認傳送到前端,以便更新 UI。
您可以使用 Trace Analytics 來協助您將此事件流程視覺化並發現效能問題。

先決條件
Trace Analytics 需要您將檢測
在您將檢測新增到應用程式之後,OpenTelemetry Collector
最後,獨立的 OpenSearch 元件 Data Prepper
如需示範資料端對端流程的 Docker Compose 檔案,請參閱 OpenSearch 文件
OpenTelemetry Collector 範例組態
若要搭配使用 OpenTelemetry Collector 與 Data Prepper,請嘗試下列組態範例:
receivers: jaeger: protocols: grpc: otlp: protocols: grpc: zipkin: exporters: otlp/data-prepper: endpoint:
data-prepper-host
:21890 insecure: true service: pipelines: traces: receivers: [jaeger, otlp, zipkin] exporters: [otlp/data-prepper]
Data Prepper 組態範例
若要將追蹤資料傳送至 OpenSearch Service 網域,請嘗試下列組態範例檔案。
data-prepper-config.yaml
ssl: true keyStoreFilePath: "/usr/share/data-prepper/keystore.jks" # required if ssl is true keyStorePassword: "password" # optional, defaults to empty string privateKeyPassword: "other_password" # optional, defaults to empty string serverPort: 4900 # port for administrative endpoints, default is 4900
pipelines.yaml
entry-pipeline: # Workers is the number of application threads. # Try setting this value to the number of CPU cores on the machine. # We recommend the same number of workers for all pipelines. workers: 4 delay: "100" # milliseconds source: otel_trace_source: ssl: true sslKeyCertChainFile: "config/demo-data-prepper.crt" sslKeyFile: "config/demo-data-prepper.key" buffer: bounded_blocking: # Buffer size is the number of export requests to hold in memory. # We recommend the same value for all pipelines. # Batch size is the maximum number of requests each worker thread processes within the delay. # Keep buffer size >= number of workers * batch size. buffer_size: 1024 batch_size: 256 sink: - pipeline: name: "raw-pipeline" - pipeline: name: "service-map-pipeline" raw-pipeline: workers: 4 # We recommend the default delay for the raw pipeline. delay: "3000" source: pipeline: name: "entry-pipeline" prepper: - otel_trace_raw_prepper: buffer: bounded_blocking: buffer_size: 1024 batch_size: 256 sink: - opensearch: hosts: ["https://
domain-endpoint
"] # # Basic authentication # username: "ta-user" # password: "ta-password" # IAM signing aws_sigv4: true aws_region: "us-east-1
" trace_analytics_raw: true service-map-pipeline: workers: 4 delay: "100" source: pipeline: name: "entry-pipeline" prepper: - service_map_stateful: buffer: bounded_blocking: buffer_size: 1024 batch_size: 256 sink: - opensearch: hosts: ["https://domain-endpoint
"] # # Basic authentication # username: "ta-user" # password: "ta-password" # IAM signing aws_sigv4: true aws_region: "us-east-1
" trace_analytics_service_map: true
-
對於 IAM 簽署,請使用 AWS CLI 執行
aws configure
,以設定您的憑證。 -
如果您搭配使用精細存取控制與內部使用者資料庫,請改用基本身分驗證。
如果您的網域使用精細存取控制,則必須將 Data Prepper 使用者或角色映射至 all_access role。
如果您的網域不使用精細存取控制,Data Prepper 使用者或角色必須具有數個索引和範本的寫入許可,以及存取索引狀態管理 (ISM) 政策和擷取叢集設定的許可。下列政策顯示需要的許可。
{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::
123456789012
:user/data-prepper-sink-user
" }, "Action": "es:ESHttp*", "Resource": [ "arn:aws:es:us-east-1
:123456789012
:domain/domain-name
/otel-v1*", "arn:aws:es:us-east-1
:123456789012
:domain/domain-name
/_template/otel-v1*", "arn:aws:es:us-east-1
:123456789012
:domain/domain-name
/_plugins/_ism/policies/raw-span-policy", "arn:aws:es:us-east-1
:123456789012
:domain/domain-name
/_alias/otel-v1*" ] }, { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012
:user/data-prepper-sink-user
" }, "Action": "es:ESHttpGet", "Resource": "arn:aws:us-east-1
:123456789012
:domain/domain-name
/_cluster/settings" } ] }
Data Prepper 使用連接埠 21890 接收資料,並且必須能夠連線至 OpenTelemetry Collector 和 OpenSearch 叢集。若要調整效能,請調整組態檔案中的工作者計數和緩衝區設定,以及機器的 Java 虛擬機器 (JVM) 堆積大小。
如需 Data Prepper 的完整文件,請參閱 OpenSearch 文件
瀏覽追蹤資料
Dashboard (儀表板) 檢視會依 HTTP 方法和路徑將追蹤集中在一起,以便您可以查看與特定操作相關聯的平均延遲、錯誤率和趨勢。如需更詳細的檢視,請嘗試按照追蹤群組名稱進行篩選。

若要深入了解構成追蹤群組的追蹤,請在右欄中選擇追蹤數目。然後選擇個別追蹤以取得詳細摘要。
Services (服務) 檢視會列出應用程式中的所有服務,以及顯示各種服務如何彼此互連的互動式地圖。與儀表板 (可協助依操作發現問題) 相反,服務地圖可協助您透過服務發現問題。嘗試依錯誤率或延遲排序,以了解應用程式的潛在問題區域。
