Skip to content

Commit a02ec1b

Browse files
Add scrapeClasses to OpenTelemetryCollector CRD
Signed-off-by: Christian Ciach <christian.ciach@gmail.com>
1 parent def5bdb commit a02ec1b

17 files changed

+219
-42
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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. collector, target allocator, auto-instrumentation, opamp, 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: Add prometheus ScrapeClass support
9+
10+
# One or more tracking issues related to the change
11+
issues: [3600]
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:
17+
Added support for configuring `scrapeClasses` when using the PrometheusCR-feature of the target allocator.
18+
The format of the `scrapeClasses` array is exactly as same as `spec.scrapeClasses` of the `Prometheus` CRD.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ spec:
708708
enabled: true
709709
serviceMonitorSelector: {}
710710
podMonitorSelector: {}
711+
scrapeClasses: []
711712
config:
712713
receivers:
713714
prometheus:
@@ -724,6 +725,9 @@ spec:
724725
EOF
725726
```
726727

728+
The `scrapeClasses` attribute refers to the ScrapeClass feature of the Prometheus Operator.
729+
Refer to https://prometheus-operator.dev/docs/developer/scrapeclass/ to learn more about scrape classes.
730+
727731
## Configure resource attributes
728732

729733
The OpenTelemetry Operator can automatically set resource attributes as defined in the

apis/v1alpha1/convert.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde
187187
PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
188188
Enabled: in.PrometheusCR.Enabled,
189189
ScrapeInterval: in.PrometheusCR.ScrapeInterval,
190+
ScrapeClasses: in.PrometheusCR.ScrapeClasses,
190191
// prometheus_cr.pod_monitor_selector shouldn't be nil when selector is empty
191192
PodMonitorSelector: &metav1.LabelSelector{
192193
MatchLabels: in.PrometheusCR.PodMonitorSelector,
@@ -458,6 +459,7 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat
458459
PrometheusCR: OpenTelemetryTargetAllocatorPrometheusCR{
459460
Enabled: in.PrometheusCR.Enabled,
460461
ScrapeInterval: in.PrometheusCR.ScrapeInterval,
462+
ScrapeClasses: in.PrometheusCR.ScrapeClasses,
461463
PodMonitorSelector: podMonitorSelector,
462464
ServiceMonitorSelector: serviceMonitorSelector,
463465
},

apis/v1alpha1/opentelemetrycollector_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package v1alpha1
55

66
import (
7+
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
78
appsv1 "k8s.io/api/apps/v1"
89
autoscalingv2 "k8s.io/api/autoscaling/v2"
910
v1 "k8s.io/api/core/v1"
@@ -389,6 +390,12 @@ type OpenTelemetryTargetAllocatorPrometheusCR struct {
389390
// +kubebuilder:default:="30s"
390391
// +kubebuilder:validation:Format:=duration
391392
ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"`
393+
// ScrapeClasses to be referenced by PodMonitors and ServiceMonitors to include common configuration.
394+
// If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass.
395+
// +optional
396+
// +listType=atomic
397+
// +kubebuilder:pruning:PreserveUnknownFields
398+
ScrapeClasses []v1beta1.AnyConfig `json:"scrapeClasses,omitempty"`
392399
// PodMonitors to be selected for target discovery.
393400
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
394401
// PodMonitor's meta labels. The requirements are ANDed.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1beta1/targetallocator_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ type TargetAllocatorPrometheusCR struct {
2525
// +kubebuilder:default:="30s"
2626
// +kubebuilder:validation:Format:=duration
2727
ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"`
28+
// ScrapeClasses to be referenced by PodMonitors and ServiceMonitors to include common configuration.
29+
// If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass.
30+
// +optional
31+
// +listType=atomic
32+
// +kubebuilder:pruning:PreserveUnknownFields
33+
ScrapeClasses []AnyConfig `json:"scrapeClasses,omitempty"`
2834
// PodMonitors to be selected for target discovery.
2935
// A label selector is a label query over a set of resources. The result of matchLabels and
3036
// matchExpressions are ANDed. An empty label selector matches all objects. A null

apis/v1beta1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,6 +3237,12 @@ spec:
32373237
additionalProperties:
32383238
type: string
32393239
type: object
3240+
scrapeClasses:
3241+
items:
3242+
type: object
3243+
type: array
3244+
x-kubernetes-list-type: atomic
3245+
x-kubernetes-preserve-unknown-fields: true
32403246
scrapeInterval:
32413247
default: 30s
32423248
format: duration
@@ -8027,6 +8033,12 @@ spec:
80278033
type: object
80288034
type: object
80298035
x-kubernetes-map-type: atomic
8036+
scrapeClasses:
8037+
items:
8038+
type: object
8039+
type: array
8040+
x-kubernetes-list-type: atomic
8041+
x-kubernetes-preserve-unknown-fields: true
80308042
scrapeConfigSelector:
80318043
properties:
80328044
matchExpressions:

bundle/community/manifests/opentelemetry.io_targetallocators.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,12 @@ spec:
23352335
type: object
23362336
type: object
23372337
x-kubernetes-map-type: atomic
2338+
scrapeClasses:
2339+
items:
2340+
type: object
2341+
type: array
2342+
x-kubernetes-list-type: atomic
2343+
x-kubernetes-preserve-unknown-fields: true
23382344
scrapeConfigSelector:
23392345
properties:
23402346
matchExpressions:

bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,6 +3236,12 @@ spec:
32363236
additionalProperties:
32373237
type: string
32383238
type: object
3239+
scrapeClasses:
3240+
items:
3241+
type: object
3242+
type: array
3243+
x-kubernetes-list-type: atomic
3244+
x-kubernetes-preserve-unknown-fields: true
32393245
scrapeInterval:
32403246
default: 30s
32413247
format: duration
@@ -8026,6 +8032,12 @@ spec:
80268032
type: object
80278033
type: object
80288034
x-kubernetes-map-type: atomic
8035+
scrapeClasses:
8036+
items:
8037+
type: object
8038+
type: array
8039+
x-kubernetes-list-type: atomic
8040+
x-kubernetes-preserve-unknown-fields: true
80298041
scrapeConfigSelector:
80308042
properties:
80318043
matchExpressions:

0 commit comments

Comments
 (0)