diff --git a/.chloggen/feat_ta-prom-cr-fields.yaml b/.chloggen/feat_ta-prom-cr-fields.yaml new file mode 100644 index 0000000000..d41803c536 --- /dev/null +++ b/.chloggen/feat_ta-prom-cr-fields.yaml @@ -0,0 +1,20 @@ +# 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: target allocator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Expose missing Prometheus CR fields in the Operator API + +# One or more tracking issues related to the change +issues: [1934] + +# (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: | + Added `podMonitorNamespaceSelector`, `serviceMonitorNamespaceSelector`, `scrapeConfigNamespaceSelector`, + `probeNamespaceSelector`, `evaluationInterval`, and `scrapeProtocols` to the `prometheusCR` + configuration within the `TargetAllocator` and `OpenTelemetryCollector` + APIs to achieve feature parity with the underlying Target Allocator. diff --git a/apis/v1beta1/targetallocator_types.go b/apis/v1beta1/targetallocator_types.go index 5f745a8b06..2f5253e467 100644 --- a/apis/v1beta1/targetallocator_types.go +++ b/apis/v1beta1/targetallocator_types.go @@ -19,12 +19,22 @@ type TargetAllocatorPrometheusCR struct { // +optional DenyNamespaces []string `json:"denyNamespaces,omitempty"` // Default interval between consecutive scrapes. Intervals set in ServiceMonitors and PodMonitors override it. - //Equivalent to the same setting on the Prometheus CR. // // Default: "30s" // +kubebuilder:default:="30s" // +kubebuilder:validation:Format:=duration ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"` + // Default interval between rule evaluations. + // + // Default: "30s" + // +kubebuilder:default:="30s" + // +kubebuilder:validation:Format:=duration + // +optional + EvaluationInterval *metav1.Duration `json:"evaluationInterval,omitempty"` + // ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the + // protocols supported by Prometheus in order of preference (from most to least preferred). + // +optional + ScrapeProtocols []string `json:"scrapeProtocols,omitempty"` // ScrapeClasses to be referenced by PodMonitors and ServiceMonitors to include common configuration. // If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass. // +optional @@ -37,24 +47,52 @@ type TargetAllocatorPrometheusCR struct { // label selector matches no objects. // +optional PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"` + // Namespaces to be selected for PodMonitor 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 + // +kubebuilder:default:={} + PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,omitempty"` // ServiceMonitors 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 ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"` + // Namespaces to be selected for ServiceMonitor 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 + // +kubebuilder:default:={} + ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,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"` + // Namespaces to be selected for ScrapeConfig 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 + // +kubebuilder:default:={} + ScrapeConfigNamespaceSelector *metav1.LabelSelector `json:"scrapeConfigNamespaceSelector,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"` + // Namespaces to be selected for Probe 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 + // +kubebuilder:default:={} + ProbeNamespaceSelector *metav1.LabelSelector `json:"probeNamespaceSelector,omitempty"` } type ( diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go index fcbbffa62b..3f32a0c0e8 100644 --- a/apis/v1beta1/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -829,6 +829,16 @@ func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPromethe *out = new(metav1.Duration) **out = **in } + if in.EvaluationInterval != nil { + in, out := &in.EvaluationInterval, &out.EvaluationInterval + *out = new(metav1.Duration) + **out = **in + } + if in.ScrapeProtocols != nil { + in, out := &in.ScrapeProtocols, &out.ScrapeProtocols + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.ScrapeClasses != nil { in, out := &in.ScrapeClasses, &out.ScrapeClasses *out = make([]AnyConfig, len(*in)) @@ -841,21 +851,41 @@ func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPromethe *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.PodMonitorNamespaceSelector != nil { + in, out := &in.PodMonitorNamespaceSelector, &out.PodMonitorNamespaceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } if in.ServiceMonitorSelector != nil { in, out := &in.ServiceMonitorSelector, &out.ServiceMonitorSelector *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.ServiceMonitorNamespaceSelector != nil { + in, out := &in.ServiceMonitorNamespaceSelector, &out.ServiceMonitorNamespaceSelector + *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.ScrapeConfigNamespaceSelector != nil { + in, out := &in.ScrapeConfigNamespaceSelector, &out.ScrapeConfigNamespaceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } if in.ProbeSelector != nil { in, out := &in.ProbeSelector, &out.ProbeSelector *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.ProbeNamespaceSelector != nil { + in, out := &in.ProbeNamespaceSelector, &out.ProbeNamespaceSelector + *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 a2d5fbf54d..23371023f4 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,Observability certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2026-02-18T12:31:45Z" + createdAt: "2026-02-25T08:17:14Z" 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 d3de7fc169..a31223739d 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -8266,6 +8266,37 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + default: {} + 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 podMonitorSelector: properties: matchExpressions: @@ -8292,6 +8323,33 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + default: {} + 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 probeSelector: properties: matchExpressions: @@ -8324,6 +8382,33 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + default: {} + 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: @@ -8354,6 +8439,37 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + default: {} + 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 serviceMonitorSelector: properties: matchExpressions: diff --git a/bundle/community/manifests/opentelemetry.io_targetallocators.yaml b/bundle/community/manifests/opentelemetry.io_targetallocators.yaml index 8207714970..da5e64c30a 100644 --- a/bundle/community/manifests/opentelemetry.io_targetallocators.yaml +++ b/bundle/community/manifests/opentelemetry.io_targetallocators.yaml @@ -2469,6 +2469,37 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + default: {} + 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 podMonitorSelector: properties: matchExpressions: @@ -2495,6 +2526,33 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + default: {} + 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 probeSelector: properties: matchExpressions: @@ -2527,6 +2585,33 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + default: {} + 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: @@ -2557,6 +2642,37 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + default: {} + 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 serviceMonitorSelector: properties: matchExpressions: diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index a3b3dffacb..bba0cf93b7 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,Observability certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2026-02-18T12:31:45Z" + createdAt: "2026-02-25T08:17:14Z" 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 ff3e127fbc..40641058b2 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -8265,6 +8265,37 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + default: {} + 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 podMonitorSelector: properties: matchExpressions: @@ -8291,6 +8322,33 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + default: {} + 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 probeSelector: properties: matchExpressions: @@ -8323,6 +8381,33 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + default: {} + 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: @@ -8353,6 +8438,37 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + default: {} + 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 serviceMonitorSelector: properties: matchExpressions: diff --git a/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml b/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml index 8207714970..da5e64c30a 100644 --- a/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml @@ -2469,6 +2469,37 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + default: {} + 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 podMonitorSelector: properties: matchExpressions: @@ -2495,6 +2526,33 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + default: {} + 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 probeSelector: properties: matchExpressions: @@ -2527,6 +2585,33 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + default: {} + 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: @@ -2557,6 +2642,37 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + default: {} + 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 serviceMonitorSelector: properties: matchExpressions: diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 415d40bab6..4c51ba6bac 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -8252,6 +8252,37 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + default: {} + 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 podMonitorSelector: properties: matchExpressions: @@ -8278,6 +8309,33 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + default: {} + 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 probeSelector: properties: matchExpressions: @@ -8310,6 +8368,33 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + default: {} + 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: @@ -8340,6 +8425,37 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + default: {} + 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 serviceMonitorSelector: properties: matchExpressions: diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml index df0ae9cb67..46d5cb71f5 100644 --- a/config/crd/bases/opentelemetry.io_targetallocators.yaml +++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml @@ -2467,6 +2467,37 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + default: {} + 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 podMonitorSelector: properties: matchExpressions: @@ -2493,6 +2524,33 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + default: {} + 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 probeSelector: properties: matchExpressions: @@ -2525,6 +2583,33 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + default: {} + 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: @@ -2555,6 +2640,37 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + default: {} + 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 serviceMonitorSelector: properties: matchExpressions: diff --git a/docs/api/opentelemetrycollectors.md b/docs/api/opentelemetrycollectors.md index 37d0cfa8e9..ac3329da10 100644 --- a/docs/api/opentelemetrycollectors.md +++ b/docs/api/opentelemetrycollectors.md @@ -34722,6 +34722,30 @@ All CR instances which the ServiceAccount has access to will be retrieved. This Enabled indicates whether to use a PrometheusOperator custom resources as targets or not.
false + + evaluationInterval + string + + Default interval between rule evaluations. + +Default: "30s"
+
+ Format: duration
+ Default: 30s
+ + false + + podMonitorNamespaceSelector + object + + Namespaces to be selected for PodMonitor 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.
+
+ Default: map[]
+ + false podMonitorSelector object @@ -34732,6 +34756,18 @@ matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
false + + probeNamespaceSelector + object + + Namespaces to be selected for Probe 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.
+
+ Default: map[]
+ + false probeSelector object @@ -34750,6 +34786,18 @@ label selector matches no objects.
If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass.
false + + scrapeConfigNamespaceSelector + object + + Namespaces to be selected for ScrapeConfig 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.
+
+ Default: map[]
+ + false scrapeConfigSelector object @@ -34765,7 +34813,6 @@ label selector matches no objects.
string Default interval between consecutive scrapes. Intervals set in ServiceMonitors and PodMonitors override it. -Equivalent to the same setting on the Prometheus CR. Default: "30s"

@@ -34773,6 +34820,26 @@ Default: "30s"
Default: 30s
false + + scrapeProtocols + []string + + ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the +protocols supported by Prometheus in order of preference (from most to least preferred).
+ + false + + serviceMonitorNamespaceSelector + object + + Namespaces to be selected for ServiceMonitor 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.
+
+ Default: map[]
+ + false serviceMonitorSelector object @@ -34787,6 +34854,91 @@ label selector matches no objects.
+### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.podMonitorNamespaceSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Namespaces to be selected for PodMonitor 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.podMonitorNamespaceSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrpodmonitornamespaceselector) + + + +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.podMonitorSelector [↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) @@ -34831,6 +34983,91 @@ 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.probeNamespaceSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Namespaces to be selected for Probe 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.probeNamespaceSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrprobenamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. @@ -34916,6 +35153,91 @@ 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.scrapeConfigNamespaceSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Namespaces to be selected for ScrapeConfig 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.scrapeConfigNamespaceSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrscrapeconfignamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. @@ -35001,6 +35323,91 @@ 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.serviceMonitorNamespaceSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Namespaces to be selected for ServiceMonitor 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.serviceMonitorNamespaceSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrservicemonitornamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. diff --git a/docs/api/targetallocators.md b/docs/api/targetallocators.md index d9c30c1f1d..3840a454d1 100644 --- a/docs/api/targetallocators.md +++ b/docs/api/targetallocators.md @@ -10326,6 +10326,30 @@ PrometheusCR defines the configuration for the retrieval of PrometheusOperator C Enabled indicates whether to use a PrometheusOperator custom resources as targets or not.
false + + evaluationInterval + string + + Default interval between rule evaluations. + +Default: "30s"
+
+ Format: duration
+ Default: 30s
+ + false + + podMonitorNamespaceSelector + object + + Namespaces to be selected for PodMonitor 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.
+
+ Default: map[]
+ + false podMonitorSelector object @@ -10336,6 +10360,18 @@ matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
false + + probeNamespaceSelector + object + + Namespaces to be selected for Probe 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.
+
+ Default: map[]
+ + false probeSelector object @@ -10354,6 +10390,18 @@ label selector matches no objects.
If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass.
false + + scrapeConfigNamespaceSelector + object + + Namespaces to be selected for ScrapeConfig 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.
+
+ Default: map[]
+ + false scrapeConfigSelector object @@ -10369,7 +10417,6 @@ label selector matches no objects.
string Default interval between consecutive scrapes. Intervals set in ServiceMonitors and PodMonitors override it. -Equivalent to the same setting on the Prometheus CR. Default: "30s"

@@ -10377,6 +10424,26 @@ Default: "30s"
Default: 30s
false + + scrapeProtocols + []string + + ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the +protocols supported by Prometheus in order of preference (from most to least preferred).
+ + false + + serviceMonitorNamespaceSelector + object + + Namespaces to be selected for ServiceMonitor 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.
+
+ Default: map[]
+ + false serviceMonitorSelector object @@ -10391,6 +10458,91 @@ label selector matches no objects.
+### TargetAllocator.spec.prometheusCR.podMonitorNamespaceSelector +[↩ Parent](#targetallocatorspecprometheuscr) + + + +Namespaces to be selected for PodMonitor 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
+ + +### TargetAllocator.spec.prometheusCR.podMonitorNamespaceSelector.matchExpressions[index] +[↩ Parent](#targetallocatorspecprometheuscrpodmonitornamespaceselector) + + + +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
+ + ### TargetAllocator.spec.prometheusCR.podMonitorSelector [↩ Parent](#targetallocatorspecprometheuscr) @@ -10435,6 +10587,91 @@ 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
+ + +### TargetAllocator.spec.prometheusCR.probeNamespaceSelector +[↩ Parent](#targetallocatorspecprometheuscr) + + + +Namespaces to be selected for Probe 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
+ + +### TargetAllocator.spec.prometheusCR.probeNamespaceSelector.matchExpressions[index] +[↩ Parent](#targetallocatorspecprometheuscrprobenamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. @@ -10520,6 +10757,91 @@ 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
+ + +### TargetAllocator.spec.prometheusCR.scrapeConfigNamespaceSelector +[↩ Parent](#targetallocatorspecprometheuscr) + + + +Namespaces to be selected for ScrapeConfig 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
+ + +### TargetAllocator.spec.prometheusCR.scrapeConfigNamespaceSelector.matchExpressions[index] +[↩ Parent](#targetallocatorspecprometheuscrscrapeconfignamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. @@ -10605,6 +10927,91 @@ 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
+ + +### TargetAllocator.spec.prometheusCR.serviceMonitorNamespaceSelector +[↩ Parent](#targetallocatorspecprometheuscr) + + + +Namespaces to be selected for ServiceMonitor 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
+ + +### TargetAllocator.spec.prometheusCR.serviceMonitorNamespaceSelector.matchExpressions[index] +[↩ Parent](#targetallocatorspecprometheuscrservicemonitornamespaceselector) + + + 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/controllers/builder_test.go b/internal/controllers/builder_test.go index 3f60bde263..c24b80974b 100644 --- a/internal/controllers/builder_test.go +++ b/internal/controllers/builder_test.go @@ -1974,9 +1974,13 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, }, @@ -2010,7 +2014,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", + "opentelemetry-targetallocator-config/hash": "7a839fe32950e427672bf7038e88d953ceecf1531457af7c43dc78300dc85eca", }, }, Spec: corev1.PodSpec{ @@ -2160,7 +2164,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", + "opentelemetry-targetallocator-config/hash": "7a839fe32950e427672bf7038e88d953ceecf1531457af7c43dc78300dc85eca", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -2273,9 +2277,13 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, }, @@ -2309,7 +2317,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", + "opentelemetry-targetallocator-config/hash": "7a839fe32950e427672bf7038e88d953ceecf1531457af7c43dc78300dc85eca", }, }, Spec: corev1.PodSpec{ @@ -2459,7 +2467,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", + "opentelemetry-targetallocator-config/hash": "7a839fe32950e427672bf7038e88d953ceecf1531457af7c43dc78300dc85eca", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -2622,9 +2630,13 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, }, @@ -2658,7 +2670,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", + "opentelemetry-targetallocator-config/hash": "a81383bc4e7ebbf141d2fd9cde3dcd9758bc47f27af6cbaeb0f14ab6360e08c6", }, }, Spec: corev1.PodSpec{ @@ -2808,7 +2820,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", + "opentelemetry-targetallocator-config/hash": "a81383bc4e7ebbf141d2fd9cde3dcd9758bc47f27af6cbaeb0f14ab6360e08c6", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -2945,9 +2957,13 @@ https: tls_key_file_path: /tls/tls.key prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, }, @@ -2981,7 +2997,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", + "opentelemetry-targetallocator-config/hash": "02ef308f21c5312c388985bd8ca91246d1df7a3a5031135ec176f3c975e2fa37", }, }, Spec: corev1.PodSpec{ @@ -3157,7 +3173,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", + "opentelemetry-targetallocator-config/hash": "02ef308f21c5312c388985bd8ca91246d1df7a3a5031135ec176f3c975e2fa37", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ diff --git a/internal/manifests/targetallocator/configmap.go b/internal/manifests/targetallocator/configmap.go index 1162c83731..73a1f7e6d0 100644 --- a/internal/manifests/targetallocator/configmap.go +++ b/internal/manifests/targetallocator/configmap.go @@ -93,6 +93,12 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) { if taSpec.PrometheusCR.ScrapeInterval.Size() > 0 { prometheusCRConfig["scrape_interval"] = taSpec.PrometheusCR.ScrapeInterval.Duration } + if taSpec.PrometheusCR.EvaluationInterval.Size() > 0 { + prometheusCRConfig["evaluation_interval"] = taSpec.PrometheusCR.EvaluationInterval.Duration + } + if taSpec.PrometheusCR.ScrapeProtocols != nil { + prometheusCRConfig["scrape_protocols"] = taSpec.PrometheusCR.ScrapeProtocols + } if taSpec.PrometheusCR.ScrapeClasses != nil { prometheusCRConfig["scrape_classes"] = taSpec.PrometheusCR.ScrapeClasses @@ -106,12 +112,16 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) { prometheusCRConfig["deny_namespaces"] = taSpec.PrometheusCR.DenyNamespaces } + prometheusCRConfig["service_monitor_namespace_selector"] = taSpec.PrometheusCR.ServiceMonitorNamespaceSelector prometheusCRConfig["service_monitor_selector"] = taSpec.PrometheusCR.ServiceMonitorSelector + prometheusCRConfig["pod_monitor_namespace_selector"] = taSpec.PrometheusCR.PodMonitorNamespaceSelector prometheusCRConfig["pod_monitor_selector"] = taSpec.PrometheusCR.PodMonitorSelector + prometheusCRConfig["scrape_config_namespace_selector"] = taSpec.PrometheusCR.ScrapeConfigNamespaceSelector prometheusCRConfig["scrape_config_selector"] = taSpec.PrometheusCR.ScrapeConfigSelector + prometheusCRConfig["probe_namespace_selector"] = taSpec.PrometheusCR.ProbeNamespaceSelector 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 5fac38a71a..b0d7117235 100644 --- a/internal/manifests/targetallocator/configmap_test.go +++ b/internal/manifests/targetallocator/configmap_test.go @@ -146,18 +146,22 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: matchlabels: release: my-instance matchexpressions: [] + probe_namespace_selector: null probe_selector: matchlabels: release: my-instance matchexpressions: [] + scrape_config_namespace_selector: null scrape_config_selector: matchlabels: release: my-instance matchexpressions: [] + service_monitor_namespace_selector: null service_monitor_selector: matchlabels: release: my-instance @@ -198,9 +202,95 @@ prometheus_cr: assert.Equal(t, "my-instance-targetallocator", actual.Name) assert.Equal(t, expectedLabels, actual.Labels) assert.Equal(t, expectedData, actual.Data) + }) + t.Run("should return expected target allocator config map with namespace label selectors", func(t *testing.T) { + expectedData := map[string]string{ + targetAllocatorFilename: `allocation_strategy: consistent-hashing +collector_selector: + matchlabels: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/instance: default.my-instance + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/part-of: opentelemetry + matchexpressions: [] +config: + global: + scrape_interval: 30s + scrape_protocols: + - PrometheusProto + - OpenMetricsText1.0.0 + - OpenMetricsText0.0.1 + - PrometheusText0.0.4 + scrape_configs: + - job_name: otel-collector + scrape_interval: 10s + static_configs: + - targets: + - 0.0.0.0:8888 + - 0.0.0.0:9999 +filter_strategy: relabel-config +prometheus_cr: + enabled: true + pod_monitor_namespace_selector: + matchlabels: + release: my-instance + matchexpressions: [] + pod_monitor_selector: null + probe_namespace_selector: + matchlabels: + release: my-instance + matchexpressions: [] + probe_selector: null + scrape_config_namespace_selector: + matchlabels: + release: my-instance + matchexpressions: [] + scrape_config_selector: null + service_monitor_namespace_selector: + matchlabels: + release: my-instance + matchexpressions: [] + service_monitor_selector: null +`, + } + targetAllocator := targetAllocatorInstance() + targetAllocator.Spec.PrometheusCR.Enabled = true + targetAllocator.Spec.PrometheusCR.PodMonitorNamespaceSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }, + } + targetAllocator.Spec.PrometheusCR.ServiceMonitorNamespaceSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} + targetAllocator.Spec.PrometheusCR.ScrapeConfigNamespaceSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} + targetAllocator.Spec.PrometheusCR.ProbeNamespaceSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} + targetAllocator.Spec.GlobalConfig = v1beta1.AnyConfig{ + Object: map[string]any{ + "scrape_interval": "30s", + "scrape_protocols": []string{"PrometheusProto", "OpenMetricsText1.0.0", "OpenMetricsText0.0.1", "PrometheusText0.0.4"}, + }, + } + testParams := Params{ + Collector: collectorInstance(), + TargetAllocator: targetAllocator, + } + actual, err := ConfigMap(testParams) + assert.NoError(t, err) + assert.Equal(t, "my-instance-targetallocator", actual.Name) + assert.Equal(t, expectedLabels, actual.Labels) + assert.Equal(t, expectedData, actual.Data) }) - t.Run("should return expected target allocator config map with scrape interval set", func(t *testing.T) { + + t.Run("should return expected target allocator config map with scrape and evaluation intervals and protocols set", func(t *testing.T) { expectedData := map[string]string{ targetAllocatorFilename: `allocation_strategy: consistent-hashing collector_selector: @@ -221,10 +311,17 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + evaluation_interval: 30s + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null scrape_interval: 30s + scrape_protocols: + - PrometheusText1.0.0 + service_monitor_namespace_selector: null service_monitor_selector: null `, } @@ -232,6 +329,8 @@ prometheus_cr: targetAllocator := targetAllocatorInstance() targetAllocator.Spec.PrometheusCR.Enabled = true targetAllocator.Spec.PrometheusCR.ScrapeInterval = &metav1.Duration{Duration: time.Second * 30} + targetAllocator.Spec.PrometheusCR.EvaluationInterval = &metav1.Duration{Duration: time.Second * 30} + targetAllocator.Spec.PrometheusCR.ScrapeProtocols = []string{"PrometheusText1.0.0"} testParams := Params{ Collector: collectorInstance(), TargetAllocator: targetAllocator, @@ -266,7 +365,9 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null scrape_classes: - default: true @@ -274,7 +375,9 @@ prometheus_cr: relabelings: - action: labeldrop regex: pod + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, } diff --git a/tests/e2e-targetallocator-cr/01-assert.yaml b/tests/e2e-targetallocator-cr/01-assert.yaml index 441308f4ec..3c5c15aee1 100644 --- a/tests/e2e-targetallocator-cr/01-assert.yaml +++ b/tests/e2e-targetallocator-cr/01-assert.yaml @@ -95,10 +95,23 @@ data: filter_strategy: relabel-config prometheus_cr: enabled: true + evaluation_interval: 30s + pod_monitor_namespace_selector: + matchlabels: {} + matchexpressions: [] pod_monitor_selector: null + probe_namespace_selector: + matchlabels: {} + matchexpressions: [] probe_selector: null + scrape_config_namespace_selector: + matchlabels: {} + matchexpressions: [] scrape_config_selector: null scrape_interval: 30s + service_monitor_namespace_selector: + matchlabels: {} + matchexpressions: [] service_monitor_selector: null kind: ConfigMap metadata: diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml index 91f960eedb..ff63a5f5e6 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml @@ -24,6 +24,14 @@ data: ( contains(@, join(':', ['scrape_config_selector', ' null'])) ): false ( contains(@, join(':', ['matchlabels', ' {}}'])) ): false ( contains(@, join(':', ['matchexpressions', ' {}}'])) ): false + ( contains(@, join(':', ['evaluation_interval', ' 2m'])) ): true + ( contains(@, '- PrometheusText1.0.0') ): true + ( contains(@, 'pod_monitor_namespace_selector:') ): true + ( contains(@, 'service_monitor_namespace_selector:') ): true + ( contains(@, 'scrape_config_namespace_selector:') ): true + ( contains(@, 'probe_namespace_selector:') ): true + ( contains(@, join(':', ['matchlabels', ' {}'])) ): true + ( contains(@, join(':', ['matchexpressions', ' []'])) ): true kind: ConfigMap metadata: name: prometheus-cr-v1beta1-targetallocator @@ -54,4 +62,4 @@ kind: Job metadata: name: check-ta-jobs-probes-v1beta1 status: - succeeded: 1 \ No newline at end of file + succeeded: 1 diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml index 4c7751361f..bbef13af95 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml @@ -27,6 +27,9 @@ spec: prometheusCR: enabled: true scrapeInterval: 1s + evaluationInterval: 2m + scrapeProtocols: + - PrometheusText1.0.0 scrapeConfigSelector: {} probeSelector: {} scrapeClasses: @@ -154,4 +157,4 @@ spec: args: - /bin/sh - -c - - curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "blackbox-exporter" \ No newline at end of file + - curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "blackbox-exporter" diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml new file mode 100644 index 0000000000..63146d5f11 --- /dev/null +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: prometheus-cr-ns-discovery-v1beta1-targetallocator +data: + targetallocator.yaml: + ( contains(@, 'pod_monitor_namespace_selector:') ): true + ( contains(@, 'service_monitor_namespace_selector:') ): true + ( contains(@, 'scrape_config_namespace_selector:') ): true + ( contains(@, 'probe_namespace_selector:') ): true + ( contains(@, join(':', ['ns-label', ' targetallocator-e2e'])) ): true +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-ns-discovery-v1beta1 +status: + succeeded: 1 diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml new file mode 100644 index 0000000000..faffd2330e --- /dev/null +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml @@ -0,0 +1,69 @@ +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: prometheus-cr-ns-discovery-v1beta1 +spec: + config: + receivers: + prometheus: + config: + scrape_configs: [] + + processors: + + exporters: + prometheus: + endpoint: 0.0.0.0:9090 + service: + pipelines: + metrics: + receivers: [prometheus] + exporters: [prometheus] + mode: statefulset + serviceAccount: collector + targetAllocator: + enabled: true + serviceAccount: ta + prometheusCR: + enabled: true + scrapeConfigSelector: {} + podMonitorNamespaceSelector: + matchLabels: + ns-label: targetallocator-e2e + serviceMonitorNamespaceSelector: + matchLabels: + ns-label: targetallocator-e2e + scrapeConfigNamespaceSelector: + matchLabels: + ns-label: targetallocator-e2e + probeNamespaceSelector: + matchLabels: + ns-label: targetallocator-e2e +--- +apiVersion: monitoring.coreos.com/v1alpha1 +kind: ScrapeConfig +metadata: + name: ns-discovery-scrape-config-cr +spec: + kubernetesSDConfigs: + - role: Node +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-ns-discovery-v1beta1 +spec: + template: + metadata: + labels: + checker: "true" + spec: + restartPolicy: OnFailure + containers: + - name: check-metrics + image: docker.io/curlimages/curl:latest + args: + - /bin/sh + - -c + - curl -s http://prometheus-cr-ns-discovery-v1beta1-targetallocator/scrape_configs | grep "ns-discovery-scrape-config-cr" diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml index 280d656819..7190cbd874 100755 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml @@ -40,3 +40,11 @@ spec: catch: - podLogs: selector: checker=true + - name: step-03 + try: + - script: + content: kubectl label namespace $NAMESPACE ns-label=targetallocator-e2e + - apply: + file: 03-install.yaml + - assert: + file: 03-assert.yaml