View a markdown version of this page

指標管道處理器 - Amazon CloudWatch

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

指標管道處理器

指標管道處理器會在擷取期間轉換 OTel 指標資料點。指標管道最多可有 20 個處理器,依定義順序依序套用。

處理器使用 OTTL 路徑表達式來鎖定不同範圍內的屬性:

OTTL 路徑範圍
路徑 Scope (範圍) 範例

resource.attributes["key"]

資源層級

resource.attributes["service.name"]

instrumentation_scope.attributes["key"]

範圍屬性

instrumentation_scope.attributes["library"]

datapoint.attributes["key"]

Datapoint 層級

datapoint.attributes["status_code"]

attributes["key"]

資料點的簡短格式

attributes["environment"]

add_attributes 處理器

新增或覆寫指標資料點上的屬性。適用於所有時間類型。

OTTL 對等項目: set(attributes["key"], "value")

組態

使用下列參數設定 add_attributes 處理器:

processor: - add_attributes: attributes: - key: resource.attributes["team"] value: "payments" - key: attributes["environment"] value: "production" - key: instrumentation_scope.attributes["version"] value: "1.0" overwrite_if_key_exists: true
Parameters
attributes (必要)

要新增的屬性物件陣列。

attributes[].key (必要)

OTTL 屬性路徑,指定要新增屬性的位置。

attributes[].value (必要)

要指派的字串值。

attributes[].overwrite_if_key_exists (選用)

布林值。當 時true, 會覆寫現有的值。預設為 false。設為 時true,此操作會被視為破壞性操作,不適用於累積指標或付費指標。

delete_attributes 處理器

從指標資料點移除特定屬性。不適用於累積指標或付費指標。

OTTL 對等項目: delete_key(attributes, "key")

組態

使用下列參數設定 delete_attributes 處理器:

processor: - delete_attributes: with_keys: - resource.attributes["obsolete"] - attributes["temp"] - datapoint.attributes["debug"]
Parameters
with_keys (必要)

要移除的 OTTL 屬性路徑陣列。

rename_attributes 處理器

重新命名指標資料點上的屬性索引鍵。不適用於累積指標或付費指標。

OTTL 對等項目: set() + delete_key()

組態

使用下列參數設定 rename_attributes 處理器:

processor: - rename_attributes: attributes: - from_key: resource.attributes["old_key"] to_key: resource.attributes["new_key"] overwrite_if_to_key_exists: true
Parameters
attributes (必要)

重新命名操作的陣列。

attributes[].from_key (必要)

來源 OTTL 屬性路徑。

attributes[].to_key (必要)

目標 OTTL 屬性路徑。

attributes[].overwrite_if_to_key_exists (選用)

布林值。當 時true, 會在目標金鑰存在時覆寫 。預設為 false

rename_metrics 處理器

重新命名指標名稱。不適用於累積指標或付費指標。

OTTL 對等項目: set(name, "new.metric.name") where name == "old.metric.name"

組態

使用下列參數設定 rename_metrics 處理器:

processor: - rename_metrics: metrics: - from: "old.metric.name" to: "new.metric.name"
Parameters
metrics (必要)

重新命名操作的陣列。

metrics[].from (必要)

目前的指標名稱。

metrics[].to (必要)

新的指標名稱。

substitute_attribute_values 處理器

透過查詢資料表映射屬性值。不適用於累積指標或付費指標。

OTTL 對等項目: replace_match()

組態

使用下列參數設定 substitute_attribute_values 處理器:

processor: - substitute_attribute_values: attributes: - key: resource.attributes["region"] from: "us-east-1a" to: "us-east-1"
Parameters
attributes (必要)

替換操作陣列。

attributes[].key (必要)

要比對的 OTTL 屬性路徑。

attributes[].from (必要)

要比對的值。

attributes[].to (必要)

取代值。

完整範例

下列範例使用單一管道中的所有五個處理器:

pipeline: source: cloudwatch_metrics: format: otlp selection_criteria: - match_all: - 'resource.attributes["service.name"] == "my-service"' - 'metric.name == "CPUUtilization"' processor: - add_attributes: attributes: - key: resource.attributes["env"] value: "prod" overwrite_if_key_exists: true - delete_attributes: with_keys: - resource.attributes["internal.trace"] - rename_attributes: attributes: - from_key: resource.attributes["old_key"] to_key: resource.attributes["new_key"] - rename_metrics: metrics: - from: "CPUUtilization" to: "system.cpu.utilization" - substitute_attribute_values: attributes: - key: resource.attributes["environment"] from: "dev" to: "development" sink: - cloudwatch_metrics: {}

處理器相容性和限制

處理器上限

指標管道最多可以有 20 個處理器。

破壞性處理器和時間性

破壞性處理器 (delete_attributessubstitute_attribute_values、、 rename_attributes rename_metricsadd_attributes搭配 overwrite_if_key_exists: true) 不適用於累積指標或付費指標。這些指標會以不變的方式傳遞。

已取代的指標保護

破壞性處理器無法修改 以 instrumentation_scope.name開頭的指標cloudwatch.aws/。這些指標會以不變的方式傳遞。