Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c74fc14
feat(k8sclusterreceiver): ✨ introduce ignore_deprecated_resource config
prashant-shahi Sep 6, 2023
0f7bd1f
docs(k8scluster): 📝 update README and example config
prashant-shahi Sep 7, 2023
6c2e5cb
Merge branch 'main' into chore/flag-autoscaling-v2beta2
prashant-shahi Sep 7, 2023
1389666
chore: 🚚 rename ignore_deprecated_resource to ignore_deprecated_resou…
prashant-shahi Sep 8, 2023
e1d1ae6
docs(k8scluster): 📝 update changelog
prashant-shahi Sep 8, 2023
1528480
Merge branch 'main' into chore/flag-autoscaling-v2beta2
prashant-shahi Sep 8, 2023
c1e5f70
Merge branch 'main' into chore/flag-autoscaling-v2beta2
prashant-shahi Sep 8, 2023
d421469
refactor(k8sclusterreceiver): :recycle: remove deprecated APIs and re…
prashant-shahi Sep 9, 2023
00ebf82
Merge branch 'main' into chore/flag-autoscaling-v2beta2
prashant-shahi Sep 9, 2023
97e1d40
docs(k8sclusterreceiver): 📝 update readme docs
prashant-shahi Sep 9, 2023
a6622b2
docs(k8scluster): 📝 update changelog
prashant-shahi Sep 9, 2023
3eca59a
Merge branch 'main' into chore/flag-autoscaling-v2beta2
prashant-shahi Sep 11, 2023
ee9e5d7
docs(k8scluster): 📝 update changelog generator config instead
prashant-shahi Sep 11, 2023
7a9bea3
docs(k8scluster): 📝 update changelog
prashant-shahi Sep 11, 2023
fb9a091
chore: update .chloggen/k8sclusterreceiver-remove-deprecated-resource…
prashant-shahi Sep 11, 2023
b8e0fbb
chore: update .chloggen/k8sclusterreceiver-remove-deprecated-resource…
prashant-shahi Sep 11, 2023
8ace748
Merge branch 'main' into chore/flag-autoscaling-v2beta2
prashant-shahi Sep 11, 2023
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
4 changes: 4 additions & 0 deletions receiver/k8sclusterreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ The following allocatable resource types are available.
- storage
- `metrics`: Allows to enable/disable metrics.
- `resource_attributes`: Allows to enable/disable resource attributes.
- `ignore_deprecated_resource` (default = `false`): Whether to ignore deprecated Kubernetes API resources. If set to true,
the receiver will not collect metrics for deprecated resources. This setting is useful for clusters that have deprecated
resources that are not used anymore and are causing errors or warnings in the logs.

Example:

Expand All @@ -81,6 +84,7 @@ Example:
resource_attributes:
container.id:
enabled: false
ignore_deprecated_resource: true
```

The full list of settings exposed for this receiver are documented [here](./config.go)
Expand Down
3 changes: 3 additions & 0 deletions receiver/k8sclusterreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type Config struct {

// MetricsBuilderConfig allows customizing scraped metrics/attributes representation.
metadata.MetricsBuilderConfig `mapstructure:",squash"`

// Whether to ignore deprecated resources or not.
IgnoreDeprecatedResource bool `mapstructure:"ignore_deprecated_resource"`
}

func (cfg *Config) Validate() error {
Expand Down
2 changes: 2 additions & 0 deletions receiver/k8sclusterreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
defaultCollectionInterval = 10 * time.Second
defaultDistribution = distributionKubernetes
defaultMetadataCollectionInterval = 5 * time.Minute
defaultIgnoreDeprecatedResource = false
)

var defaultNodeConditionsToReport = []string{"Ready"}
Expand All @@ -37,6 +38,7 @@ func createDefaultConfig() component.Config {
},
MetadataCollectionInterval: defaultMetadataCollectionInterval,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
IgnoreDeprecatedResource: defaultIgnoreDeprecatedResource,
}
}

Expand Down
1 change: 1 addition & 0 deletions receiver/k8sclusterreceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ k8s_cluster/all_settings:
allocatable_types_to_report: [ "cpu","memory" ]
metadata_exporters: [ nop ]
metadata_collection_interval: 30m
ignore_deprecated_resource: false
k8s_cluster/partial_settings:
collection_interval: 30s
distribution: openshift
32 changes: 19 additions & 13 deletions receiver/k8sclusterreceiver/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,25 @@ func (rw *resourceWatcher) prepareSharedInformerFactory() error {
// informer for that kind won't be set and a warning message is thrown.
// This map should be kept in sync with what can be provided by the supported k8s server versions.
supportedKinds := map[string][]schema.GroupVersionKind{
"Pod": {gvk.Pod},
"Node": {gvk.Node},
"Namespace": {gvk.Namespace},
"ReplicationController": {gvk.ReplicationController},
"ResourceQuota": {gvk.ResourceQuota},
"Service": {gvk.Service},
"DaemonSet": {gvk.DaemonSet},
"Deployment": {gvk.Deployment},
"ReplicaSet": {gvk.ReplicaSet},
"StatefulSet": {gvk.StatefulSet},
"Job": {gvk.Job},
"CronJob": {gvk.CronJob, gvk.CronJobBeta},
"HorizontalPodAutoscaler": {gvk.HorizontalPodAutoscaler, gvk.HorizontalPodAutoscalerBeta},
"Pod": {gvk.Pod},
"Node": {gvk.Node},
"Namespace": {gvk.Namespace},
"ReplicationController": {gvk.ReplicationController},
"ResourceQuota": {gvk.ResourceQuota},
"Service": {gvk.Service},
"DaemonSet": {gvk.DaemonSet},
"Deployment": {gvk.Deployment},
"ReplicaSet": {gvk.ReplicaSet},
"StatefulSet": {gvk.StatefulSet},
"Job": {gvk.Job},
}

if !rw.config.IgnoreDeprecatedResource {
supportedKinds["CronJob"] = []schema.GroupVersionKind{gvk.CronJob, gvk.CronJobBeta}
supportedKinds["HorizontalPodAutoscaler"] = []schema.GroupVersionKind{gvk.HorizontalPodAutoscaler, gvk.HorizontalPodAutoscalerBeta}
} else {
supportedKinds["CronJob"] = []schema.GroupVersionKind{gvk.CronJob}
supportedKinds["HorizontalPodAutoscaler"] = []schema.GroupVersionKind{gvk.HorizontalPodAutoscaler}
}

for kind, gvks := range supportedKinds {
Expand Down