View a markdown version of this page

CloudWatch Metrics (OTel) - Amazon CloudWatch

CloudWatch Metrics (OTel)

選択基準により、処理のためにパイプラインに入る OTel メトリクスが決まります。各基準は、受信メトリクスの特定の属性に一致する <path> == "<value>" 形式の式です。少なくとも 1 つの選択基準が必要です。

条件は AND セマンティクスを使用して match_all ブロック内でグループ化されます。パイプラインに入るには、メトリクスがグループ内のすべての式と一致する必要があります。

サポートされているパス

選択基準では、次の OTTL パスがサポートされています。

パス 説明

resource.attributes["key"]

リソースレベル属性

instrumentation_scope.name

計装スコープ名

instrumentation_scope.version

計装スコープバージョン

instrumentation_scope.attributes["key"]

計装スコープ属性

metric.name

メトリクス名

datapoint.attributes["key"]

データポイントレベル属性

attributes["key"]

datapoint.attributes["key"] の短形式

設定

選択基準は、パイプライン設定の source セクションで定義されます。

pipeline: source: cloudwatch_metrics: format: otlp selection_criteria: - match_all: - 'resource.attributes["service.name"] == "my-service"' - 'metric.name == "http.server.request.duration"' processor: - add_attributes: attributes: - key: resource.attributes["team"] value: "platform-engineering" sink: - cloudwatch_metrics: {}

次の例では、サポートされているすべてのパスタイプを使用します。

pipeline: source: cloudwatch_metrics: format: otlp selection_criteria: - match_all: - 'resource.attributes["service.name"] == "my-service"' - 'instrumentation_scope.name == "my-scope"' - 'instrumentation_scope.version == "1.0.0"' - 'instrumentation_scope.attributes["library"] == "otel-java"' - 'metric.name == "http.server.request.duration"' - 'datapoint.attributes["status_code"] == "200"' - 'attributes["environment"] == "production"' processor: - add_attributes: attributes: - key: resource.attributes["team"] value: "observability" sink: - cloudwatch_metrics: {}

PromQL による検証

CloudWatch は、@ プレフィックス規則を使用して OTLP 属性スコープを PromQL ラベルにマッピングします。このマッピングを使用して、パイプラインが Query Studio で期待どおりにメトリクスを処理していることを確認します。

パイプライン OTTL パス PromQL ラベルプレフィックス

resource.attributes["key"]

@resource.

@resource.service.name

instrumentation_scope.name

@instrumentation.@name

@instrumentation.@name

instrumentation_scope.attributes["key"]

@instrumentation.

@instrumentation.library

datapoint.attributes["key"] / attributes["key"]

@datapoint. またはベア

status_code

たとえば、パイプラインが値 "platform-engineering" を含む resource.attributes["team"] を追加すると、それが適用されたことを確認できます。

{"CPUUtilization", "@resource.team"="platform-engineering"}

要件と制限

単一の match_all グループ

各パイプラインは、selection_criteria の中の 1 つの match_all グループのみをサポートします。1 つのパイプラインにおいて複数の match_all グループを定義することはできません。

最小基準

match_all グループには少なくとも 1 つの式が必要です。

最大基準

match_all グループには最大で 20 個の式を含めることができます。

AND セマンティクス

パイプラインに入るには、match_all グループ内のすべての式が一致している必要があります。

文字列の完全一致

値は静的文字列である必要があります。ワイルドカード、正規表現、部分一致はサポートされていません。各式は == 演算子を使用している必要があります。

パイプライン間で基準が重複しない

各メトリクスデータポイントが一致しなければならないパイプラインは多くても 1 つです。データポイントが新規と既存のパイプライン基準の両方に一致する場合、パイプラインの作成は失敗します。重複を防ぐために、各パイプラインの選択基準に、異なる値を含む属性パスを少なくとも 1 つ含めてください。

たとえば、パイプライン A は、パイプライン B がターゲットとする特定のメトリクスを含む payment-service からすべてのメトリクスを選択するため、次の 2 つの選択基準が重複します。

# Pipeline A — selects ALL metrics from payment-service selection_criteria: - match_all: - 'resource.attributes["service.name"] == "payment-service"' # Pipeline B — FAILS: a datapoint with service.name="payment-service" # and metric.name="http.server.request.duration" matches both pipelines selection_criteria: - match_all: - 'metric.name == "http.server.request.duration"'