Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
16e29f7
[CONTINT-4643] Add an option to configure KSM custom resource metrics…
L3n41c May 23, 2025
368511b
[CONTINT-4643] Update `x-kubernetes-list-type` to `atomic` for `Colle…
L3n41c May 26, 2025
2f7658e
Merge branch 'main' into lenaic/CONTINT-4643
L3n41c May 28, 2025
03a75b1
Merge branch 'main' into lenaic/CONTINT-4643
L3n41c Jun 2, 2025
bca3a71
Merge branch 'main' of github.com:DataDog/datadog-operator into lenai…
L3n41c Aug 5, 2025
2da48f0
Merge branch 'main' into lenaic/CONTINT-4643
L3n41c Aug 12, 2025
581cdb7
Fix configuration typo
L3n41c Aug 13, 2025
8de389d
Mark optional fields as such
L3n41c Aug 13, 2025
3f14755
Merge branch 'main' into lenaic/CONTINT-4643
L3n41c Aug 18, 2025
79634ce
Merge branch 'main' into lenaic/CONTINT-4643
L3n41c Aug 19, 2025
84db041
Fix the indentation inside the `kubernetes_state_core.yaml.default` file
L3n41c Aug 21, 2025
0f5ceb1
Add tests for `indentWriter`
L3n41c Aug 21, 2025
76101df
Add tests
L3n41c Aug 21, 2025
654136f
Add RBAC
L3n41c Aug 21, 2025
a25f71b
Add e2e tests
L3n41c Aug 21, 2025
09901e9
Merge branch 'main' into lenaic/CONTINT-4643
L3n41c Aug 21, 2025
9ea201c
fixup! Add e2e tests
L3n41c Aug 22, 2025
104758a
Merge branch 'main' into lenaic/CONTINT-4643
tbavelier Aug 26, 2025
e26718a
Merge branch 'main' into lenaic/CONTINT-4643
levan-m Sep 16, 2025
28c60bd
[CONTINT-4643] Rename `collectCustomResources` to `collectCrMetrics`
L3n41c Oct 2, 2025
7bdd331
Merge branch 'lenaic/CONTINT-4643' of github.com:DataDog/datadog-oper…
L3n41c Oct 2, 2025
59aeb87
Merge branch 'main' into lenaic/CONTINT-4643
levan-m Oct 7, 2025
07ade52
Add omitempty (#2233)
levan-m Oct 8, 2025
1188d65
Merge branch 'main' into lenaic/CONTINT-4643
L3n41c Oct 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ core,github.com/go-logr/zapr,Apache-2.0
core,github.com/go-openapi/jsonpointer,Apache-2.0
core,github.com/go-openapi/jsonreference,Apache-2.0
core,github.com/go-openapi/swag,Apache-2.0
core,github.com/gobuffalo/flect,MIT
core,github.com/gobwas/glob,MIT
core,github.com/gogo/protobuf,BSD-3-Clause
core,github.com/golang/protobuf,BSD-3-Clause
Expand Down
150 changes: 150 additions & 0 deletions api/datadoghq/v2alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,156 @@ type KubeStateMetricsCoreFeatureConfig struct {
// This must point to a ConfigMap containing a valid cluster check configuration.
// +optional
Conf *CustomConfig `json:"conf,omitempty"`

// `CollectCrMetrics` defines custom resources for the kube-state-metrics core check to collect.
//
// The datadog agent uses the same logic as upstream `kube-state-metrics`. So is its configuration.
// The exact structure and existing fields of each item in this list can be found in:
// https://github.com/kubernetes/kube-state-metrics/blob/main/docs/metrics/extend/customresourcestate-metrics.md
//
// +optional
// +listType=atomic
CollectCrMetrics []Resource `json:"collectCrMetrics,omitempty"`
}

// Resource configures a custom resource for metric generation.
type Resource struct {
// MetricNamePrefix defines a prefix for all metrics of the resource.
// If set to "", no prefix will be added.
// Example: If set to "foo", MetricNamePrefix will be "foo_<metric>".
// +optional
MetricNamePrefix *string `json:"metricNamePrefix,omitempty" yaml:"metricNamePrefix,omitempty"`

// GroupVersionKind of the custom resource to be monitored.
GroupVersionKind GroupVersionKind `json:"groupVersionKind,omitempty" yaml:"groupVersionKind,omitempty"`

// Labels are added to all metrics. If the same key is used in a metric, the value from the metric will overwrite the value here.
Labels `json:",inline" yaml:",inline"`

// Metrics are the custom resource fields to be collected.
Metrics []Generator `json:"metrics,omitempty" yaml:"metrics,omitempty"`

// ResourcePlural sets the plural name of the resource. Defaults to the plural version of the Kind according to flect.Pluralize.
// +optional
ResourcePlural string `json:"resourcePlural,omitempty" yaml:"resourcePlural,omitempty"`
}

// GroupVersionKind is the Kubernetes group, version, and kind of a resource.
type GroupVersionKind struct {
Group string `json:"group,omitempty" yaml:"group,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
}

// Labels is common configuration of labels to add to metrics.
type Labels struct {
// CommonLabels are added to all metrics.
// +optional
CommonLabels map[string]string `json:"commonLabels,omitempty" yaml:"commonLabels,omitempty"`
// LabelsFromPath adds additional labels where the value is taken from a field in the resource.
// +optional
LabelsFromPath map[string][]string `json:"labelsFromPath,omitempty" yaml:"labelsFromPath,omitempty"`
}

// Generator describes a unique metric name.
type Generator struct {
// Name of the metric. Subject to prefixing based on the configuration of the Resource.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Help text for the metric.
// +optional
Help string `json:"help,omitempty" yaml:"help,omitempty"`
// Each targets a value or values from the resource.
Each Metric `json:"each,omitempty" yaml:"each,omitempty"`

// Labels are added to all metrics. Labels from Each will overwrite these if using the same key.
Labels `json:",inline" yaml:",inline"` // json will inline because it is already tagged
}

// Metric defines a metric to expose.
// +union
type Metric struct {
// Type defines the type of the metric.
// +unionDiscriminator
Type MetricType `json:"type,omitempty" yaml:"type,omitempty"`

// Gauge defines a gauge metric.
// +optional
Gauge *MetricGauge `json:"gauge,omitempty" yaml:"gauge,omitempty"`
// StateSet defines a state set metric.
// +optional
StateSet *MetricStateSet `json:"stateSet,omitempty" yaml:"stateSet,omitempty"`
// Info defines an info metric.
// +optional
Info *MetricInfo `json:"info,omitempty" yaml:"info,omitempty"`
}

// Type represents the type of the metric. See https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#metric-types.
type MetricType string

// Supported metric types.
var (

// Gauge defines an OpenMetrics gauge.
Gauge MetricType = "gauge"

// Info defines an OpenMetrics info.
Info MetricType = "info"

// StateSet defines an OpenMetrics stateset.
StateSet MetricType = "stateset"

// Counter defines an OpenMetrics counter.
Counter MetricType = "counter"
)

// MetricMeta are variables which may used for any metric type.
type MetricMeta struct {
// LabelsFromPath adds additional labels where the value of the label is taken from a field under Path.
// +optional
LabelsFromPath map[string][]string `json:"labelsFromPath,omitempty" yaml:"labelsFromPath,omitempty"`
// Path is the path to to generate metric(s) for.
Path []string `json:"path" yaml:"path"`
}

// MetricGauge targets a Path that may be a single value, array, or object. Arrays and objects will generate a metric per element.
// Ref: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#gauge
type MetricGauge struct {
MetricMeta `json:",inline" yaml:",inline"`

// ValueFrom is the path to a numeric field under Path that will be the metric value.
// +optional
ValueFrom []string `json:"valueFrom,omitempty" yaml:"valueFrom,omitempty"`
// LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key.
// +optional
LabelFromKey string `json:"labelFromKey,omitempty" yaml:"labelFromKey,omitempty"`
// NilIsZero indicates that if a value is nil it will be treated as zero value.
// +optional
NilIsZero bool `json:"nilIsZero,omitempty" yaml:"nilIsZero,omitempty"`
}

// MetricInfo is a metric which is used to expose textual information.
// Ref: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#info
type MetricInfo struct {
MetricMeta `json:",inline" yaml:",inline"`
// LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key.
// +optional
LabelFromKey string `json:"labelFromKey,omitempty" yaml:"labelFromKey,omitempty"`
}

// MetricStateSet is a metric which represent a series of related boolean values, also called a bitset.
// Ref: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#stateset
type MetricStateSet struct {
MetricMeta `json:",inline" yaml:",inline"`

// List is the list of values to expose a value for.
// +optional
List []string `json:"list,omitempty" yaml:"list,omitempty"`
// LabelName is the key of the label which is used for each entry in List to expose the value.
// +optional
LabelName string `json:"labelName,omitempty" yaml:"labelName,omitempty"`
// ValueFrom is the subpath to compare the list to.
// +optional
ValueFrom []string `json:"valueFrom,omitempty" yaml:"valueFrom,omitempty"`
}

// OtelCollectorFeatureConfig contains the configuration for the otel-agent.
Expand Down
Loading
Loading