Skip to content

Commit 661e6b3

Browse files
authored
Create ServiceMonitor to monitor target allocator (#2416)
* add create service monitor to targetallocator * add chlog * add e2e test to ta service monitor * fix linting * make bundle * fix chlog * add a condition to avoid creating sm when running in unsupported modes * update bundle * move ta sm ports into ta definition * remove changes to config/manager * assert ta service monitor creation in e2e * enable prometheus feature in e2e test * change description of observability field * move ta observability check to build * add target allocator to builder test * fix lint * fix ta sm manifest test * remove changes to manager kustomization * make ta sm return directly * move ta service monitor test to dedicated tests * remove commands in e2e * use function to generate label for sm * ta sm labels in builder test * fix api.md * fix bundling * make api-docs again * fix kustomization manager * fix ta service account in test according to fixed issues
1 parent 2910ea9 commit 661e6b3

18 files changed

+2011
-160
lines changed

.chloggen/2311-ta-servicemonitor.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
5+
component: target allocator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Create ServiceMonitor to monitor target allocator
9+
10+
# One or more tracking issues related to the change
11+
issues: [2311]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

apis/v1alpha1/opentelemetrycollector_types.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ type OpenTelemetryTargetAllocator struct {
340340
// consumed in the config file for the TargetAllocator.
341341
// +optional
342342
Env []v1.EnvVar `json:"env,omitempty"`
343+
// ObservabilitySpec defines how telemetry data gets handled.
344+
//
345+
// +optional
346+
// +kubebuilder:validation:Optional
347+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Observability"
348+
Observability ObservabilitySpec `json:"observability,omitempty"`
343349
// PodDisruptionBudget specifies the pod disruption budget configuration to use
344350
// for the target allocator workload.
345351
//
@@ -492,7 +498,7 @@ type PodDisruptionBudgetSpec struct {
492498

493499
// MetricsConfigSpec defines a metrics config.
494500
type MetricsConfigSpec struct {
495-
// EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar mode) should be created for the OpenTelemetry Collector and Prometheus Exporters.
501+
// EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar mode) should be created for the service managed by the OpenTelemetry Operator.
496502
// The operator.observability.prometheus feature gate must be enabled to use this feature.
497503
//
498504
// +optional

apis/v1alpha1/zz_generated.deepcopy.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml

+14-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ metadata:
6565
categories: Logging & Tracing,Monitoring
6666
certified: "false"
6767
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
68-
createdAt: "2023-12-06T14:31:16Z"
68+
createdAt: "2023-12-19T02:48:46Z"
6969
description: Provides the OpenTelemetry components, including the Collector
7070
operators.operatorframework.io/builder: operator-sdk-v1.29.0
7171
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
@@ -136,11 +136,23 @@ spec:
136136
displayName: Metrics Config
137137
path: observability.metrics
138138
- description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar
139-
mode) should be created for the OpenTelemetry Collector and Prometheus Exporters.
139+
mode) should be created for the service managed by the OpenTelemetry Operator.
140140
The operator.observability.prometheus feature gate must be enabled to use
141141
this feature.
142142
displayName: Create ServiceMonitors for OpenTelemetry Collector
143143
path: observability.metrics.enableMetrics
144+
- description: ObservabilitySpec defines how telemetry data gets handled.
145+
displayName: Observability
146+
path: targetAllocator.observability
147+
- description: Metrics defines the metrics configuration for operands.
148+
displayName: Metrics Config
149+
path: targetAllocator.observability.metrics
150+
- description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar
151+
mode) should be created for the service managed by the OpenTelemetry Operator.
152+
The operator.observability.prometheus feature gate must be enabled to use
153+
this feature.
154+
displayName: Create ServiceMonitors for OpenTelemetry Collector
155+
path: targetAllocator.observability.metrics.enableMetrics
144156
version: v1alpha1
145157
description: |-
146158
OpenTelemetry is a collection of tools, APIs, and SDKs. You use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior.

bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml

+18-2
Original file line numberDiff line numberDiff line change
@@ -3838,8 +3838,8 @@ spec:
38383838
properties:
38393839
enableMetrics:
38403840
description: EnableMetrics specifies if ServiceMonitor or
3841-
PodMonitor(for sidecar mode) should be created for the OpenTelemetry
3842-
Collector and Prometheus Exporters. The operator.observability.
3841+
PodMonitor(for sidecar mode) should be created for the service
3842+
managed by the OpenTelemetry Operator. The operator.observability.
38433843
type: boolean
38443844
type: object
38453845
type: object
@@ -5160,6 +5160,22 @@ spec:
51605160
description: NodeSelector to schedule OpenTelemetry TargetAllocator
51615161
pods.
51625162
type: object
5163+
observability:
5164+
description: ObservabilitySpec defines how telemetry data gets
5165+
handled.
5166+
properties:
5167+
metrics:
5168+
description: Metrics defines the metrics configuration for
5169+
operands.
5170+
properties:
5171+
enableMetrics:
5172+
description: EnableMetrics specifies if ServiceMonitor
5173+
or PodMonitor(for sidecar mode) should be created for
5174+
the service managed by the OpenTelemetry Operator. The
5175+
operator.observability.
5176+
type: boolean
5177+
type: object
5178+
type: object
51635179
podDisruptionBudget:
51645180
description: PodDisruptionBudget specifies the pod disruption
51655181
budget configuration to use for the target allocator workload.

config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml

+18-2
Original file line numberDiff line numberDiff line change
@@ -3835,8 +3835,8 @@ spec:
38353835
properties:
38363836
enableMetrics:
38373837
description: EnableMetrics specifies if ServiceMonitor or
3838-
PodMonitor(for sidecar mode) should be created for the OpenTelemetry
3839-
Collector and Prometheus Exporters. The operator.observability.
3838+
PodMonitor(for sidecar mode) should be created for the service
3839+
managed by the OpenTelemetry Operator. The operator.observability.
38403840
type: boolean
38413841
type: object
38423842
type: object
@@ -5157,6 +5157,22 @@ spec:
51575157
description: NodeSelector to schedule OpenTelemetry TargetAllocator
51585158
pods.
51595159
type: object
5160+
observability:
5161+
description: ObservabilitySpec defines how telemetry data gets
5162+
handled.
5163+
properties:
5164+
metrics:
5165+
description: Metrics defines the metrics configuration for
5166+
operands.
5167+
properties:
5168+
enableMetrics:
5169+
description: EnableMetrics specifies if ServiceMonitor
5170+
or PodMonitor(for sidecar mode) should be created for
5171+
the service managed by the OpenTelemetry Operator. The
5172+
operator.observability.
5173+
type: boolean
5174+
type: object
5175+
type: object
51605176
podDisruptionBudget:
51615177
description: PodDisruptionBudget specifies the pod disruption
51625178
budget configuration to use for the target allocator workload.

config/manifests/bases/opentelemetry-operator.clusterserviceversion.yaml

+13-1
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,23 @@ spec:
8282
displayName: Metrics Config
8383
path: observability.metrics
8484
- description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar
85-
mode) should be created for the OpenTelemetry Collector and Prometheus Exporters.
85+
mode) should be created for the service managed by the OpenTelemetry Operator.
8686
The operator.observability.prometheus feature gate must be enabled to use
8787
this feature.
8888
displayName: Create ServiceMonitors for OpenTelemetry Collector
8989
path: observability.metrics.enableMetrics
90+
- description: ObservabilitySpec defines how telemetry data gets handled.
91+
displayName: Observability
92+
path: targetAllocator.observability
93+
- description: Metrics defines the metrics configuration for operands.
94+
displayName: Metrics Config
95+
path: targetAllocator.observability.metrics
96+
- description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar
97+
mode) should be created for the service managed by the OpenTelemetry Operator.
98+
The operator.observability.prometheus feature gate must be enabled to use
99+
this feature.
100+
displayName: Create ServiceMonitors for OpenTelemetry Collector
101+
path: targetAllocator.observability.metrics.enableMetrics
90102
version: v1alpha1
91103
description: |-
92104
OpenTelemetry is a collection of tools, APIs, and SDKs. You use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior.

0 commit comments

Comments
 (0)