From d87da69d6076b7b2d490f3a37ef385a3cb2a0417 Mon Sep 17 00:00:00 2001 From: qiyang Date: Mon, 18 Nov 2024 14:36:45 +0800 Subject: [PATCH] Enable scrapeConfigSelector and probeSelector option in OpenTelemetryTargetAllocatorPrometheusCR, create right configmap for target allocator Signed-off-by: qiyang --- .chloggen/scrape_config_probe.yaml | 16 ++ apis/v1beta1/targetallocator_types.go | 12 ++ apis/v1beta1/zz_generated.deepcopy.go | 10 + ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 52 +++++ ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 52 +++++ ...ntelemetry.io_opentelemetrycollectors.yaml | 52 +++++ .../opentelemetry.io_targetallocators.yaml | 52 +++++ controllers/builder_test.go | 42 ++-- docs/api.md | 190 ++++++++++++++++++ .../manifests/targetallocator/configmap.go | 4 + .../targetallocator/configmap_test.go | 20 ++ 13 files changed, 490 insertions(+), 16 deletions(-) create mode 100755 .chloggen/scrape_config_probe.yaml diff --git a/.chloggen/scrape_config_probe.yaml b/.chloggen/scrape_config_probe.yaml new file mode 100755 index 0000000000..524fa01fb0 --- /dev/null +++ b/.chloggen/scrape_config_probe.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: collector + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: enables support for pulling scrape config and probe CRDs in the target allocator + +# One or more tracking issues related to the change +issues: [1842] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/apis/v1beta1/targetallocator_types.go b/apis/v1beta1/targetallocator_types.go index 5eceb5664e..ca9bc9aa0c 100644 --- a/apis/v1beta1/targetallocator_types.go +++ b/apis/v1beta1/targetallocator_types.go @@ -42,6 +42,18 @@ type TargetAllocatorPrometheusCR struct { // label selector matches no objects. // +optional ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"` + // ScrapeConfigs to be selected for target discovery. + // A label selector is a label query over a set of resources. The result of matchLabels and + // matchExpressions are ANDed. An empty label selector matches all objects. A null + // label selector matches no objects. + // +optional + ScrapeConfigSelector *metav1.LabelSelector `json:"scrapeConfigSelector,omitempty"` + // Probes to be selected for target discovery. + // A label selector is a label query over a set of resources. The result of matchLabels and + // matchExpressions are ANDed. An empty label selector matches all objects. A null + // label selector matches no objects. + // +optional + ProbeSelector *metav1.LabelSelector `json:"probeSelector,omitempty"` } type ( diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go index b508f0be76..8d2402a809 100644 --- a/apis/v1beta1/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -787,6 +787,16 @@ func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPromethe *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.ScrapeConfigSelector != nil { + in, out := &in.ScrapeConfigSelector, &out.ScrapeConfigSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.ProbeSelector != nil { + in, out := &in.ProbeSelector, &out.ProbeSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorPrometheusCR. diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index e7b58fec20..741ab10e7e 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-11-08T09:36:39Z" + createdAt: "2024-11-18T05:42:43Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 6ccb1c9e5f..8279c4550b 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -7909,6 +7909,58 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + scrapeConfigSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeInterval: default: 30s format: duration diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index cae664cb52..138147094e 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2024-11-08T09:36:43Z" + createdAt: "2024-11-18T05:42:44Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 6ccb1c9e5f..8279c4550b 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -7909,6 +7909,58 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + scrapeConfigSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeInterval: default: 30s format: duration diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index fc36f4deb5..6a32030d4f 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -7895,6 +7895,58 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + scrapeConfigSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeInterval: default: 30s format: duration diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml index 5ce85e459c..89c0c32134 100644 --- a/config/crd/bases/opentelemetry.io_targetallocators.yaml +++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml @@ -2269,6 +2269,58 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + scrapeConfigSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeInterval: default: 30s format: duration diff --git a/controllers/builder_test.go b/controllers/builder_test.go index 6a5f4803c1..b407d932c6 100644 --- a/controllers/builder_test.go +++ b/controllers/builder_test.go @@ -1514,6 +1514,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -1547,7 +1549,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: corev1.PodSpec{ @@ -1679,7 +1681,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -1971,6 +1973,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -2004,7 +2008,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: corev1.PodSpec{ @@ -2136,7 +2140,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -2474,6 +2478,8 @@ https: prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -2507,7 +2513,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f1ce0fdbf69924576576d1d6eb2a3cc91a3f72675b3facbb36702d57027bc6ae", + "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", }, }, Spec: corev1.PodSpec{ @@ -2665,7 +2671,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f1ce0fdbf69924576576d1d6eb2a3cc91a3f72675b3facbb36702d57027bc6ae", + "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -3529,6 +3535,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -3562,7 +3570,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "88ab06aab167d58ae2316ddecc9cf0600b9094d27054781dd6aa6e44dcf902fc", + "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", }, }, Spec: corev1.PodSpec{ @@ -3694,7 +3702,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "88ab06aab167d58ae2316ddecc9cf0600b9094d27054781dd6aa6e44dcf902fc", + "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -3802,6 +3810,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -3835,7 +3845,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "88ab06aab167d58ae2316ddecc9cf0600b9094d27054781dd6aa6e44dcf902fc", + "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", }, }, Spec: corev1.PodSpec{ @@ -3967,7 +3977,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "88ab06aab167d58ae2316ddecc9cf0600b9094d27054781dd6aa6e44dcf902fc", + "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -4126,6 +4136,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -4159,7 +4171,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: corev1.PodSpec{ @@ -4291,7 +4303,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "9d78d2ecfad18bad24dec7e9a825b4ce45657ecbb2e6b32845b585b7c15ea407", + "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -4423,6 +4435,8 @@ https: prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null service_monitor_selector: null `, }, @@ -4456,7 +4470,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f1ce0fdbf69924576576d1d6eb2a3cc91a3f72675b3facbb36702d57027bc6ae", + "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", }, }, Spec: corev1.PodSpec{ @@ -4614,7 +4628,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f1ce0fdbf69924576576d1d6eb2a3cc91a3f72675b3facbb36702d57027bc6ae", + "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ diff --git a/docs/api.md b/docs/api.md index 9601cca2fd..5a15a4c945 100644 --- a/docs/api.md +++ b/docs/api.md @@ -48094,6 +48094,26 @@ All CR instances which the ServiceAccount has access to will be retrieved. This PodMonitors to be selected for target discovery. A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false + + probeSelector + object + + Probes to be selected for target discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false + + scrapeConfigSelector + object + + ScrapeConfigs to be selected for target discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
false @@ -48168,6 +48188,176 @@ operator is "In", and the values array contains only "value". The requirements a +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.probeSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Probes to be selected for target discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.probeSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrprobeselector) + + + +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.scrapeConfigSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +ScrapeConfigs to be selected for target discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.scrapeConfigSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrscrapeconfigselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. diff --git a/internal/manifests/targetallocator/configmap.go b/internal/manifests/targetallocator/configmap.go index b17df29151..99ffb337f0 100644 --- a/internal/manifests/targetallocator/configmap.go +++ b/internal/manifests/targetallocator/configmap.go @@ -104,6 +104,10 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) { prometheusCRConfig["pod_monitor_selector"] = taSpec.PrometheusCR.PodMonitorSelector + prometheusCRConfig["scrape_config_selector"] = taSpec.PrometheusCR.ScrapeConfigSelector + + prometheusCRConfig["probe_selector"] = taSpec.PrometheusCR.ProbeSelector + taConfig["prometheus_cr"] = prometheusCRConfig } diff --git a/internal/manifests/targetallocator/configmap_test.go b/internal/manifests/targetallocator/configmap_test.go index de863874db..7bae7c0ce6 100644 --- a/internal/manifests/targetallocator/configmap_test.go +++ b/internal/manifests/targetallocator/configmap_test.go @@ -171,6 +171,14 @@ prometheus_cr: matchlabels: release: my-instance matchexpressions: [] + probe_selector: + matchlabels: + release: my-instance + matchexpressions: [] + scrape_config_selector: + matchlabels: + release: my-instance + matchexpressions: [] service_monitor_selector: matchlabels: release: my-instance @@ -188,6 +196,14 @@ prometheus_cr: MatchLabels: map[string]string{ "release": "my-instance", }} + targetAllocator.Spec.PrometheusCR.ScrapeConfigSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} + targetAllocator.Spec.PrometheusCR.ProbeSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} targetAllocator.Spec.GlobalConfig = v1beta1.AnyConfig{ Object: map[string]interface{}{ "scrape_interval": "30s", @@ -224,6 +240,8 @@ filter_strategy: relabel-config prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null scrape_interval: 30s service_monitor_selector: null `, @@ -285,6 +303,8 @@ https: prometheus_cr: enabled: true pod_monitor_selector: null + probe_selector: null + scrape_config_selector: null scrape_interval: 30s service_monitor_selector: null `,