From 37c777e9bca860abcee3d36f9148da3d9f4aa47a Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Fri, 15 Jul 2022 04:14:25 +0200 Subject: [PATCH] feat: add option to pass EnableRemoteWriteReceiver to Prometheus CR Fixes: https://github.com/rhobs/observability-operator/issues/160 Signed-off-by: Jan Fajerski --- deploy/crds/common/monitoring.rhobs_monitoringstacks.yaml | 4 ++++ docs/api.md | 7 +++++++ pkg/apis/monitoring/v1alpha1/types.go | 3 +++ pkg/controllers/monitoring/monitoring-stack/components.go | 5 +++-- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/deploy/crds/common/monitoring.rhobs_monitoringstacks.yaml b/deploy/crds/common/monitoring.rhobs_monitoringstacks.yaml index c1163438..76beaa8c 100644 --- a/deploy/crds/common/monitoring.rhobs_monitoringstacks.yaml +++ b/deploy/crds/common/monitoring.rhobs_monitoringstacks.yaml @@ -49,6 +49,10 @@ spec: replicas: 2 description: Define prometheus config properties: + enableRemoteWriteReceiver: + description: Enable Prometheus to be used as a receiver for the + Prometheus remote write protocol. Defaults to the value of `false`. + type: boolean externalLabels: additionalProperties: type: string diff --git a/docs/api.md b/docs/api.md index ca480078..f1e81d44 100644 --- a/docs/api.md +++ b/docs/api.md @@ -150,6 +150,13 @@ Define prometheus config + enableRemoteWriteReceiver + boolean + + Enable Prometheus to be used as a receiver for the Prometheus remote write protocol. Defaults to the value of `false`.
+ + false + externalLabels map[string]string diff --git a/pkg/apis/monitoring/v1alpha1/types.go b/pkg/apis/monitoring/v1alpha1/types.go index a48031e9..7e8a131f 100644 --- a/pkg/apis/monitoring/v1alpha1/types.go +++ b/pkg/apis/monitoring/v1alpha1/types.go @@ -96,6 +96,9 @@ type PrometheusConfig struct { // Define ExternalLabels for prometheus // +optional ExternalLabels map[string]string `json:"externalLabels,omitempty"` + // Enable Prometheus to be used as a receiver for the Prometheus remote write protocol. Defaults to the value of `false`. + // +optional + EnableRemoteWriteReceiver bool `json:"enableRemoteWriteReceiver,omitempty"` } // NamespaceSelector is a selector for selecting either all namespaces or a diff --git a/pkg/controllers/monitoring/monitoring-stack/components.go b/pkg/controllers/monitoring/monitoring-stack/components.go index 151520fe..2bf1bffe 100644 --- a/pkg/controllers/monitoring/monitoring-stack/components.go +++ b/pkg/controllers/monitoring/monitoring-stack/components.go @@ -180,8 +180,9 @@ func newPrometheus( RunAsNonRoot: pointer.Bool(true), RunAsUser: pointer.Int64(PrometheusUserFSGroupID), }, - RemoteWrite: config.RemoteWrite, - ExternalLabels: config.ExternalLabels, + RemoteWrite: config.RemoteWrite, + ExternalLabels: config.ExternalLabels, + EnableRemoteWriteReceiver: config.EnableRemoteWriteReceiver, }, Retention: ms.Spec.Retention, RuleSelector: prometheusSelector,