diff --git a/CHANGELOG.md b/CHANGELOG.md index e0738f2951..7ce82c8513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - [#2302](https://github.com/openshift/cluster-monitoring-operator/issues/2302) Enable feature `extra-scrape-metrics` in Prometheus user-workload - [#2319](https://github.com/openshift/cluster-monitoring-operator/pull/2319) Allow read-only access to the Alertmanager API (use `monitoring-alertmanager-view`). - [#2078](https://github.com/openshift/cluster-monitoring-operator/pull/2078) Support exporting VPA metrics from KSM. +- [#2339](https://github.com/openshift/cluster-monitoring-operator/pull/2339) Add support to sysctl node-exporter collector ## 4.15 diff --git a/Documentation/api.md b/Documentation/api.md index e66015ede8..645aa74848 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -34,6 +34,7 @@ Configuring Cluster Monitoring is optional. If the config does not exist or is e * [NodeExporterCollectorNetClassConfig](#nodeexportercollectornetclassconfig) * [NodeExporterCollectorNetDevConfig](#nodeexportercollectornetdevconfig) * [NodeExporterCollectorProcessesConfig](#nodeexportercollectorprocessesconfig) +* [NodeExporterCollectorSysctlConfig](#nodeexportercollectorsysctlconfig) * [NodeExporterCollectorSystemdConfig](#nodeexportercollectorsystemdconfig) * [NodeExporterCollectorTcpStatConfig](#nodeexportercollectortcpstatconfig) * [NodeExporterConfig](#nodeexporterconfig) @@ -250,6 +251,7 @@ The `NodeExporterCollectorConfig` resource defines settings for individual colle | mountstats | [NodeExporterCollectorMountStatsConfig](#nodeexportercollectormountstatsconfig) | Defines the configuration of the `mountstats` collector, which collects statistics about NFS volume I/O activities. Disabled by default. | | ksmd | [NodeExporterCollectorKSMDConfig](#nodeexportercollectorksmdconfig) | Defines the configuration of the `ksmd` collector, which collects statistics from the kernel same-page merger daemon. Disabled by default. | | processes | [NodeExporterCollectorProcessesConfig](#nodeexportercollectorprocessesconfig) | Defines the configuration of the `processes` collector, which collects statistics from processes and threads running in the system. Disabled by default. | +| sysctl | [NodeExporterCollectorSysctlConfig](#nodeexportercollectorsysctlconfig) | Defines the configuration of the `sysctl` collector, which collects sysctl metrics. Disabled by default. | | systemd | [NodeExporterCollectorSystemdConfig](#nodeexportercollectorsystemdconfig) | Defines the configuration of the `systemd` collector, which collects statistics on the systemd daemon and its managed services. Disabled by default. | [Back to TOC](#table-of-contents) @@ -345,6 +347,23 @@ The `NodeExporterCollectorProcessesConfig` resource works as an on/off switch fo [Back to TOC](#table-of-contents) +## NodeExporterCollectorSysctlConfig + +#### Description + +The `NodeExporterCollectorSysctlConfig` resource works as an on/off switch for the `sysctl` collector of the `node-exporter` agent. By default, the `sysctl` collector is disabled. + + +appears in: [NodeExporterCollectorConfig](#nodeexportercollectorconfig) + +| Property | Type | Description | +| -------- | ---- | ----------- | +| enabled | bool | A Boolean flag that enables or disables the `sysctl` collector. | +| includeSysctlMetrics | *[]string | A list of numeric sysctl values. | +| includeInfoSysctlMetrics | *[]string | A list of string sysctl values. An optional mapping can be given to expose each value as its own metric. Otherwise an index label is used to identify the different fields. | + +[Back to TOC](#table-of-contents) + ## NodeExporterCollectorSystemdConfig #### Description diff --git a/Documentation/openshiftdocs/index.adoc b/Documentation/openshiftdocs/index.adoc index 76fe12797f..c75d75c123 100644 --- a/Documentation/openshiftdocs/index.adoc +++ b/Documentation/openshiftdocs/index.adoc @@ -54,6 +54,7 @@ The configuration file itself is always defined under the `config.yaml` key in t * link:modules/nodeexportercollectornetclassconfig.adoc[NodeExporterCollectorNetClassConfig] * link:modules/nodeexportercollectornetdevconfig.adoc[NodeExporterCollectorNetDevConfig] * link:modules/nodeexportercollectorprocessesconfig.adoc[NodeExporterCollectorProcessesConfig] +* link:modules/nodeexportercollectorsysctlconfig.adoc[NodeExporterCollectorSysctlConfig] * link:modules/nodeexportercollectorsystemdconfig.adoc[NodeExporterCollectorSystemdConfig] * link:modules/nodeexportercollectortcpstatconfig.adoc[NodeExporterCollectorTcpStatConfig] * link:modules/nodeexporterconfig.adoc[NodeExporterConfig] diff --git a/Documentation/openshiftdocs/modules/nodeexportercollectorconfig.adoc b/Documentation/openshiftdocs/modules/nodeexportercollectorconfig.adoc index 7d5e2fbbe9..7470c6d522 100644 --- a/Documentation/openshiftdocs/modules/nodeexportercollectorconfig.adoc +++ b/Documentation/openshiftdocs/modules/nodeexportercollectorconfig.adoc @@ -34,6 +34,8 @@ Appears in: link:nodeexporterconfig.adoc[NodeExporterConfig] |processes|link:nodeexportercollectorprocessesconfig.adoc[NodeExporterCollectorProcessesConfig]|Defines the configuration of the `processes` collector, which collects statistics from processes and threads running in the system. Disabled by default. +|sysctl|link:nodeexportercollectorsysctlconfig.adoc[NodeExporterCollectorSysctlConfig]|Defines the configuration of the `sysctl` collector, which collects sysctl metrics. Disabled by default. + |systemd|link:nodeexportercollectorsystemdconfig.adoc[NodeExporterCollectorSystemdConfig]|Defines the configuration of the `systemd` collector, which collects statistics on the systemd daemon and its managed services. Disabled by default. |=== diff --git a/Documentation/openshiftdocs/modules/nodeexportercollectorsysctlconfig.adoc b/Documentation/openshiftdocs/modules/nodeexportercollectorsysctlconfig.adoc new file mode 100644 index 0000000000..00c83cf4a6 --- /dev/null +++ b/Documentation/openshiftdocs/modules/nodeexportercollectorsysctlconfig.adoc @@ -0,0 +1,29 @@ +// DO NOT EDIT THE CONTENT IN THIS FILE. It is automatically generated from the + // source code for the Cluster Monitoring Operator. Any changes made to this + // file will be overwritten when the content is re-generated. If you wish to + // make edits, read the docgen utility instructions in the source code for the + // CMO. + :_content-type: ASSEMBLY + +== NodeExporterCollectorSysctlConfig + +=== Description + +The `NodeExporterCollectorSysctlConfig` resource works as an on/off switch for the `sysctl` collector of the `node-exporter` agent. By default, the `sysctl` collector is disabled. + + + +Appears in: link:nodeexportercollectorconfig.adoc[NodeExporterCollectorConfig] + +[options="header"] +|=== +| Property | Type | Description +|enabled|bool|A Boolean flag that enables or disables the `sysctl` collector. + +|includeSysctlMetrics|*[]string|A list of numeric sysctl values. + +|includeInfoSysctlMetrics|*[]string|A list of string sysctl values. An optional mapping can be given to expose each value as its own metric. Otherwise an index label is used to identify the different fields. + +|=== + +link:../index.adoc[Back to TOC] diff --git a/pkg/manifests/config.go b/pkg/manifests/config.go index 084e703c4b..b7bb1a0433 100644 --- a/pkg/manifests/config.go +++ b/pkg/manifests/config.go @@ -217,6 +217,11 @@ func defaultClusterMonitoringConfiguration() ClusterMonitoringConfiguration { Systemd: NodeExporterCollectorSystemdConfig{ Enabled: false, }, + Sysctl: NodeExporterCollectorSysctlConfig{ + Enabled: false, + IncludeSysctlMetrics: &[]string{}, + IncludeInfoSysctlMetrics: &[]string{}, + }, }, }, } diff --git a/pkg/manifests/manifests.go b/pkg/manifests/manifests.go index dbad2aea58..afc1f4e5e1 100644 --- a/pkg/manifests/manifests.go +++ b/pkg/manifests/manifests.go @@ -876,6 +876,21 @@ func (f *Factory) updateNodeExporterArgs(args []string) ([]string, error) { args = setArg(args, "--no-collector.tcpstat", "") } + if f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.Sysctl.Enabled { + includeSysctlMetrics := *f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.Sysctl.IncludeSysctlMetrics + includeInfoSysctlMetrics := *f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.Sysctl.IncludeInfoSysctlMetrics + + args = setArg(args, "--collector.sysctl", "") + for _, sysctl := range includeSysctlMetrics { + args = append(args, fmt.Sprintf("--collector.sysctl.include=%s", sysctl)) + } + for _, sysctl := range includeInfoSysctlMetrics { + args = append(args, fmt.Sprintf("--collector.sysctl.include-info=%s", sysctl)) + } + } else { + args = setArg(args, "--no-collector.sysctl", "") + } + var excludedDevices string if f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.NetDev.Enabled || f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.NetClass.Enabled { diff --git a/pkg/manifests/manifests_test.go b/pkg/manifests/manifests_test.go index 6fc222162a..e324b8c5ea 100644 --- a/pkg/manifests/manifests_test.go +++ b/pkg/manifests/manifests_test.go @@ -3380,6 +3380,7 @@ func TestNodeExporterCollectorSettings(t *testing.T) { name: "default config", config: "", argsPresent: []string{"--no-collector.cpufreq", + "--no-collector.sysctl", "--no-collector.tcpstat", "--collector.netdev", "--collector.netclass", @@ -3392,6 +3393,7 @@ func TestNodeExporterCollectorSettings(t *testing.T) { "--no-collector.systemd", }, argsAbsent: []string{"--collector.cpufreq", + "--collector.sysctl", "--collector.tcpstat", "--no-collector.netdev", "--no-collector.netclass", @@ -3557,6 +3559,38 @@ nodeExporter: "--collector.systemd.unit-include=^(network.+|nss.+)$"}, argsAbsent: []string{"--no-collector.systemd"}, }, + { + name: "disable sysctl collector", + config: ` +nodeExporter: + collectors: + sysctl: + enabled: false +`, + argsPresent: []string{"--no-collector.sysctl"}, + argsAbsent: []string{"--collector.sysctl"}, + }, + { + name: "enable sysctl collector", + config: ` +nodeExporter: + collectors: + sysctl: + enabled: true + includeSysctlMetrics: + - net.ipv4.tcp_rmem:min,default,max + - net.ipv4.tcp_mem + includeInfoSysctlMetrics: + - kernel.core_pattern + - kernel.seccomp.actions_avail +`, + argsPresent: []string{"--collector.sysctl", + "--collector.sysctl.include=net.ipv4.tcp_rmem:min,default,max", + "--collector.sysctl.include=net.ipv4.tcp_mem", + "--collector.sysctl.include-info=kernel.core_pattern", + "--collector.sysctl.include-info=kernel.seccomp.actions_avail"}, + argsAbsent: []string{"--no-collector.sysctl"}, + }, } for _, test := range tests { diff --git a/pkg/manifests/types.go b/pkg/manifests/types.go index 6994fc03ca..67254af0be 100644 --- a/pkg/manifests/types.go +++ b/pkg/manifests/types.go @@ -351,6 +351,9 @@ type NodeExporterCollectorConfig struct { // Defines the configuration of the `processes` collector, which collects statistics from processes and threads running in the system. // Disabled by default. Processes NodeExporterCollectorProcessesConfig `json:"processes,omitempty"` + // Defines the configuration of the `sysctl` collector, which collects sysctl metrics. + // Disabled by default. + Sysctl NodeExporterCollectorSysctlConfig `json:"sysctl,omitempty"` // Defines the configuration of the `systemd` collector, which collects statistics on the systemd daemon and its managed services. // Disabled by default. Systemd NodeExporterCollectorSystemdConfig `json:"systemd,omitempty"` @@ -376,6 +379,18 @@ type NodeExporterCollectorTcpStatConfig struct { Enabled bool `json:"enabled,omitempty"` } +// The `NodeExporterCollectorSysctlConfig` resource works as an on/off switch for +// the `sysctl` collector of the `node-exporter` agent. +// By default, the `sysctl` collector is disabled. +type NodeExporterCollectorSysctlConfig struct { + // A Boolean flag that enables or disables the `sysctl` collector. + Enabled bool `json:"enabled,omitempty"` + // A list of numeric sysctl values. + IncludeSysctlMetrics *[]string `json:"includeSysctlMetrics,omitempty"` + // A list of string sysctl values. An optional mapping can be given to expose each value as its own metric. Otherwise an index label is used to identify the different fields. + IncludeInfoSysctlMetrics *[]string `json:"includeInfoSysctlMetrics,omitempty"` +} + // The `NodeExporterCollectorNetDevConfig` resource works as an on/off switch for // the `netdev` collector of the `node-exporter` agent. // By default, the `netdev` collector is enabled.