View a markdown version of this page

Amazon CloudWatch 代理程式 - Amazon CloudWatch

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Amazon CloudWatch 代理程式

CloudWatch 代理程式建置在 OpenTelemetry Collector 上,因此您可以使用它來接收 OpenTelemetry 資料,並將其傳送至 CloudWatch OTLP 端點。對於大多數客戶而言,這是將 OpenTelemetry 遙測傳送至 CloudWatch 的建議方法,因為單一代理程式也可以為 CloudWatch Application Signals 和 CloudWatch Enhanced Container Insights 等精選體驗提供支援。

若要立即透過代理程式傳送 OpenTelemetry 資料,您可以在 YAML 中提供 OpenTelemetry 收集器組態,並將其附加到代理程式自己的組態。使用 CloudWatch 代理程式組態檔案啟動代理程式,然後附加 OpenTelemetry YAML 檔案:

/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -c file:/tmp/agent.json -s /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -c file:/tmp/otel.yaml -s

代理程式會在啟動時合併兩個組態,並記錄已解析的組態。為了避免與代理程式自動建立的管道發生合併衝突,請將自訂尾碼新增至 OpenTelemetry YAML 中的每個元件和管道名稱 (例如 otlphttp/cwagent)。

支援的 OpenTelemetry 元件

您可以在附加的 YAML 組態中設定下列 OpenTelemetry 元件。使用此處顯示的元件類型名稱做為 YAML 中的金鑰。

元件類型 可用的元件

接收者

otlp, prometheus, statsd, collectd, jmx, hostmetrics, filelog, tcplog, udplog, jaeger, zipkin, kafka, kubeletstats

處理器

batch, memory_limiter, filter, attributes, resource, resourcedetection, metricstransform, transform, cumulativetodelta, deltatocumulative, deltatorate, groupbyattrs, groupbytrace, k8sattributes, metricsgeneration, metricstarttime, probabilistic_sampler, span, tail_sampling

匯出工具

otlphttp, awsemf, awscloudwatchlogs, awsxray, prometheusremotewrite, debug

延伸模組

sigv4auth, headers_setter, file_storage, health_check, pprof, zpages

CloudWatch 代理程式僅支援將遙測寫入 AWS 目的地。

組態範例

下列範例會使用otlphttp匯出程式和 sigv4auth擴充功能,將每個訊號傳送至對應的 CloudWatch OTLP 端點。每個元件和管道名稱都會使用/cwagent尾碼,以避免與客服人員自動建立的管道發生衝突。將區域取代為您的 AWS 區域。

指標

receivers: otlp/cwagent: protocols: http: endpoint: 0.0.0.0:4318 processors: batch/cwagent: {} exporters: otlphttp/cwagent: metrics_endpoint: https://monitoring.region.amazonaws.com/v1/metrics auth: authenticator: sigv4auth/cwagent extensions: sigv4auth/cwagent: region: "region" service: "monitoring" service: extensions: [sigv4auth/cwagent] pipelines: metrics/cwagent: receivers: [otlp/cwagent] processors: [batch/cwagent] exporters: [otlphttp/cwagent]

日誌

receivers: otlp/cwagent: protocols: http: endpoint: 0.0.0.0:4318 exporters: otlphttp/cwagent: logs_endpoint: https://logs.region.amazonaws.com/v1/logs headers: x-aws-log-group: my-log-group x-aws-log-stream: default auth: authenticator: sigv4auth/cwagent extensions: sigv4auth/cwagent: region: "region" service: "logs" service: extensions: [sigv4auth/cwagent] pipelines: logs/cwagent: receivers: [otlp/cwagent] exporters: [otlphttp/cwagent]

追蹤

receivers: otlp/cwagent: protocols: http: endpoint: 0.0.0.0:4318 exporters: otlphttp/cwagent: traces_endpoint: https://xray.region.amazonaws.com/v1/traces auth: authenticator: sigv4auth/cwagent extensions: sigv4auth/cwagent: region: "region" service: "xray" service: extensions: [sigv4auth/cwagent] pipelines: traces/cwagent: receivers: [otlp/cwagent] exporters: [otlphttp/cwagent]
注意

將追蹤傳送至 OTLP 追蹤端點之前,請確定已啟用交易搜尋。