Skip to content

Commit

Permalink
Enable scrapeConfigSelector and probeSelector option in OpenTelemetry…
Browse files Browse the repository at this point in the history
…TargetAllocatorPrometheusCR, create right configmap for target allocator

Signed-off-by: qiyang <[email protected]>
  • Loading branch information
dominicqi committed Nov 18, 2024
1 parent 7e6b3cf commit 97b4885
Show file tree
Hide file tree
Showing 16 changed files with 505 additions and 31 deletions.
16 changes: 16 additions & 0 deletions .chloggen/scrape_config_probe.yaml
Original file line number Diff line number Diff line change
@@ -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:
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ scorecard-tests: operator-sdk
.PHONY: container
container: GOOS = linux
container: manager
docker build --load -t ${IMG} .
docker build --build-arg TARGETARCH=amd64 --load -t ${IMG} .

# Push the container image, used only for local dev purposes
.PHONY: container-push
Expand All @@ -396,7 +396,7 @@ container-operator-opamp-bridge-push:
.PHONY: container-target-allocator
container-target-allocator: GOOS = linux
container-target-allocator: targetallocator
docker build --load -t ${TARGETALLOCATOR_IMG} cmd/otel-allocator
docker build --load -t ${TARGETALLOCATOR_IMG} --build-arg TARGETARCH=amd64 cmd/otel-allocator

.PHONY: container-operator-opamp-bridge
container-operator-opamp-bridge: GOOS = linux
Expand Down
12 changes: 6 additions & 6 deletions apis/v1alpha1/opentelemetrycollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,15 @@ type OpenTelemetryTargetAllocatorPrometheusCR struct {
// +kubebuilder:validation:Format:=duration
ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"`
// PodMonitors to be selected for target discovery.
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
// PodMonitor's meta labels. The requirements are ANDed.
// Empty or nil map matches all pod monitors.
// 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
PodMonitorSelector map[string]string `json:"podMonitorSelector,omitempty"`
// ServiceMonitors to be selected for target discovery.
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
// ServiceMonitor's meta labels. The requirements are ANDed.
// Empty or nil map matches all service monitors.
// 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 map[string]string `json:"serviceMonitorSelector,omitempty"`
}
Expand Down
12 changes: 12 additions & 0 deletions apis/v1beta1/targetallocator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ type TargetAllocatorPrometheusCR struct {
// label selector matches no objects.
// +optional
ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"`
// ScrapeConfig 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"`
// ProbeSelector 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 (
Expand Down
10 changes: 10 additions & 0 deletions apis/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/otel-allocator/allocation/per_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *perNodeStrategy) GetCollectorForTarget(collectors map[string]*Collector
targetNodeName := item.GetNodeName()
collector, ok := s.collectorByNode[targetNodeName]
if !ok {
return nil, fmt.Errorf("could not find collector for node %s", targetNodeName)
return nil, fmt.Errorf("could not find collector for node %s target is %s", targetNodeName, item.GetNodeName())
}
return collectors[collector.Name], nil
}
Expand Down
52 changes: 52 additions & 0 deletions config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions config/crd/bases/opentelemetry.io_targetallocators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 97b4885

Please sign in to comment.