diff --git a/apis/fluentbit/v1alpha2/clusteroutput_types_test.go b/apis/fluentbit/v1alpha2/clusteroutput_types_test.go index 23b24ed93..f7665d0da 100644 --- a/apis/fluentbit/v1alpha2/clusteroutput_types_test.go +++ b/apis/fluentbit/v1alpha2/clusteroutput_types_test.go @@ -444,8 +444,8 @@ func TestLokiOutputWithStructuredMetadata_Load(t *testing.T) { "trace_id": "${record['trace_id']}", }, StructuredMetadataKeys: []string{ - "level", - "caller", + "$kubernetes['labels']", + "$kubernetes['annotations']", }, }, }, @@ -462,7 +462,7 @@ func TestLokiOutputWithStructuredMetadata_Load(t *testing.T) { port 3100 labels environment=production,job=fluentbit structured_metadata container=${record['kubernetes']['container_name']},pod=${record['kubernetes']['pod_name']},trace_id=${record['trace_id']} - structured_metadata_keys level,caller + structured_metadata_map_keys $kubernetes['labels'],$kubernetes['annotations'] ` result, err := outputs.Load(sl) @@ -497,8 +497,8 @@ func TestLokiOutputWithStructuredMetadata_LoadAsYaml(t *testing.T) { "trace_id": "${record['trace_id']}", }, StructuredMetadataKeys: []string{ - "level", - "caller", + "$kubernetes['labels']", + "$kubernetes['annotations']", }, }, }, @@ -515,7 +515,7 @@ func TestLokiOutputWithStructuredMetadata_LoadAsYaml(t *testing.T) { port: 3100 labels: environment=production,job=fluentbit structured_metadata: container=${record['kubernetes']['container_name']},pod=${record['kubernetes']['pod_name']},trace_id=${record['trace_id']} - structured_metadata_keys: level,caller + structured_metadata_map_keys: $kubernetes['labels'],$kubernetes['annotations'] ` result, err := outputs.LoadAsYaml(sl, 0) diff --git a/apis/fluentbit/v1alpha2/plugins/output/loki_types.go b/apis/fluentbit/v1alpha2/plugins/output/loki_types.go index 4c1709f59..8d1a68473 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/loki_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/loki_types.go @@ -61,8 +61,9 @@ type Loki struct { // This is used for high cardinality data that isn't suited for using labels. // Only supported in Loki 3.0+ with schema v13 and TSDB storage. StructuredMetadata map[string]string `json:"structuredMetadata,omitempty"` - // Optional list of record keys that will be placed as structured metadata. - // This allows using record accessor patterns (e.g. $kubernetes['pod_name']) to reference record keys. + // Optional list of record keys whose values are maps, written as structured_metadata_map_keys. + // Every key/value pair of those maps is added as structured metadata (e.g. $kubernetes['labels']). + // Requires Fluent Bit 4.0+. StructuredMetadataKeys []string `json:"structuredMetadataKeys,omitempty"` *plugins.TLS `json:"tls,omitempty"` // Include fluentbit networking options for this output-plugin @@ -164,7 +165,7 @@ func (l *Loki) Params(sl plugins.SecretLoader) (*params.KVs, error) { } if len(l.StructuredMetadataKeys) > 0 { - kvs.Insert("structured_metadata_keys", strings.Join(l.StructuredMetadataKeys, ",")) + kvs.Insert("structured_metadata_map_keys", strings.Join(l.StructuredMetadataKeys, ",")) } return kvs, nil diff --git a/charts/fluent-operator-fluent-bit-crds/templates/fluentbit.fluent.io_clusteroutputs.yaml b/charts/fluent-operator-fluent-bit-crds/templates/fluentbit.fluent.io_clusteroutputs.yaml index 89ddcd91c..9179f13ba 100644 --- a/charts/fluent-operator-fluent-bit-crds/templates/fluentbit.fluent.io_clusteroutputs.yaml +++ b/charts/fluent-operator-fluent-bit-crds/templates/fluentbit.fluent.io_clusteroutputs.yaml @@ -2778,8 +2778,9 @@ spec: type: object structuredMetadataKeys: description: |- - Optional list of record keys that will be placed as structured metadata. - This allows using record accessor patterns (e.g. $kubernetes['pod_name']) to reference record keys. + Optional list of record keys whose values are maps, written as structured_metadata_map_keys. + Every key/value pair of those maps is added as structured metadata (e.g. $kubernetes['labels']). + Requires Fluent Bit 4.0+. items: type: string type: array diff --git a/charts/fluent-operator-fluent-bit-crds/templates/fluentbit.fluent.io_outputs.yaml b/charts/fluent-operator-fluent-bit-crds/templates/fluentbit.fluent.io_outputs.yaml index 9eb164464..4923b89b9 100644 --- a/charts/fluent-operator-fluent-bit-crds/templates/fluentbit.fluent.io_outputs.yaml +++ b/charts/fluent-operator-fluent-bit-crds/templates/fluentbit.fluent.io_outputs.yaml @@ -2778,8 +2778,9 @@ spec: type: object structuredMetadataKeys: description: |- - Optional list of record keys that will be placed as structured metadata. - This allows using record accessor patterns (e.g. $kubernetes['pod_name']) to reference record keys. + Optional list of record keys whose values are maps, written as structured_metadata_map_keys. + Every key/value pair of those maps is added as structured metadata (e.g. $kubernetes['labels']). + Requires Fluent Bit 4.0+. items: type: string type: array diff --git a/charts/fluent-operator/crds/fluentbit.fluent.io_clusteroutputs.yaml b/charts/fluent-operator/crds/fluentbit.fluent.io_clusteroutputs.yaml index 1f2333798..8d49561d3 100644 --- a/charts/fluent-operator/crds/fluentbit.fluent.io_clusteroutputs.yaml +++ b/charts/fluent-operator/crds/fluentbit.fluent.io_clusteroutputs.yaml @@ -2776,8 +2776,9 @@ spec: type: object structuredMetadataKeys: description: |- - Optional list of record keys that will be placed as structured metadata. - This allows using record accessor patterns (e.g. $kubernetes['pod_name']) to reference record keys. + Optional list of record keys whose values are maps, written as structured_metadata_map_keys. + Every key/value pair of those maps is added as structured metadata (e.g. $kubernetes['labels']). + Requires Fluent Bit 4.0+. items: type: string type: array diff --git a/charts/fluent-operator/crds/fluentbit.fluent.io_outputs.yaml b/charts/fluent-operator/crds/fluentbit.fluent.io_outputs.yaml index d45cee613..814ef8d46 100644 --- a/charts/fluent-operator/crds/fluentbit.fluent.io_outputs.yaml +++ b/charts/fluent-operator/crds/fluentbit.fluent.io_outputs.yaml @@ -2776,8 +2776,9 @@ spec: type: object structuredMetadataKeys: description: |- - Optional list of record keys that will be placed as structured metadata. - This allows using record accessor patterns (e.g. $kubernetes['pod_name']) to reference record keys. + Optional list of record keys whose values are maps, written as structured_metadata_map_keys. + Every key/value pair of those maps is added as structured metadata (e.g. $kubernetes['labels']). + Requires Fluent Bit 4.0+. items: type: string type: array diff --git a/config/crd/bases/fluentbit.fluent.io_clusteroutputs.yaml b/config/crd/bases/fluentbit.fluent.io_clusteroutputs.yaml index 9db83b362..3a219b57c 100644 --- a/config/crd/bases/fluentbit.fluent.io_clusteroutputs.yaml +++ b/config/crd/bases/fluentbit.fluent.io_clusteroutputs.yaml @@ -2777,8 +2777,9 @@ spec: type: object structuredMetadataKeys: description: |- - Optional list of record keys that will be placed as structured metadata. - This allows using record accessor patterns (e.g. $kubernetes['pod_name']) to reference record keys. + Optional list of record keys whose values are maps, written as structured_metadata_map_keys. + Every key/value pair of those maps is added as structured metadata (e.g. $kubernetes['labels']). + Requires Fluent Bit 4.0+. items: type: string type: array diff --git a/config/crd/bases/fluentbit.fluent.io_outputs.yaml b/config/crd/bases/fluentbit.fluent.io_outputs.yaml index 341ccaeab..66e241a2d 100644 --- a/config/crd/bases/fluentbit.fluent.io_outputs.yaml +++ b/config/crd/bases/fluentbit.fluent.io_outputs.yaml @@ -2777,8 +2777,9 @@ spec: type: object structuredMetadataKeys: description: |- - Optional list of record keys that will be placed as structured metadata. - This allows using record accessor patterns (e.g. $kubernetes['pod_name']) to reference record keys. + Optional list of record keys whose values are maps, written as structured_metadata_map_keys. + Every key/value pair of those maps is added as structured metadata (e.g. $kubernetes['labels']). + Requires Fluent Bit 4.0+. items: type: string type: array diff --git a/docs/plugins/fluentbit/output/loki.md b/docs/plugins/fluentbit/output/loki.md index 220c9ca58..6b1d704a7 100644 --- a/docs/plugins/fluentbit/output/loki.md +++ b/docs/plugins/fluentbit/output/loki.md @@ -21,7 +21,7 @@ The loki output plugin, allows to ingest your records into a Loki service.