From 721681adb9691a27c794826c578d912909a5c6f7 Mon Sep 17 00:00:00 2001 From: Anson Liu Date: Tue, 23 Jul 2024 07:09:49 +0000 Subject: [PATCH] add tag and tag_from_uri for opentelemetry input plugin Signed-off-by: Anson Liu --- .../v1alpha2/plugins/input/open_telemetry_types.go | 10 ++++++++++ .../v1alpha2/plugins/input/zz_generated.deepcopy.go | 5 +++++ .../crds/fluentbit.fluent.io_clusterinputs.yaml | 7 +++++++ .../crd/bases/fluentbit.fluent.io_clusterinputs.yaml | 7 +++++++ docs/plugins/fluentbit/input/open_telemetry.md | 2 ++ manifests/setup/fluent-operator-crd.yaml | 7 +++++++ manifests/setup/setup.yaml | 7 +++++++ 7 files changed, 45 insertions(+) diff --git a/apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go b/apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go index 2c5cf16d3..ca866e330 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go @@ -31,6 +31,10 @@ type OpenTelemetry struct { BufferChunkSize string `json:"bufferChunkSize,omitempty"` //It allows to set successful response code. 200, 201 and 204 are supported(default 201). SuccessfulResponseCode *int32 `json:"successfulResponseCode,omitempty"` + // opentelemetry uses the tag value for incoming metrics. + Tag string `json:"tag,omitempty"` + // If true, tag will be created from uri. e.g. v1_metrics from /v1/metrics + TagFromURI *bool `json:"tagFromURI,omitempty"` } func (_ *OpenTelemetry) Name() string { @@ -61,5 +65,11 @@ func (ot *OpenTelemetry) Params(_ plugins.SecretLoader) (*params.KVs, error) { if ot.SuccessfulResponseCode != nil { kvs.Insert("successful_response_code", fmt.Sprint(*ot.SuccessfulResponseCode)) } + if ot.Tag != "" { + kvs.Insert("tag", ot.Tag) + } + if ot.TagFromURI != nil { + kvs.Insert("tag_from_uri", fmt.Sprint(*ot.TagFromURI)) + } return kvs, nil } diff --git a/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go index 7c8928f38..f41c794cf 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go @@ -262,6 +262,11 @@ func (in *OpenTelemetry) DeepCopyInto(out *OpenTelemetry) { *out = new(int32) **out = **in } + if in.TagFromURI != nil { + in, out := &in.TagFromURI, &out.TagFromURI + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenTelemetry. diff --git a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml index f791b5f2b..42addc326 100644 --- a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml +++ b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml @@ -423,6 +423,13 @@ spec: and 204 are supported(default 201). format: int32 type: integer + tag: + description: opentelemetry uses the tag value for incoming metrics. + type: string + tagFromURI: + description: If true, tag will be created from uri. e.g. v1_metrics + from /v1/metrics + type: boolean tagKey: description: Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. diff --git a/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml b/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml index f791b5f2b..42addc326 100644 --- a/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml +++ b/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml @@ -423,6 +423,13 @@ spec: and 204 are supported(default 201). format: int32 type: integer + tag: + description: opentelemetry uses the tag value for incoming metrics. + type: string + tagFromURI: + description: If true, tag will be created from uri. e.g. v1_metrics + from /v1/metrics + type: boolean tagKey: description: Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. diff --git a/docs/plugins/fluentbit/input/open_telemetry.md b/docs/plugins/fluentbit/input/open_telemetry.md index 04c5b40ae..21bd1f0c6 100644 --- a/docs/plugins/fluentbit/input/open_telemetry.md +++ b/docs/plugins/fluentbit/input/open_telemetry.md @@ -12,3 +12,5 @@ The OpenTelemetry plugin allows you to ingest telemetry data as per the OTLP spe | bufferMaxSize | Specify the maximum buffer size in KB to receive a JSON message(default 4M). | string | | bufferChunkSize | This sets the chunk size for incoming incoming JSON messages. These chunks are then stored/managed in the space available by buffer_max_size(default 512K). | string | | successfulResponseCode | It allows to set successful response code. 200, 201 and 204 are supported(default 201). | *int32 | +| tag | opentelemetry uses the tag value for incoming metrics. | string | +| tagFromURI | If true, tag will be created from uri. e.g. v1_metrics from /v1/metrics | *bool | diff --git a/manifests/setup/fluent-operator-crd.yaml b/manifests/setup/fluent-operator-crd.yaml index 1309ba3d7..338455f32 100644 --- a/manifests/setup/fluent-operator-crd.yaml +++ b/manifests/setup/fluent-operator-crd.yaml @@ -2370,6 +2370,13 @@ spec: and 204 are supported(default 201). format: int32 type: integer + tag: + description: opentelemetry uses the tag value for incoming metrics. + type: string + tagFromURI: + description: If true, tag will be created from uri. e.g. v1_metrics + from /v1/metrics + type: boolean tagKey: description: Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. diff --git a/manifests/setup/setup.yaml b/manifests/setup/setup.yaml index 84a696f80..798e0319e 100644 --- a/manifests/setup/setup.yaml +++ b/manifests/setup/setup.yaml @@ -2370,6 +2370,13 @@ spec: and 204 are supported(default 201). format: int32 type: integer + tag: + description: opentelemetry uses the tag value for incoming metrics. + type: string + tagFromURI: + description: If true, tag will be created from uri. e.g. v1_metrics + from /v1/metrics + type: boolean tagKey: description: Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key.