From aa58fe3f4ce361608b4069c35ace897b5f979479 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Tue, 22 Oct 2024 17:53:12 +0200 Subject: [PATCH] feat: add support for Remote Write v2.0 This change includes the following: * New `messageVersion` field to the remote write configuration to select between v1 and v2 message formats. * New `remoteWriteReceiverMessageVersions` to select which message format(s) to accept when the remote receiver is configured. * Stricter validation for the remote write's URL (not breaking since an empty URL value would already fail the Prometheus configuration loading) Signed-off-by: Simon Pasquier --- CHANGELOG.md | 1 + Documentation/api.md | 124 ++++++++++++++++++ bundle.yaml | 66 ++++++++++ ...onitoring.coreos.com_prometheusagents.yaml | 33 +++++ .../monitoring.coreos.com_prometheuses.yaml | 33 +++++ ...onitoring.coreos.com_prometheusagents.yaml | 33 +++++ .../monitoring.coreos.com_prometheuses.yaml | 33 +++++ .../prometheusagents-crd.json | 22 ++++ .../prometheus-operator/prometheuses-crd.json | 22 ++++ pkg/apis/monitoring/v1/prometheus_types.go | 41 +++++- .../monitoring/v1/zz_generated.deepcopy.go | 15 +++ .../monitoring/v1/commonprometheusfields.go | 11 ++ .../monitoring/v1/prometheusspec.go | 10 ++ .../monitoring/v1/remotewritespec.go | 9 ++ .../v1alpha1/prometheusagentspec.go | 10 ++ pkg/prometheus/common.go | 19 +++ pkg/prometheus/common_test.go | 65 +++++++++ pkg/prometheus/promcfg.go | 24 +++- pkg/prometheus/promcfg_test.go | 16 +++ pkg/prometheus/server/statefulset_test.go | 74 ++++++++--- ...WriteConfig_v2.53.0_MessageVersion2.golden | 10 ++ ...WriteConfig_v2.54.0_MessageVersion2.golden | 11 ++ test/e2e/prometheus_test.go | 101 ++++++++++++++ test/framework/prometheus.go | 12 +- 24 files changed, 771 insertions(+), 24 deletions(-) create mode 100644 pkg/prometheus/testdata/RemoteWriteConfig_v2.53.0_MessageVersion2.golden create mode 100644 pkg/prometheus/testdata/RemoteWriteConfig_v2.54.0_MessageVersion2.golden diff --git a/CHANGELOG.md b/CHANGELOG.md index e80b786ed..16b3c0718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * [CHANGE] Allow overlapping compactions by default in Prometheus when the Thanos sidecar is configured with uploads. #6906 * [FEATURE] Add `dnsConfig` and `dnsPolicy` fields to `Alertmanager`, `Prometheus`, `PrometheusAgent` and `ThanosRuler` CRDs. #3889 * [FEATURE] Add `ruleQueryOffset` field to `Prometheus` CRD and `query_offset` field to `PrometheusRule` CRD. #6957 +* [FEATURE] Add support for Remote Write v2.0 to `Prometheus` and `PrometheusAgent` CRDs. #7033 * [ENHANCEMENT] Add `goGC` field to `Prometheus` and `PrometheusAgent` CRDs. #6667 * [BUGFIX] Fix label name validation in `ScrapeConfig` CRD. #6892 diff --git a/Documentation/api.md b/Documentation/api.md index 1fa80f0b8..8f0245026 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -1991,6 +1991,22 @@ For more information see +[]RemoteWriteMessageVersion + + + + +(Optional) +

List of the protobuf message versions to accept when receiving the +remote writes.

+

It requires Prometheus >= v2.54.0.

+ + + + enableFeatures
@@ -6896,6 +6912,22 @@ For more information see +[]RemoteWriteMessageVersion + + + + +(Optional) +

List of the protobuf message versions to accept when receiving the +remote writes.

+

It requires Prometheus >= v2.54.0.

+ + + + enableFeatures
@@ -11567,6 +11599,22 @@ For more information see +[]RemoteWriteMessageVersion + + + + +(Optional) +

List of the protobuf message versions to accept when receiving the +remote writes.

+

It requires Prometheus >= v2.54.0.

+ + + + enableFeatures
@@ -13901,6 +13949,28 @@ bool +

RemoteWriteMessageVersion +(string alias)

+

+(Appears on:CommonPrometheusFields, RemoteWriteSpec) +

+
+
+ + + + + + + + + + + + +
ValueDescription

"V1.0"

Remote Write message’s version 1.0.

+

"V2.0"

Remote Write message’s version 2.0.

+

RemoteWriteSpec

@@ -13937,6 +14007,7 @@ string +(Optional)

The name of the remote write queue, it must be unique if specified. The name is used in metrics and logging in order to differentiate queues.

It requires Prometheus >= v2.15.0.

@@ -13944,6 +14015,27 @@ name is used in metrics and logging in order to differentiate queues.

+messageVersion
+ + +RemoteWriteMessageVersion + + + + +(Optional) +

The Remote Write message’s version to use when writing to the endpoint.

+

Version1.0 corresponds to the prometheus.WriteRequest protobuf message introduced in Remote Write 1.0. +Version2.0 corresponds to the io.prometheus.write.v2.Request protobuf message introduced in Remote Write 2.0.

+

When Version2.0 is selected, Prometheus will automatically be +configured to append the metadata of scraped metrics to the WAL.

+

Before setting this field, consult with your remote storage provider +what message version it supports.

+

It requires Prometheus >= v2.54.0.

+ + + + sendExemplars
bool @@ -18039,6 +18131,22 @@ For more information see +[]RemoteWriteMessageVersion + + + + +(Optional) +

List of the protobuf message versions to accept when receiving the +remote writes.

+

It requires Prometheus >= v2.54.0.

+ + + + enableFeatures
@@ -25834,6 +25942,22 @@ For more information see +[]RemoteWriteMessageVersion + + + + +(Optional) +

List of the protobuf message versions to accept when receiving the +remote writes.

+

It requires Prometheus >= v2.54.0.

+ + + + enableFeatures
diff --git a/bundle.yaml b/bundle.yaml index c9f67fa02..2df5cfa5a 100644 --- a/bundle.yaml +++ b/bundle.yaml @@ -26234,6 +26234,24 @@ spec: It requires Prometheus >= v2.25.0. type: object + messageVersion: + description: |- + The Remote Write message's version to use when writing to the endpoint. + + `Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0. + `Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0. + + When `Version2.0` is selected, Prometheus will automatically be + configured to append the metadata of scraped metrics to the WAL. + + Before setting this field, consult with your remote storage provider + what message version it supports. + + It requires Prometheus >= v2.54.0. + enum: + - V1.0 + - V2.0 + type: string metadataConfig: description: MetadataConfig configures the sending of series metadata to the remote storage. @@ -26957,6 +26975,7 @@ spec: type: object url: description: The URL of the endpoint to send samples to. + minLength: 1 type: string writeRelabelConfigs: description: The list of remote write relabel configurations. @@ -27049,6 +27068,20 @@ spec: - url type: object type: array + remoteWriteReceiverMessageVersions: + description: |- + List of the protobuf message versions to accept when receiving the + remote writes. + + It requires Prometheus >= v2.54.0. + items: + enum: + - V1.0 + - V2.0 + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set replicaExternalLabelName: description: |- Name of Prometheus external label used to denote the replica name. @@ -38309,6 +38342,24 @@ spec: It requires Prometheus >= v2.25.0. type: object + messageVersion: + description: |- + The Remote Write message's version to use when writing to the endpoint. + + `Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0. + `Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0. + + When `Version2.0` is selected, Prometheus will automatically be + configured to append the metadata of scraped metrics to the WAL. + + Before setting this field, consult with your remote storage provider + what message version it supports. + + It requires Prometheus >= v2.54.0. + enum: + - V1.0 + - V2.0 + type: string metadataConfig: description: MetadataConfig configures the sending of series metadata to the remote storage. @@ -39032,6 +39083,7 @@ spec: type: object url: description: The URL of the endpoint to send samples to. + minLength: 1 type: string writeRelabelConfigs: description: The list of remote write relabel configurations. @@ -39124,6 +39176,20 @@ spec: - url type: object type: array + remoteWriteReceiverMessageVersions: + description: |- + List of the protobuf message versions to accept when receiving the + remote writes. + + It requires Prometheus >= v2.54.0. + items: + enum: + - V1.0 + - V2.0 + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set replicaExternalLabelName: description: |- Name of Prometheus external label used to denote the replica name. diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml index 0b1a29a83..dc428d8ce 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml @@ -5303,6 +5303,24 @@ spec: It requires Prometheus >= v2.25.0. type: object + messageVersion: + description: |- + The Remote Write message's version to use when writing to the endpoint. + + `Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0. + `Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0. + + When `Version2.0` is selected, Prometheus will automatically be + configured to append the metadata of scraped metrics to the WAL. + + Before setting this field, consult with your remote storage provider + what message version it supports. + + It requires Prometheus >= v2.54.0. + enum: + - V1.0 + - V2.0 + type: string metadataConfig: description: MetadataConfig configures the sending of series metadata to the remote storage. @@ -6026,6 +6044,7 @@ spec: type: object url: description: The URL of the endpoint to send samples to. + minLength: 1 type: string writeRelabelConfigs: description: The list of remote write relabel configurations. @@ -6118,6 +6137,20 @@ spec: - url type: object type: array + remoteWriteReceiverMessageVersions: + description: |- + List of the protobuf message versions to accept when receiving the + remote writes. + + It requires Prometheus >= v2.54.0. + items: + enum: + - V1.0 + - V2.0 + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set replicaExternalLabelName: description: |- Name of Prometheus external label used to denote the replica name. diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml index b4b2f2401..3418e5497 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml @@ -6806,6 +6806,24 @@ spec: It requires Prometheus >= v2.25.0. type: object + messageVersion: + description: |- + The Remote Write message's version to use when writing to the endpoint. + + `Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0. + `Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0. + + When `Version2.0` is selected, Prometheus will automatically be + configured to append the metadata of scraped metrics to the WAL. + + Before setting this field, consult with your remote storage provider + what message version it supports. + + It requires Prometheus >= v2.54.0. + enum: + - V1.0 + - V2.0 + type: string metadataConfig: description: MetadataConfig configures the sending of series metadata to the remote storage. @@ -7529,6 +7547,7 @@ spec: type: object url: description: The URL of the endpoint to send samples to. + minLength: 1 type: string writeRelabelConfigs: description: The list of remote write relabel configurations. @@ -7621,6 +7640,20 @@ spec: - url type: object type: array + remoteWriteReceiverMessageVersions: + description: |- + List of the protobuf message versions to accept when receiving the + remote writes. + + It requires Prometheus >= v2.54.0. + items: + enum: + - V1.0 + - V2.0 + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set replicaExternalLabelName: description: |- Name of Prometheus external label used to denote the replica name. diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml index 879bd25c1..73b265e9c 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml @@ -5304,6 +5304,24 @@ spec: It requires Prometheus >= v2.25.0. type: object + messageVersion: + description: |- + The Remote Write message's version to use when writing to the endpoint. + + `Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0. + `Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0. + + When `Version2.0` is selected, Prometheus will automatically be + configured to append the metadata of scraped metrics to the WAL. + + Before setting this field, consult with your remote storage provider + what message version it supports. + + It requires Prometheus >= v2.54.0. + enum: + - V1.0 + - V2.0 + type: string metadataConfig: description: MetadataConfig configures the sending of series metadata to the remote storage. @@ -6027,6 +6045,7 @@ spec: type: object url: description: The URL of the endpoint to send samples to. + minLength: 1 type: string writeRelabelConfigs: description: The list of remote write relabel configurations. @@ -6119,6 +6138,20 @@ spec: - url type: object type: array + remoteWriteReceiverMessageVersions: + description: |- + List of the protobuf message versions to accept when receiving the + remote writes. + + It requires Prometheus >= v2.54.0. + items: + enum: + - V1.0 + - V2.0 + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set replicaExternalLabelName: description: |- Name of Prometheus external label used to denote the replica name. diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml index b84804291..119fb3791 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml @@ -6807,6 +6807,24 @@ spec: It requires Prometheus >= v2.25.0. type: object + messageVersion: + description: |- + The Remote Write message's version to use when writing to the endpoint. + + `Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0. + `Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0. + + When `Version2.0` is selected, Prometheus will automatically be + configured to append the metadata of scraped metrics to the WAL. + + Before setting this field, consult with your remote storage provider + what message version it supports. + + It requires Prometheus >= v2.54.0. + enum: + - V1.0 + - V2.0 + type: string metadataConfig: description: MetadataConfig configures the sending of series metadata to the remote storage. @@ -7530,6 +7548,7 @@ spec: type: object url: description: The URL of the endpoint to send samples to. + minLength: 1 type: string writeRelabelConfigs: description: The list of remote write relabel configurations. @@ -7622,6 +7641,20 @@ spec: - url type: object type: array + remoteWriteReceiverMessageVersions: + description: |- + List of the protobuf message versions to accept when receiving the + remote writes. + + It requires Prometheus >= v2.54.0. + items: + enum: + - V1.0 + - V2.0 + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set replicaExternalLabelName: description: |- Name of Prometheus external label used to denote the replica name. diff --git a/jsonnet/prometheus-operator/prometheusagents-crd.json b/jsonnet/prometheus-operator/prometheusagents-crd.json index 52afea139..0b6247b3e 100644 --- a/jsonnet/prometheus-operator/prometheusagents-crd.json +++ b/jsonnet/prometheus-operator/prometheusagents-crd.json @@ -4501,6 +4501,14 @@ "description": "Custom HTTP headers to be sent along with each remote write request.\nBe aware that headers that are set by Prometheus itself can't be overwritten.\n\nIt requires Prometheus >= v2.25.0.", "type": "object" }, + "messageVersion": { + "description": "The Remote Write message's version to use when writing to the endpoint.\n\n`Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0.\n`Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0.\n\nWhen `Version2.0` is selected, Prometheus will automatically be\nconfigured to append the metadata of scraped metrics to the WAL.\n\nBefore setting this field, consult with your remote storage provider\nwhat message version it supports.\n\nIt requires Prometheus >= v2.54.0.", + "enum": [ + "V1.0", + "V2.0" + ], + "type": "string" + }, "metadataConfig": { "description": "MetadataConfig configures the sending of series metadata to the remote storage.", "properties": { @@ -5176,6 +5184,7 @@ }, "url": { "description": "The URL of the endpoint to send samples to.", + "minLength": 1, "type": "string" }, "writeRelabelConfigs": { @@ -5255,6 +5264,19 @@ }, "type": "array" }, + "remoteWriteReceiverMessageVersions": { + "description": "List of the protobuf message versions to accept when receiving the\nremote writes.\n\nIt requires Prometheus >= v2.54.0.", + "items": { + "enum": [ + "V1.0", + "V2.0" + ], + "type": "string" + }, + "minItems": 1, + "type": "array", + "x-kubernetes-list-type": "set" + }, "replicaExternalLabelName": { "description": "Name of Prometheus external label used to denote the replica name.\nThe external label will _not_ be added when the field is set to the\nempty string (`\"\"`).\n\nDefault: \"prometheus_replica\"", "type": "string" diff --git a/jsonnet/prometheus-operator/prometheuses-crd.json b/jsonnet/prometheus-operator/prometheuses-crd.json index fa11c5469..9d32935f2 100644 --- a/jsonnet/prometheus-operator/prometheuses-crd.json +++ b/jsonnet/prometheus-operator/prometheuses-crd.json @@ -5830,6 +5830,14 @@ "description": "Custom HTTP headers to be sent along with each remote write request.\nBe aware that headers that are set by Prometheus itself can't be overwritten.\n\nIt requires Prometheus >= v2.25.0.", "type": "object" }, + "messageVersion": { + "description": "The Remote Write message's version to use when writing to the endpoint.\n\n`Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0.\n`Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0.\n\nWhen `Version2.0` is selected, Prometheus will automatically be\nconfigured to append the metadata of scraped metrics to the WAL.\n\nBefore setting this field, consult with your remote storage provider\nwhat message version it supports.\n\nIt requires Prometheus >= v2.54.0.", + "enum": [ + "V1.0", + "V2.0" + ], + "type": "string" + }, "metadataConfig": { "description": "MetadataConfig configures the sending of series metadata to the remote storage.", "properties": { @@ -6505,6 +6513,7 @@ }, "url": { "description": "The URL of the endpoint to send samples to.", + "minLength": 1, "type": "string" }, "writeRelabelConfigs": { @@ -6584,6 +6593,19 @@ }, "type": "array" }, + "remoteWriteReceiverMessageVersions": { + "description": "List of the protobuf message versions to accept when receiving the\nremote writes.\n\nIt requires Prometheus >= v2.54.0.", + "items": { + "enum": [ + "V1.0", + "V2.0" + ], + "type": "string" + }, + "minItems": 1, + "type": "array", + "x-kubernetes-list-type": "set" + }, "replicaExternalLabelName": { "description": "Name of Prometheus external label used to denote the replica name.\nThe external label will _not_ be added when the field is set to the\nempty string (`\"\"`).\n\nDefault: \"prometheus_replica\"", "type": "string" diff --git a/pkg/apis/monitoring/v1/prometheus_types.go b/pkg/apis/monitoring/v1/prometheus_types.go index 7180f799d..6faff54ec 100644 --- a/pkg/apis/monitoring/v1/prometheus_types.go +++ b/pkg/apis/monitoring/v1/prometheus_types.go @@ -307,6 +307,16 @@ type CommonPrometheusFields struct { // It requires Prometheus >= v2.33.0. EnableRemoteWriteReceiver bool `json:"enableRemoteWriteReceiver,omitempty"` + // List of the protobuf message versions to accept when receiving the + // remote writes. + // + // It requires Prometheus >= v2.54.0. + // + // +kubebuilder:validation:MinItems=1 + // +listType:=set + // +optional + RemoteWriteReceiverMessageVersions []RemoteWriteMessageVersion `json:"remoteWriteReceiverMessageVersions,omitempty"` + // Enable access to Prometheus feature flags. By default, no features are enabled. // // Enabling features which are disabled by default is entirely outside the @@ -1338,6 +1348,8 @@ type ThanosSpec struct { // +k8s:openapi-gen=true type RemoteWriteSpec struct { // The URL of the endpoint to send samples to. + // +kubebuilder:validation:MinLength=1 + // +required URL string `json:"url"` // The name of the remote write queue, it must be unique if specified. The @@ -1345,7 +1357,24 @@ type RemoteWriteSpec struct { // // It requires Prometheus >= v2.15.0. // - Name string `json:"name,omitempty"` + //+optional + Name *string `json:"name,omitempty"` + + // The Remote Write message's version to use when writing to the endpoint. + // + // `Version1.0` corresponds to the `prometheus.WriteRequest` protobuf message introduced in Remote Write 1.0. + // `Version2.0` corresponds to the `io.prometheus.write.v2.Request` protobuf message introduced in Remote Write 2.0. + // + // When `Version2.0` is selected, Prometheus will automatically be + // configured to append the metadata of scraped metrics to the WAL. + // + // Before setting this field, consult with your remote storage provider + // what message version it supports. + // + // It requires Prometheus >= v2.54.0. + // + // +optional + MessageVersion *RemoteWriteMessageVersion `json:"messageVersion,omitempty"` // Enables sending of exemplars over remote write. Note that // exemplar-storage itself must be enabled using the `spec.enableFeature` @@ -1456,6 +1485,16 @@ type RemoteWriteSpec struct { EnableHttp2 *bool `json:"enableHTTP2,omitempty"` } +// +kubebuilder:validation:Enum=V1.0;V2.0 +type RemoteWriteMessageVersion string + +const ( + // Remote Write message's version 1.0. + RemoteWriteMessageVersion1_0 = RemoteWriteMessageVersion("V1.0") + // Remote Write message's version 2.0. + RemoteWriteMessageVersion2_0 = RemoteWriteMessageVersion("V2.0") +) + // QueueConfig allows the tuning of remote write's queue_config parameters. // This object is referenced in the RemoteWriteSpec object. // +k8s:openapi-gen=true diff --git a/pkg/apis/monitoring/v1/zz_generated.deepcopy.go b/pkg/apis/monitoring/v1/zz_generated.deepcopy.go index 9f345c69a..f7fa96831 100644 --- a/pkg/apis/monitoring/v1/zz_generated.deepcopy.go +++ b/pkg/apis/monitoring/v1/zz_generated.deepcopy.go @@ -752,6 +752,11 @@ func (in *CommonPrometheusFields) DeepCopyInto(out *CommonPrometheusFields) { (*out)[key] = val } } + if in.RemoteWriteReceiverMessageVersions != nil { + in, out := &in.RemoteWriteReceiverMessageVersions, &out.RemoteWriteReceiverMessageVersions + *out = make([]RemoteWriteMessageVersion, len(*in)) + copy(*out, *in) + } if in.EnableFeatures != nil { in, out := &in.EnableFeatures, &out.EnableFeatures *out = make([]EnableFeature, len(*in)) @@ -2600,6 +2605,16 @@ func (in *RemoteReadSpec) DeepCopy() *RemoteReadSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RemoteWriteSpec) DeepCopyInto(out *RemoteWriteSpec) { *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.MessageVersion != nil { + in, out := &in.MessageVersion, &out.MessageVersion + *out = new(RemoteWriteMessageVersion) + **out = **in + } if in.SendExemplars != nil { in, out := &in.SendExemplars, &out.SendExemplars *out = new(bool) diff --git a/pkg/client/applyconfiguration/monitoring/v1/commonprometheusfields.go b/pkg/client/applyconfiguration/monitoring/v1/commonprometheusfields.go index fbe568745..8aa3d94c4 100644 --- a/pkg/client/applyconfiguration/monitoring/v1/commonprometheusfields.go +++ b/pkg/client/applyconfiguration/monitoring/v1/commonprometheusfields.go @@ -51,6 +51,7 @@ type CommonPrometheusFieldsApplyConfiguration struct { ScrapeProtocols []monitoringv1.ScrapeProtocol `json:"scrapeProtocols,omitempty"` ExternalLabels map[string]string `json:"externalLabels,omitempty"` EnableRemoteWriteReceiver *bool `json:"enableRemoteWriteReceiver,omitempty"` + RemoteWriteReceiverMessageVersions []monitoringv1.RemoteWriteMessageVersion `json:"remoteWriteReceiverMessageVersions,omitempty"` EnableFeatures []monitoringv1.EnableFeature `json:"enableFeatures,omitempty"` ExternalURL *string `json:"externalUrl,omitempty"` RoutePrefix *string `json:"routePrefix,omitempty"` @@ -330,6 +331,16 @@ func (b *CommonPrometheusFieldsApplyConfiguration) WithEnableRemoteWriteReceiver return b } +// WithRemoteWriteReceiverMessageVersions adds the given value to the RemoteWriteReceiverMessageVersions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the RemoteWriteReceiverMessageVersions field. +func (b *CommonPrometheusFieldsApplyConfiguration) WithRemoteWriteReceiverMessageVersions(values ...monitoringv1.RemoteWriteMessageVersion) *CommonPrometheusFieldsApplyConfiguration { + for i := range values { + b.RemoteWriteReceiverMessageVersions = append(b.RemoteWriteReceiverMessageVersions, values[i]) + } + return b +} + // WithEnableFeatures adds the given value to the EnableFeatures field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the EnableFeatures field. diff --git a/pkg/client/applyconfiguration/monitoring/v1/prometheusspec.go b/pkg/client/applyconfiguration/monitoring/v1/prometheusspec.go index e5b57bb66..97ac61352 100644 --- a/pkg/client/applyconfiguration/monitoring/v1/prometheusspec.go +++ b/pkg/client/applyconfiguration/monitoring/v1/prometheusspec.go @@ -268,6 +268,16 @@ func (b *PrometheusSpecApplyConfiguration) WithEnableRemoteWriteReceiver(value b return b } +// WithRemoteWriteReceiverMessageVersions adds the given value to the RemoteWriteReceiverMessageVersions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the RemoteWriteReceiverMessageVersions field. +func (b *PrometheusSpecApplyConfiguration) WithRemoteWriteReceiverMessageVersions(values ...monitoringv1.RemoteWriteMessageVersion) *PrometheusSpecApplyConfiguration { + for i := range values { + b.RemoteWriteReceiverMessageVersions = append(b.RemoteWriteReceiverMessageVersions, values[i]) + } + return b +} + // WithEnableFeatures adds the given value to the EnableFeatures field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the EnableFeatures field. diff --git a/pkg/client/applyconfiguration/monitoring/v1/remotewritespec.go b/pkg/client/applyconfiguration/monitoring/v1/remotewritespec.go index aea08151e..0fb019eb7 100644 --- a/pkg/client/applyconfiguration/monitoring/v1/remotewritespec.go +++ b/pkg/client/applyconfiguration/monitoring/v1/remotewritespec.go @@ -26,6 +26,7 @@ import ( type RemoteWriteSpecApplyConfiguration struct { URL *string `json:"url,omitempty"` Name *string `json:"name,omitempty"` + MessageVersion *v1.RemoteWriteMessageVersion `json:"messageVersion,omitempty"` SendExemplars *bool `json:"sendExemplars,omitempty"` SendNativeHistograms *bool `json:"sendNativeHistograms,omitempty"` RemoteTimeout *v1.Duration `json:"remoteTimeout,omitempty"` @@ -68,6 +69,14 @@ func (b *RemoteWriteSpecApplyConfiguration) WithName(value string) *RemoteWriteS return b } +// WithMessageVersion sets the MessageVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MessageVersion field is set to the value of the last call. +func (b *RemoteWriteSpecApplyConfiguration) WithMessageVersion(value v1.RemoteWriteMessageVersion) *RemoteWriteSpecApplyConfiguration { + b.MessageVersion = &value + return b +} + // WithSendExemplars sets the SendExemplars field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the SendExemplars field is set to the value of the last call. diff --git a/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go b/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go index 6fca7b4d8..84b30ab36 100644 --- a/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go +++ b/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go @@ -255,6 +255,16 @@ func (b *PrometheusAgentSpecApplyConfiguration) WithEnableRemoteWriteReceiver(va return b } +// WithRemoteWriteReceiverMessageVersions adds the given value to the RemoteWriteReceiverMessageVersions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the RemoteWriteReceiverMessageVersions field. +func (b *PrometheusAgentSpecApplyConfiguration) WithRemoteWriteReceiverMessageVersions(values ...monitoringv1.RemoteWriteMessageVersion) *PrometheusAgentSpecApplyConfiguration { + for i := range values { + b.RemoteWriteReceiverMessageVersions = append(b.RemoteWriteReceiverMessageVersions, values[i]) + } + return b +} + // WithEnableFeatures adds the given value to the EnableFeatures field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the EnableFeatures field. diff --git a/pkg/prometheus/common.go b/pkg/prometheus/common.go index c32c2864d..22cfdf71f 100644 --- a/pkg/prometheus/common.go +++ b/pkg/prometheus/common.go @@ -219,6 +219,25 @@ func BuildCommonPrometheusArgs(cpf monitoringv1.CommonPrometheusFields, cg *Conf if cpf.EnableRemoteWriteReceiver { promArgs = cg.WithMinimumVersion("2.33.0").AppendCommandlineArgument(promArgs, monitoringv1.Argument{Name: "web.enable-remote-write-receiver"}) + if len(cpf.RemoteWriteReceiverMessageVersions) > 0 { + versions := make([]string, 0, len(cpf.RemoteWriteReceiverMessageVersions)) + for _, v := range cpf.RemoteWriteReceiverMessageVersions { + versions = append(versions, toProtobufMessageVersion(v)) + } + promArgs = cg.WithMinimumVersion("2.54.0").AppendCommandlineArgument( + promArgs, + monitoringv1.Argument{ + Name: "web.remote-write-receiver.accepted-protobuf-messages", + Value: strings.Join(versions, ","), + }, + ) + } + } + + for _, rw := range cpf.RemoteWrite { + if ptr.Deref(rw.MessageVersion, monitoringv1.RemoteWriteMessageVersion1_0) == monitoringv1.RemoteWriteMessageVersion2_0 { + promArgs = cg.WithMinimumVersion("2.54.0").AppendCommandlineArgument(promArgs, monitoringv1.Argument{Name: "enable-feature", Value: "metadata-wal-records"}) + } } if len(cpf.EnableFeatures) > 0 { diff --git a/pkg/prometheus/common_test.go b/pkg/prometheus/common_test.go index d7a776cbb..e219ff2c8 100644 --- a/pkg/prometheus/common_test.go +++ b/pkg/prometheus/common_test.go @@ -18,6 +18,7 @@ import ( "testing" "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" @@ -96,3 +97,67 @@ func TestStartupProbeTimeoutSeconds(t *testing.T) { require.Equal(t, test.expectedMaxStartupDuration, startupPeriodSeconds*startupFailureThreshold) } } + +func TestBuildCommonPrometheusArgsWithRemoteWriteMessageV2(t *testing.T) { + for _, tc := range []struct { + version string + messageVersion *monitoringv1.RemoteWriteMessageVersion + + expectedPresent bool + }{ + { + version: "v2.53.0", + }, + { + version: "v2.53.0", + messageVersion: ptr.To(monitoringv1.RemoteWriteMessageVersion2_0), + }, + { + version: "v2.54.0", + }, + { + version: "v2.54.0", + messageVersion: ptr.To(monitoringv1.RemoteWriteMessageVersion1_0), + }, + { + version: "v2.54.0", + messageVersion: ptr.To(monitoringv1.RemoteWriteMessageVersion2_0), + expectedPresent: true, + }, + } { + t.Run("", func(t *testing.T) { + p := &monitoringv1.Prometheus{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "test", + }, + Spec: monitoringv1.PrometheusSpec{ + CommonPrometheusFields: monitoringv1.CommonPrometheusFields{ + Version: tc.version, + RemoteWrite: []monitoringv1.RemoteWriteSpec{ + { + URL: "http://example.com", + MessageVersion: tc.messageVersion, + }, + }, + }, + }, + } + + cg, err := NewConfigGenerator(NewLogger(), p) + require.NoError(t, err) + + args := BuildCommonPrometheusArgs(p.GetCommonPrometheusFields(), cg) + + var found bool + for _, arg := range args { + if arg.Name == "enable-feature" && arg.Value == "metadata-wal-records" { + found = true + break + } + } + + require.Equal(t, tc.expectedPresent, found) + }) + } +} diff --git a/pkg/prometheus/promcfg.go b/pkg/prometheus/promcfg.go index d00cd1f9c..0268c30d8 100644 --- a/pkg/prometheus/promcfg.go +++ b/pkg/prometheus/promcfg.go @@ -261,7 +261,7 @@ func (cg *ConfigGenerator) AppendMapItem(m yaml.MapSlice, k string, v interface{ // the updated slice. func (cg *ConfigGenerator) AppendCommandlineArgument(m []monitoringv1.Argument, argument monitoringv1.Argument) []monitoringv1.Argument { if cg.notCompatible { - cg.logger.Warn(fmt.Sprintf("ignoring command line argument %q not supported by Prometheus", argument.Name)) + cg.logger.Warn(fmt.Sprintf("ignoring command line argument %q=%q not supported by Prometheus", argument.Name, argument.Value)) return m } @@ -2172,6 +2172,20 @@ func (cg *ConfigGenerator) addOAuth2ToYaml( return cg.WithMinimumVersion("2.27.0").AppendMapItem(cfg, "oauth2", oauth2Cfg) } +func toProtobufMessageVersion(mv monitoringv1.RemoteWriteMessageVersion) string { + switch mv { + case monitoringv1.RemoteWriteMessageVersion1_0: + return "prometheus.WriteRequest" + case monitoringv1.RemoteWriteMessageVersion2_0: + return "io.prometheus.write.v2.Request" + } + + // The API should allow only the values listed in the switch/case + // statement but in case something goes wrong, let's return remote + // write v1. + return "prometheus.WriteRequest" +} + func (cg *ConfigGenerator) generateRemoteWriteConfig( store *assets.StoreBuilder, ) yaml.MapItem { @@ -2193,8 +2207,12 @@ func (cg *ConfigGenerator) generateRemoteWriteConfig( cfg = cg.WithMinimumVersion("2.15.0").AppendMapItem(cfg, "headers", stringMapToMapSlice(spec.Headers)) } - if spec.Name != "" { - cfg = cg.WithMinimumVersion("2.15.0").AppendMapItem(cfg, "name", spec.Name) + if ptr.Deref(spec.Name, "") != "" { + cfg = cg.WithMinimumVersion("2.15.0").AppendMapItem(cfg, "name", *spec.Name) + } + + if spec.MessageVersion != nil { + cfg = cg.WithMinimumVersion("2.54.0").AppendMapItem(cfg, "protobuf_message", toProtobufMessageVersion(*spec.MessageVersion)) } if spec.SendExemplars != nil { diff --git a/pkg/prometheus/promcfg_test.go b/pkg/prometheus/promcfg_test.go index 49f79f5b7..d9685dcfc 100644 --- a/pkg/prometheus/promcfg_test.go +++ b/pkg/prometheus/promcfg_test.go @@ -4029,6 +4029,22 @@ func TestRemoteWriteConfig(t *testing.T) { }, golden: "RemoteWriteConfig_v2.43.0_ProxyConfigWithMutiValues.golden", }, + { + version: "v2.53.0", + remoteWrite: monitoringv1.RemoteWriteSpec{ + URL: "http://example.com", + MessageVersion: ptr.To(monitoringv1.RemoteWriteMessageVersion2_0), + }, + golden: "RemoteWriteConfig_v2.53.0_MessageVersion2.golden", + }, + { + version: "v2.54.0", + remoteWrite: monitoringv1.RemoteWriteSpec{ + URL: "http://example.com", + MessageVersion: ptr.To(monitoringv1.RemoteWriteMessageVersion2_0), + }, + golden: "RemoteWriteConfig_v2.54.0_MessageVersion2.golden", + }, } { t.Run(fmt.Sprintf("i=%d,version=%s", i, tc.version), func(t *testing.T) { p := defaultPrometheus() diff --git a/pkg/prometheus/server/statefulset_test.go b/pkg/prometheus/server/statefulset_test.go index 2beb59b3c..82a0264bb 100644 --- a/pkg/prometheus/server/statefulset_test.go +++ b/pkg/prometheus/server/statefulset_test.go @@ -2093,23 +2093,27 @@ func TestQueryLogFileVolumeMountNotPresent(t *testing.T) { require.False(t, found, "Query log file mounted, when it shouldn't be.") } -func TestEnableRemoteWriteReceiver(t *testing.T) { +func TestRemoteWriteReceiver(t *testing.T) { for _, tc := range []struct { - version string - enableRemoteWriteReceiver bool + version string + enableRemoteWriteReceiver bool + messageVersions []monitoringv1.RemoteWriteMessageVersion + expectedRemoteWriteReceiverFlag bool + expectedMessageVersions string }{ - // Test lower version where feature not available + // Remote write receiver not supported. { version: "2.32.0", enableRemoteWriteReceiver: true, }, - // Test correct version from which feature available + // Remote write receiver supported starting with v2.33.0. { version: "2.33.0", enableRemoteWriteReceiver: true, expectedRemoteWriteReceiverFlag: true, }, + // Remote write receiver supported but not enabled. { version: "2.33.0", enableRemoteWriteReceiver: false, @@ -2121,27 +2125,67 @@ func TestEnableRemoteWriteReceiver(t *testing.T) { enableRemoteWriteReceiver: true, expectedRemoteWriteReceiverFlag: true, }, + // RemoteWriteMessageVersions not supported. + { + version: "2.53.0", + enableRemoteWriteReceiver: true, + expectedRemoteWriteReceiverFlag: true, + messageVersions: []monitoringv1.RemoteWriteMessageVersion{ + monitoringv1.RemoteWriteMessageVersion2_0, + }, + }, + // RemoteWriteMessageVersions supported and set to one value. + { + version: "2.54.0", + enableRemoteWriteReceiver: true, + messageVersions: []monitoringv1.RemoteWriteMessageVersion{ + monitoringv1.RemoteWriteMessageVersion2_0, + }, + expectedRemoteWriteReceiverFlag: true, + expectedMessageVersions: "io.prometheus.write.v2.Request", + }, + // RemoteWriteMessageVersions supported and set to 2 values. + { + version: "2.54.0", + enableRemoteWriteReceiver: true, + messageVersions: []monitoringv1.RemoteWriteMessageVersion{ + monitoringv1.RemoteWriteMessageVersion1_0, + monitoringv1.RemoteWriteMessageVersion2_0, + }, + expectedRemoteWriteReceiverFlag: true, + expectedMessageVersions: "prometheus.WriteRequest,io.prometheus.write.v2.Request", + }, } { - t.Run(fmt.Sprintf("case %s", tc.version), func(t *testing.T) { - sset, err := makeStatefulSetFromPrometheus(monitoringv1.Prometheus{ + t.Run(tc.version, func(t *testing.T) { + p := monitoringv1.Prometheus{ Spec: monitoringv1.PrometheusSpec{ CommonPrometheusFields: monitoringv1.CommonPrometheusFields{ - Version: tc.version, - EnableRemoteWriteReceiver: tc.enableRemoteWriteReceiver, + Version: tc.version, + EnableRemoteWriteReceiver: tc.enableRemoteWriteReceiver, + RemoteWriteReceiverMessageVersions: tc.messageVersions, }, }, - }) + } + sset, err := makeStatefulSetFromPrometheus(p) require.NoError(t, err) - found := false + var ( + enabled bool + messageVersions string + ) for _, flag := range sset.Spec.Template.Spec.Containers[0].Args { - if flag == "--web.enable-remote-write-receiver" { - found = true - break + flag = strings.TrimPrefix(flag, "--") + values := strings.Split(flag, "=") + switch values[0] { + case "web.enable-remote-write-receiver": + enabled = true + case "web.remote-write-receiver.accepted-protobuf-messages": + messageVersions = values[1] } } - require.Equal(t, tc.expectedRemoteWriteReceiverFlag, found, "Expecting Prometheus remote write receiver to be %t, got %t", tc.expectedRemoteWriteReceiverFlag, found) + require.Equal(t, tc.expectedRemoteWriteReceiverFlag, enabled) + require.Equal(t, tc.expectedMessageVersions, messageVersions) }) } } diff --git a/pkg/prometheus/testdata/RemoteWriteConfig_v2.53.0_MessageVersion2.golden b/pkg/prometheus/testdata/RemoteWriteConfig_v2.53.0_MessageVersion2.golden new file mode 100644 index 000000000..e525aa4af --- /dev/null +++ b/pkg/prometheus/testdata/RemoteWriteConfig_v2.53.0_MessageVersion2.golden @@ -0,0 +1,10 @@ +global: + evaluation_interval: 30s + scrape_interval: 30s + external_labels: + prometheus: default/test + prometheus_replica: $(POD_NAME) +scrape_configs: [] +remote_write: +- url: http://example.com + remote_timeout: 30s diff --git a/pkg/prometheus/testdata/RemoteWriteConfig_v2.54.0_MessageVersion2.golden b/pkg/prometheus/testdata/RemoteWriteConfig_v2.54.0_MessageVersion2.golden new file mode 100644 index 000000000..37b4a0c9f --- /dev/null +++ b/pkg/prometheus/testdata/RemoteWriteConfig_v2.54.0_MessageVersion2.golden @@ -0,0 +1,11 @@ +global: + evaluation_interval: 30s + scrape_interval: 30s + external_labels: + prometheus: default/test + prometheus_replica: $(POD_NAME) +scrape_configs: [] +remote_write: +- url: http://example.com + remote_timeout: 30s + protobuf_message: io.prometheus.write.v2.Request diff --git a/test/e2e/prometheus_test.go b/test/e2e/prometheus_test.go index d77e09e07..58bae8ab5 100644 --- a/test/e2e/prometheus_test.go +++ b/test/e2e/prometheus_test.go @@ -686,6 +686,28 @@ func testPromRemoteWriteWithTLS(t *testing.T) { }, success: true, }, + { + // Prometheus Remote Write v2.0. + name: "remote-write-v2.0", + rwConfig: testFramework.PromRemoteWriteTestConfig{ + ClientKey: testFramework.Key{ + Filename: "client.key", + SecretName: "client-tls-key-cert-ca", + }, + ClientCert: testFramework.Cert{ + Filename: "client.crt", + ResourceName: "client-tls-key-cert-ca", + ResourceType: testFramework.SECRET, + }, + CA: testFramework.Cert{ + Filename: "ca.crt", + ResourceName: "client-tls-key-cert-ca", + ResourceType: testFramework.SECRET, + }, + RemoteWriteMessageVersion: ptr.To(monitoringv1.RemoteWriteMessageVersion2_0), + }, + success: true, + }, } { tc := tc @@ -4773,6 +4795,85 @@ func testPrometheusCRDValidation(t *testing.T) { }, expectedError: true, }, + { + name: "valid-remote-write-message-version", + prometheusSpec: monitoringv1.PrometheusSpec{ + CommonPrometheusFields: monitoringv1.CommonPrometheusFields{ + Replicas: &replicas, + Version: operator.DefaultPrometheusVersion, + ServiceAccountName: "prometheus", + RemoteWrite: []monitoringv1.RemoteWriteSpec{ + { + URL: "http://example.com", + MessageVersion: ptr.To(monitoringv1.RemoteWriteMessageVersion2_0), + }, + }, + }, + }, + expectedError: false, + }, + { + name: "invalid-remote-write-message-version", + prometheusSpec: monitoringv1.PrometheusSpec{ + CommonPrometheusFields: monitoringv1.CommonPrometheusFields{ + Replicas: &replicas, + Version: operator.DefaultPrometheusVersion, + ServiceAccountName: "prometheus", + RemoteWrite: []monitoringv1.RemoteWriteSpec{ + { + URL: "http://example.com", + MessageVersion: ptr.To(monitoringv1.RemoteWriteMessageVersion("xx")), + }, + }, + }, + }, + expectedError: true, + }, + { + name: "invalid-empty-remote-write-url", + prometheusSpec: monitoringv1.PrometheusSpec{ + CommonPrometheusFields: monitoringv1.CommonPrometheusFields{ + Replicas: &replicas, + Version: operator.DefaultPrometheusVersion, + ServiceAccountName: "prometheus", + RemoteWrite: []monitoringv1.RemoteWriteSpec{ + { + URL: "", + }, + }, + }, + }, + expectedError: true, + }, + { + name: "valid-remote-write-receiver-message-versions", + prometheusSpec: monitoringv1.PrometheusSpec{ + CommonPrometheusFields: monitoringv1.CommonPrometheusFields{ + Replicas: &replicas, + Version: operator.DefaultPrometheusVersion, + ServiceAccountName: "prometheus", + RemoteWriteReceiverMessageVersions: []monitoringv1.RemoteWriteMessageVersion{ + monitoringv1.RemoteWriteMessageVersion2_0, + }, + }, + }, + expectedError: false, + }, + { + name: "invalid-remote-write-receiver-message-versions", + prometheusSpec: monitoringv1.PrometheusSpec{ + CommonPrometheusFields: monitoringv1.CommonPrometheusFields{ + Replicas: &replicas, + Version: operator.DefaultPrometheusVersion, + ServiceAccountName: "prometheus", + RemoteWriteReceiverMessageVersions: []monitoringv1.RemoteWriteMessageVersion{ + monitoringv1.RemoteWriteMessageVersion2_0, + monitoringv1.RemoteWriteMessageVersion("xx"), + }, + }, + }, + expectedError: true, + }, } for _, test := range tests { diff --git a/test/framework/prometheus.go b/test/framework/prometheus.go index 6ebc237aa..c86053b5e 100644 --- a/test/framework/prometheus.go +++ b/test/framework/prometheus.go @@ -68,10 +68,11 @@ type Cert struct { } type PromRemoteWriteTestConfig struct { - ClientKey Key - ClientCert Cert - CA Cert - InsecureSkipVerify bool + ClientKey Key + ClientCert Cert + CA Cert + InsecureSkipVerify bool + RemoteWriteMessageVersion *monitoringv1.RemoteWriteMessageVersion } func (f *Framework) CreateCertificateResources(namespace, certsDir string, prwtc PromRemoteWriteTestConfig) error { @@ -222,7 +223,8 @@ func (f *Framework) MakeBasicPrometheus(ns, name, group string, replicas int32) // AddRemoteWriteWithTLSToPrometheus configures Prometheus to send samples to the remote-write endpoint. func (prwtc PromRemoteWriteTestConfig) AddRemoteWriteWithTLSToPrometheus(p *monitoringv1.Prometheus, url string) { p.Spec.RemoteWrite = []monitoringv1.RemoteWriteSpec{{ - URL: url, + URL: url, + MessageVersion: prwtc.RemoteWriteMessageVersion, QueueConfig: &monitoringv1.QueueConfig{ BatchSendDeadline: (*monitoringv1.Duration)(ptr.To("1s")), },