Skip to content

Commit bd1ea23

Browse files
authored
feat(operator)!: Add configuration option for dropping OTLP attributes (#15857)
1 parent 83339cb commit bd1ea23

24 files changed

+1027
-1046
lines changed

‎operator/api/loki/v1/lokistack_types.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,16 @@ type OpenshiftTenantSpec struct {
308308

309309
// OpenshiftOTLPConfig defines configuration specific to users using OTLP together with an OpenShift tenancy mode.
310310
type OpenshiftOTLPConfig struct {
311-
// DisableRecommendedAttributes can be used to reduce the number of attributes used for stream labels and structured
312-
// metadata.
311+
// DisableRecommendedAttributes can be used to reduce the number of attributes used as stream labels.
313312
//
314313
// Enabling this setting removes the "recommended attributes" from the generated Loki configuration. This will cause
315-
// meta information to not be available as stream labels or structured metadata, potentially making queries more
316-
// expensive and less performant.
314+
// some stream labels to disappear from the index, potentially making queries more expensive and less performant.
317315
//
318316
// Note that there is a set of "required attributes", needed for OpenShift Logging to work properly. Those will be
319317
// added to the configuration, even if this field is set to true.
320318
//
321-
// This option is supposed to be combined with a custom label configuration customizing the labels for the specific
322-
// usecase.
319+
// This option is supposed to be combined with a custom attribute configuration listing the stream labels that
320+
// should continue to exist.
323321
//
324322
// +optional
325323
// +kubebuilder:validation:Optional
@@ -827,8 +825,13 @@ type IngestionLimitSpec struct {
827825
PerStreamRateLimitBurst int32 `json:"perStreamRateLimitBurst,omitempty"`
828826
}
829827

830-
// OTLPSpec defines which resource, scope and log attributes should be used as stream labels or
831-
// stored as structured metadata.
828+
// OTLPSpec defines which resource, scope and log attributes should be used as stream labels or dropped before storing.
829+
//
830+
// Attributes need to be listed by their "OpenTelemetry name" and not the representation used by Loki. Please consult
831+
// the documentation of the collector or application emitting the OpenTelemetry data to find out which attributes
832+
// are emitted.
833+
//
834+
// Attributes not listed as stream labels or to be dropped are stored as structured metadata in Loki.
832835
type OTLPSpec struct {
833836
// StreamLabels configures which resource attributes are converted to Loki stream labels.
834837
//
@@ -837,12 +840,12 @@ type OTLPSpec struct {
837840
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Stream Labels"
838841
StreamLabels *OTLPStreamLabelSpec `json:"streamLabels,omitempty"`
839842

840-
// StructuredMetadata configures which attributes are saved in structured metadata.
843+
// Drop configures which attributes are dropped from the log entry.
841844
//
842845
// +optional
843846
// +kubebuilder:validation:Optional
844-
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Structured Metadata"
845-
StructuredMetadata *OTLPMetadataSpec `json:"structuredMetadata,omitempty"`
847+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Dropped Attributes"
848+
Drop *OTLPMetadataSpec `json:"drop,omitempty"`
846849
}
847850

848851
type OTLPStreamLabelSpec struct {

‎operator/api/loki/v1/v1.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ var (
9090
ErrOTLPTenantMissing = errors.New("if no global OTLP configuration is present which defines at least one stream label, every tenant must have an OTLP configuration")
9191
// ErrOTLPTenantNoStreamLabel when a tenant is defined but has no stream labels and there also no global stream labels.
9292
ErrOTLPTenantNoStreamLabel = errors.New("if no global OTLP configuration is present which defines at least one stream label, every tenant must define at least one stream label")
93+
// ErrOTLPInvalidDrop when a OTLP configuration tries to drop an attribute also listed as a stream label
94+
ErrOTLPInvalidDrop = errors.New("can not drop OTLP attribute also listed as a stream label")
9395

9496
// ErrRuleMustMatchNamespace indicates that an expression used in an alerting or recording rule is missing
9597
// matchers for a namespace.

‎operator/api/loki/v1/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎operator/bundle/community-openshift/manifests/loki-operator.clusterserviceversion.yaml

Lines changed: 61 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ metadata:
150150
categories: OpenShift Optional, Logging & Tracing
151151
certified: "false"
152152
containerImage: docker.io/grafana/loki-operator:0.7.1
153-
createdAt: "2025-01-16T18:30:58Z"
153+
createdAt: "2025-01-28T12:36:38Z"
154154
description: The Community Loki Operator provides Kubernetes native deployment
155155
and management of Loki and related logging components.
156156
features.operators.openshift.io/disconnected: "true"
@@ -373,62 +373,61 @@ spec:
373373
path: limits.global.ingestion.perStreamRateLimitBurst
374374
x-descriptors:
375375
- urn:alm:descriptor:com.tectonic.ui:number
376-
- description: StreamLabels configures which resource attributes are converted
377-
to Loki stream labels.
378-
displayName: Stream Labels
379-
path: limits.global.otlp.streamLabels
380-
- description: ResourceAttributes lists the names of the resource attributes
381-
that should be converted into Loki stream labels.
382-
displayName: Resource Attributes
383-
path: limits.global.otlp.streamLabels.resourceAttributes
384-
- description: Name contains either a verbatim name of an attribute or a regular
385-
expression matching many attributes.
386-
displayName: Name
387-
path: limits.global.otlp.streamLabels.resourceAttributes[0].name
388-
- description: If Regex is true, then Name is treated as a regular expression
389-
instead of as a verbatim attribute name.
390-
displayName: Treat name as regular expression
391-
path: limits.global.otlp.streamLabels.resourceAttributes[0].regex
392-
- description: StructuredMetadata configures which attributes are saved in structured
393-
metadata.
394-
displayName: Structured Metadata
395-
path: limits.global.otlp.structuredMetadata
376+
- description: Drop configures which attributes are dropped from the log entry.
377+
displayName: Dropped Attributes
378+
path: limits.global.otlp.drop
396379
- description: LogAttributes lists the names of log attributes that should be
397380
included in structured metadata.
398381
displayName: Log Attributes
399-
path: limits.global.otlp.structuredMetadata.logAttributes
382+
path: limits.global.otlp.drop.logAttributes
400383
- description: Name contains either a verbatim name of an attribute or a regular
401384
expression matching many attributes.
402385
displayName: Name
403-
path: limits.global.otlp.structuredMetadata.logAttributes[0].name
386+
path: limits.global.otlp.drop.logAttributes[0].name
404387
- description: If Regex is true, then Name is treated as a regular expression
405388
instead of as a verbatim attribute name.
406389
displayName: Treat name as regular expression
407-
path: limits.global.otlp.structuredMetadata.logAttributes[0].regex
390+
path: limits.global.otlp.drop.logAttributes[0].regex
408391
- description: ResourceAttributes lists the names of resource attributes that
409392
should be included in structured metadata.
410393
displayName: Resource Attributes
411-
path: limits.global.otlp.structuredMetadata.resourceAttributes
394+
path: limits.global.otlp.drop.resourceAttributes
412395
- description: Name contains either a verbatim name of an attribute or a regular
413396
expression matching many attributes.
414397
displayName: Name
415-
path: limits.global.otlp.structuredMetadata.resourceAttributes[0].name
398+
path: limits.global.otlp.drop.resourceAttributes[0].name
416399
- description: If Regex is true, then Name is treated as a regular expression
417400
instead of as a verbatim attribute name.
418401
displayName: Treat name as regular expression
419-
path: limits.global.otlp.structuredMetadata.resourceAttributes[0].regex
402+
path: limits.global.otlp.drop.resourceAttributes[0].regex
420403
- description: ScopeAttributes lists the names of scope attributes that should
421404
be included in structured metadata.
422405
displayName: Scope Attributes
423-
path: limits.global.otlp.structuredMetadata.scopeAttributes
406+
path: limits.global.otlp.drop.scopeAttributes
424407
- description: Name contains either a verbatim name of an attribute or a regular
425408
expression matching many attributes.
426409
displayName: Name
427-
path: limits.global.otlp.structuredMetadata.scopeAttributes[0].name
410+
path: limits.global.otlp.drop.scopeAttributes[0].name
428411
- description: If Regex is true, then Name is treated as a regular expression
429412
instead of as a verbatim attribute name.
430413
displayName: Treat name as regular expression
431-
path: limits.global.otlp.structuredMetadata.scopeAttributes[0].regex
414+
path: limits.global.otlp.drop.scopeAttributes[0].regex
415+
- description: StreamLabels configures which resource attributes are converted
416+
to Loki stream labels.
417+
displayName: Stream Labels
418+
path: limits.global.otlp.streamLabels
419+
- description: ResourceAttributes lists the names of the resource attributes
420+
that should be converted into Loki stream labels.
421+
displayName: Resource Attributes
422+
path: limits.global.otlp.streamLabels.resourceAttributes
423+
- description: Name contains either a verbatim name of an attribute or a regular
424+
expression matching many attributes.
425+
displayName: Name
426+
path: limits.global.otlp.streamLabels.resourceAttributes[0].name
427+
- description: If Regex is true, then Name is treated as a regular expression
428+
instead of as a verbatim attribute name.
429+
displayName: Treat name as regular expression
430+
path: limits.global.otlp.streamLabels.resourceAttributes[0].regex
432431
- description: CardinalityLimit defines the cardinality limit for index queries.
433432
displayName: Cardinality Limit
434433
path: limits.global.queries.cardinalityLimit
@@ -534,62 +533,61 @@ spec:
534533
path: limits.tenants.ingestion.perStreamRateLimitBurst
535534
x-descriptors:
536535
- urn:alm:descriptor:com.tectonic.ui:number
537-
- description: StreamLabels configures which resource attributes are converted
538-
to Loki stream labels.
539-
displayName: Stream Labels
540-
path: limits.tenants.otlp.streamLabels
541-
- description: ResourceAttributes lists the names of the resource attributes
542-
that should be converted into Loki stream labels.
543-
displayName: Resource Attributes
544-
path: limits.tenants.otlp.streamLabels.resourceAttributes
545-
- description: Name contains either a verbatim name of an attribute or a regular
546-
expression matching many attributes.
547-
displayName: Name
548-
path: limits.tenants.otlp.streamLabels.resourceAttributes[0].name
549-
- description: If Regex is true, then Name is treated as a regular expression
550-
instead of as a verbatim attribute name.
551-
displayName: Treat name as regular expression
552-
path: limits.tenants.otlp.streamLabels.resourceAttributes[0].regex
553-
- description: StructuredMetadata configures which attributes are saved in structured
554-
metadata.
555-
displayName: Structured Metadata
556-
path: limits.tenants.otlp.structuredMetadata
536+
- description: Drop configures which attributes are dropped from the log entry.
537+
displayName: Dropped Attributes
538+
path: limits.tenants.otlp.drop
557539
- description: LogAttributes lists the names of log attributes that should be
558540
included in structured metadata.
559541
displayName: Log Attributes
560-
path: limits.tenants.otlp.structuredMetadata.logAttributes
542+
path: limits.tenants.otlp.drop.logAttributes
561543
- description: Name contains either a verbatim name of an attribute or a regular
562544
expression matching many attributes.
563545
displayName: Name
564-
path: limits.tenants.otlp.structuredMetadata.logAttributes[0].name
546+
path: limits.tenants.otlp.drop.logAttributes[0].name
565547
- description: If Regex is true, then Name is treated as a regular expression
566548
instead of as a verbatim attribute name.
567549
displayName: Treat name as regular expression
568-
path: limits.tenants.otlp.structuredMetadata.logAttributes[0].regex
550+
path: limits.tenants.otlp.drop.logAttributes[0].regex
569551
- description: ResourceAttributes lists the names of resource attributes that
570552
should be included in structured metadata.
571553
displayName: Resource Attributes
572-
path: limits.tenants.otlp.structuredMetadata.resourceAttributes
554+
path: limits.tenants.otlp.drop.resourceAttributes
573555
- description: Name contains either a verbatim name of an attribute or a regular
574556
expression matching many attributes.
575557
displayName: Name
576-
path: limits.tenants.otlp.structuredMetadata.resourceAttributes[0].name
558+
path: limits.tenants.otlp.drop.resourceAttributes[0].name
577559
- description: If Regex is true, then Name is treated as a regular expression
578560
instead of as a verbatim attribute name.
579561
displayName: Treat name as regular expression
580-
path: limits.tenants.otlp.structuredMetadata.resourceAttributes[0].regex
562+
path: limits.tenants.otlp.drop.resourceAttributes[0].regex
581563
- description: ScopeAttributes lists the names of scope attributes that should
582564
be included in structured metadata.
583565
displayName: Scope Attributes
584-
path: limits.tenants.otlp.structuredMetadata.scopeAttributes
566+
path: limits.tenants.otlp.drop.scopeAttributes
585567
- description: Name contains either a verbatim name of an attribute or a regular
586568
expression matching many attributes.
587569
displayName: Name
588-
path: limits.tenants.otlp.structuredMetadata.scopeAttributes[0].name
570+
path: limits.tenants.otlp.drop.scopeAttributes[0].name
589571
- description: If Regex is true, then Name is treated as a regular expression
590572
instead of as a verbatim attribute name.
591573
displayName: Treat name as regular expression
592-
path: limits.tenants.otlp.structuredMetadata.scopeAttributes[0].regex
574+
path: limits.tenants.otlp.drop.scopeAttributes[0].regex
575+
- description: StreamLabels configures which resource attributes are converted
576+
to Loki stream labels.
577+
displayName: Stream Labels
578+
path: limits.tenants.otlp.streamLabels
579+
- description: ResourceAttributes lists the names of the resource attributes
580+
that should be converted into Loki stream labels.
581+
displayName: Resource Attributes
582+
path: limits.tenants.otlp.streamLabels.resourceAttributes
583+
- description: Name contains either a verbatim name of an attribute or a regular
584+
expression matching many attributes.
585+
displayName: Name
586+
path: limits.tenants.otlp.streamLabels.resourceAttributes[0].name
587+
- description: If Regex is true, then Name is treated as a regular expression
588+
instead of as a verbatim attribute name.
589+
displayName: Treat name as regular expression
590+
path: limits.tenants.otlp.streamLabels.resourceAttributes[0].regex
593591
- description: Blocked defines the list of rules to block matching queries.
594592
displayName: Blocked
595593
path: limits.tenants.queries.blocked
@@ -1013,21 +1011,19 @@ spec:
10131011
displayName: OpenTelemetry Protocol
10141012
path: tenants.openshift.otlp
10151013
- description: |-
1016-
DisableRecommendedAttributes can be used to reduce the number of attributes used for stream labels and structured
1017-
metadata.
1014+
DisableRecommendedAttributes can be used to reduce the number of attributes used as stream labels.
10181015
10191016
10201017
Enabling this setting removes the "recommended attributes" from the generated Loki configuration. This will cause
1021-
meta information to not be available as stream labels or structured metadata, potentially making queries more
1022-
expensive and less performant.
1018+
some stream labels to disappear from the index, potentially making queries more expensive and less performant.
10231019
10241020
10251021
Note that there is a set of "required attributes", needed for OpenShift Logging to work properly. Those will be
10261022
added to the configuration, even if this field is set to true.
10271023
10281024
1029-
This option is supposed to be combined with a custom label configuration customizing the labels for the specific
1030-
usecase.
1025+
This option is supposed to be combined with a custom attribute configuration listing the stream labels that
1026+
should continue to exist.
10311027
displayName: Disable recommended OTLP attributes
10321028
path: tenants.openshift.otlp.disableRecommendedAttributes
10331029
statusDescriptors:

0 commit comments

Comments
 (0)