OTel Collector Agent Processing

Overview

The OpenTelemetry Collector provides a set of processors and connectors that let you reshape telemetry data before it reaches Kloudfuse. This page covers metric processing patterns using the transform processor.

Replace <kloudfuse-hostname> with your Kloudfuse cluster hostname and <api-key> with your Kloudfuse API key.

Metric Processing

Drop Labels and Aggregate Metrics

Use the transform processor to remove attributes from metric datapoints, then use groupbyattrs to re-aggregate datapoints that now share the same attribute set:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  transform/drop_labels:
    metric_statements:
      - context: datapoint
        statements:
          - delete_key(attributes, "pod_id")
          - delete_key(attributes, "container_id")

  groupbyattrs/aggregate:
    keys:
      - service.name
      - environment

exporters:
  otlp:
    endpoint: https://<kloudfuse-hostname>/ingester/otlp
    headers:
      Kf-Api-Key: <api-key>

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [transform/drop_labels, groupbyattrs/aggregate]   (1)
      exporters: [otlp]
yaml
1 Order matters: transform/drop_labels runs first to remove the attributes, then groupbyattrs/aggregate sums the datapoints that now share the same key set.

Drop High-Cardinality Labels

Remove attributes that create an unbounded number of time series — such as request IDs, user IDs, or raw URLs — before they reach Kloudfuse:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  transform/drop_high_cardinality:
    metric_statements:
      - context: datapoint
        statements:
          - delete_key(attributes, "request_id")
          - delete_key(attributes, "user_id")
          - replace_pattern(attributes["http.target"], "\\?.*$", "")   (1)

exporters:
  otlp:
    endpoint: https://<kloudfuse-hostname>/ingester/otlp
    headers:
      Kf-Api-Key: <api-key>

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [transform/drop_high_cardinality]
      exporters: [otlp]
yaml
1 Strips query strings from the HTTP target attribute to normalize the label value and reduce cardinality.

Rename Metrics

Use the transform processor to rename metrics to a new name:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  transform/rename_metrics:
    metric_statements:
      - context: metric
        statements:
          - set(name, "http.server.request.duration") where name == "http_server_duration"
          - set(name, "process.cpu.utilization") where name == "process_cpu_usage"

exporters:
  otlp:
    endpoint: https://<kloudfuse-hostname>/ingester/otlp
    headers:
      Kf-Api-Key: <api-key>

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [transform/rename_metrics]
      exporters: [otlp]
yaml

Add Metrics Together to Create a New Metric

Rename both source metrics to the target name, then use groupbyattrs to sum the datapoints that now share the same attribute set into a single time series:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  transform/combine_metrics:
    metric_statements:
      - context: metric
        statements:
          - set(name, "http.requests.total")
            where name == "http.read.requests" or name == "http.write.requests"   (1)

  groupbyattrs/sum_combined:
    keys:
      - service.name
      - environment

exporters:
  otlp:
    endpoint: https://<kloudfuse-hostname>/ingester/otlp
    headers:
      Kf-Api-Key: <api-key>

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [transform/combine_metrics, groupbyattrs/sum_combined]
      exporters: [otlp]
yaml
1 Both source metrics are renamed to http.requests.total. groupbyattrs then sums the datapoints that share the same attribute set into a single combined time series.
This approach merges the original metrics into the new name. If you need to preserve the originals, use the routing connector to duplicate them through separate pipelines before renaming.

Drop Metrics by Name

Use the filter processor to drop metrics before they reach Kloudfuse. Each entry under metrics.metric: is a drop condition — any metric that matches is dropped and not forwarded. This is different from the transform processor, which modifies metrics rather than removing them.

To drop by exact name:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  filter/drop_by_name:
    metrics:
      metric:
        - 'name == "go.gc.duration"'
        - 'name == "process.runtime.go.mem.heap_alloc"'

exporters:
  otlp:
    endpoint: https://<kloudfuse-hostname>/ingester/otlp
    headers:
      Kf-Api-Key: <api-key>

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [filter/drop_by_name]
      exporters: [otlp]
yaml

To drop all metrics whose names match a regex pattern:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  filter/drop_by_regex:
    metrics:
      metric:
        - 'IsMatch(name, "^go\\.runtime\\..*")'    (1)
        - 'IsMatch(name, "^process\\.runtime\\..*")'

exporters:
  otlp:
    endpoint: https://<kloudfuse-hostname>/ingester/otlp
    headers:
      Kf-Api-Key: <api-key>

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [filter/drop_by_regex]
      exporters: [otlp]
yaml
1 Dots in metric names must be escaped as \\. in the regex because . matches any character.

To keep only metrics whose names match a pattern and drop everything else, use not to invert the drop condition. Because every entry under metrics.metric: is a drop condition, not IsMatch(…​) means "drop any metric that does not match" — which has the effect of keeping only the metrics that do match:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  filter/keep_by_regex:
    metrics:
      metric:
        - 'not IsMatch(name, "^http\\..*")'    (1)

exporters:
  otlp:
    endpoint: https://<kloudfuse-hostname>/ingester/otlp
    headers:
      Kf-Api-Key: <api-key>

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [filter/keep_by_regex]
      exporters: [otlp]
yaml
1 Drops any metric whose name does not start with http.. Only http.* metrics are forwarded to Kloudfuse.