Closed
Description
Component(s)
processor/transform
Is your feature request related to a problem? Please describe.
I'm using the transform processor to implement #27069 (waiting for the PR).
For this, I currently use where
clause to avoid errors. This leads to complex code:
transform/flatten-kubernetesEvents:
error_mode: ignore
log_statements:
- context: log
statements:
# https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/27069
- set(resource.attributes["k8s.namespace.name"], body["object"]["regarding"]["namespace"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"])
# - set(resource.attributes[Concat(["k8s.", ConvertCase(body["object"]["regarding"]["kind"], "lower"), ".name"], "")], body["object"]["regarding"]["name"])
- set(resource.attributes["k8s.application.name"], body["object"]["regarding"]["name"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"]) and
body["object"]["regarding"]["kind"] == "Application"
- set(resource.attributes["k8s.deployment.name"], body["object"]["regarding"]["name"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"]) and
body["object"]["regarding"]["kind"] == "Deployment"
- set(resource.attributes["k8s.job.name"], body["object"]["regarding"]["name"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"]) and
body["object"]["regarding"]["kind"] == "Job"
- set(resource.attributes["k8s.pod.name"], body["object"]["regarding"]["name"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"]) and
body["object"]["regarding"]["kind"] == "Pod"
- set(resource.attributes["k8s.replicaset.name"], body["object"]["regarding"]["name"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"]) and
body["object"]["regarding"]["kind"] == "ReplicaSet"
- set(resource.attributes["k8s.service.name"], body["object"]["regarding"]["name"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"]) and
body["object"]["regarding"]["kind"] == "Service"
- set(resource.attributes["k8s.tenant.name"], body["object"]["regarding"]["name"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"]) and
body["object"]["regarding"]["kind"] == "Tenant"
# More
- set(severity_number, SEVERITY_NUMBER_WARN)
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"]) and
body["object"]["type"] == "Warning"
- set(attributes["k8s.event.reason"], body["object"]["reason"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"])
- set(attributes["k8s.event.type"], body["object"]["type"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"])
- set(body, body["object"]["note"])
where IsMap(body) and IsMap(body["object"]) and IsMap(body["object"]["regarding"])
Describe the solution you'd like
I want to add :
include:
match_type: strict
attributes:
- key: k8s.resource.name
value: events
and remove most of the where
clauses.
Describe alternatives you've considered
No response
Additional context
No response