Skip to content

Commit

Permalink
add toggle netlink implementation of netclass collector in Node Expor…
Browse files Browse the repository at this point in the history
…ter.
  • Loading branch information
raptorsun committed Feb 15, 2023
1 parent 2f00aea commit e562835
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [#1876](https://github.com/openshift/cluster-monitoring-operator/pull/1876) Add nodeExporter.collectors.tcpstat settings.
- [#1888](https://github.com/openshift/cluster-monitoring-operator/pull/1888) Add nodeExporter.collectors.netdev settings.
- [#1893](https://github.com/openshift/cluster-monitoring-operator/pull/1893) Add nodeExporter.collectors.netclass settings.
- [#1894](https://github.com/openshift/cluster-monitoring-operator/pull/1894) Add toggle netlink implementation of netclass collector in Node Exporter.


## 4.12
Expand Down
1 change: 1 addition & 0 deletions Documentation/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ The `NodeExporterCollectorNetClassConfig` resource works as an on/off switch for
| Property | Type | Description |
| -------- | ---- | ----------- |
| enabled | bool | A Boolean flag that enables or disables the `netclass` collector. |
| netlinkImpl | bool | A Boolean flag that activate the netlink implementation of the `netclass` collector. |

[Back to TOC](#table-of-contents)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Appears in: link:nodeexportercollectorconfig.adoc[NodeExporterCollectorConfig]
| Property | Type | Description
|enabled|bool|A Boolean flag that enables or disables the `netclass` collector.

|netlinkImpl|bool|A Boolean flag that activate the netlink implementation of the `netclass` collector.

|===

link:../index.adoc[Back to TOC]
3 changes: 2 additions & 1 deletion pkg/manifests/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ func defaultClusterMonitoringConfiguration() ClusterMonitoringConfiguration {
Enabled: true,
},
NetClass: NodeExporterCollectorNetClassConfig{
Enabled: true,
Enabled: true,
NetlinkImpl: true,
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/manifests/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ func (f *Factory) updateNodeExporterArgs(args []string) []string {

if f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.NetClass.Enabled {
args = setArg(args, "--collector.netclass", "")
if f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.NetClass.NetlinkImpl {
args = setArg(args, "--collector.netclass.netlink", "")
}
} else {
args = setArg(args, "--no-collector.netclass", "")
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/manifests/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2838,6 +2838,7 @@ func TestNodeExporterCollectorSettings(t *testing.T) {
"--no-collector.tcpstat",
"--collector.netdev",
"--collector.netclass",
"--collector.netclass.netlink",
},
argsAbsent: []string{"--collector.cpufreq",
"--collector.tcpstat",
Expand Down Expand Up @@ -2889,6 +2890,19 @@ nodeExporter:
argsPresent: []string{"--no-collector.netclass"},
argsAbsent: []string{"--collector.netclass"},
},
{
name: "disable netlink mode in netclass collector",
config: `
nodeExporter:
collectors:
netclass:
enabled: true
netlinkImpl: false
`,
argsPresent: []string{"--collector.netclass"},
argsAbsent: []string{"--no-collector.netclass",
"--collector.netclass.netlink"},
},
}

for _, test := range tests {
Expand Down
2 changes: 2 additions & 0 deletions pkg/manifests/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ type NodeExporterCollectorNetDevConfig struct {
type NodeExporterCollectorNetClassConfig struct {
// A Boolean flag that enables or disables the `netclass` collector.
Enabled bool `json:"enabled,omitempty"`
// A Boolean flag that activate the netlink implementation of the `netclass` collector.
NetlinkImpl bool `json:"netlinkImpl,omitempty"`
}

// The `UserWorkloadConfiguration` resource defines the settings
Expand Down

0 comments on commit e562835

Please # to comment.