[processor/attributes] Get values from maps #33934
Labels
enhancement
New feature or request
needs triage
New item requiring triage
processor/attributes
Attributes processor
Component(s)
processor/attributes
Is your feature request related to a problem? Please describe.
The fluentforwardreceiver puts metadata about Pod in
.resourceLogs.scopeLogs.logRecords.attributes.kubernetes
, see a part of the data in yaml:If I'd like to forward the logs to Loki by lokiexporter, I have to configure the label filters, for example:
It works, because label filters will be
kubernetes_container_name
,kubernetes_host
,kubernetes_labels_app_kubernetes_io_name
,kubernetes_annotations_kubectl_kubernetes_io_default_container
(.
is converted to_
, see: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/lokiexporter/README.md#labels ), but does not conform to https://opentelemetry.io/docs/specs/semconv/resource/k8s/ and https://opentelemetry.io/docs/specs/semconv/attributes-registry/k8s/ .I've already renamed the
kubernetes
key tok8s
by below configuration:, but I'm unable to rename or copy from anything in the
kubernetes
map, because the attributesprocessor cannot access it.Whole json and yaml logs are attached:
log23_1.json.gz
log23_1.yaml.gz
Describe the solution you'd like
The solution will be an enhanced getter function, which can access inside the
kubernetes
map and can copy the value tok8s.x.y
ork8s.x.label.y
ork8s.x.annotation.y
key, conform to https://opentelemetry.io/docs/specs/semconv/resource/k8s/ and https://opentelemetry.io/docs/specs/semconv/attributes-registry/k8s/ . Example for the configuration:Technical details:
The
getSourceAttributeValue
call in func (ap *AttrProc) Process(ctx context.Context, logger *zap.Logger, attrs pcommon.Map) atINSERT
shoud be decorated by a new function, which works similar toThe func getAttribute(attr string, attributes pcommon.Map) (pcommon.Value, bool) .
It's a tradeoff, because is does not enable changing the map, it just support to create a new key under the
attributes
from a map value.Describe alternatives you've considered
Renaming the
kubernetes
key tok8s
is not enough to conform to https://opentelemetry.io/docs/specs/semconv/resource/k8s/ and https://opentelemetry.io/docs/specs/semconv/attributes-registry/k8s/ .Additional context
An example screenshot about Grafana Explorer with Loki datasource, after renaming the
kubernetes
attributes key tok8s
(seek8s_host
, instead ofk8s_node_name
and plurallabels
, which is deprecated at https://opentelemetry.io/docs/specs/semconv/attributes-registry/k8s/#k8s-deprecated-attributes :The text was updated successfully, but these errors were encountered: