I need to use transform to change descriptions in metrics on otel-collector. I'm starting the otel-collector with this command just to see if my configuration runs:
docker run --rm -v "$PWD/otel-collector-config.yaml:/otel-collector-config.yaml" \
--network host -p 127.0.0.1:8889:8889 -p 127.0.0.1:55679:55679 \
otel/opentelemetry-collector:0.103.0 --config otel-collector-config.yaml
I've got this configuration:
transform:
metric_statements:
- context: metric
statements:
- set(description, "Number of all requests") where name == "undertow_request_count_total"
receivers:
otlp:
protocols:
grpc:
http:
exporters:
prometheus:
endpoint: "0.0.0.0:8889"
debug:
verbosity: detailed
logging:
loglevel: debug
service:
pipelines:
metrics:
receivers: [otlp]
# processors: []
exporters: [prometheus, debug]
I get this error:
Error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding:
* '' has invalid keys: transform
2024/06/22 06:41:49 collector server run finished with error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding:
* '' has invalid keys: transform
I understand from the error that the transform should not go where I've set it, but I don't understand where else to put it. The documentation for the transform processor isn't helping me much since all examples here look like mine.
Update 2024-06-26:
Tried to use the change Shiva Pundir suggested:
processors:
transform:
metric_statements:
- context: metric
statements:
- set(description, "Number of all requests") where name == "undertow_request_count_total"
...
... gave me this error:
Error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding:
* error decoding 'processors': unknown type: "transform" for id: "transform" (valid values: [probabilistic_sampler filter batch memory_limiter attributes resource span])
2024/06/26 10:48:49 collector server run finished with error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding:
* error decoding 'processors': unknown type: "transform" for id: "transform" (valid values: [probabilistic_sampler filter batch memory_limiter attributes resource span])
I think you are using the otel-collector-contrib (indicated by otel/opentelemetry-collector:0.103.0
). Instead you should be using otel/opentelemetry-collector-contrib:0.103.0
.
In general, the contrib is the superset of all components possible. While core only consists of components which are stable.
The transform
processor is not available in the core binary (See the box with Distributions
- https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor#transform-processor)
Try this
docker run --rm -v "$PWD/otel-collector-config.yaml:/otel-collector-config.yaml" \
--network host -p 127.0.0.1:8889:8889 -p 127.0.0.1:55679:55679 \
otel/opentelemetry-collector-contrib:0.103.1 --config otel-collector-config.yaml