Skip to content

Commit

Permalink
add nodeExporter.collectors.systemd settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
raptorsun committed Apr 8, 2023
1 parent e154bc6 commit a161f24
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Documentation/api.md
Expand Up @@ -30,6 +30,7 @@ Configuring Cluster Monitoring is optional. If the config does not exist or is e
* [NodeExporterCollectorCpufreqConfig](#nodeexportercollectorcpufreqconfig)
* [NodeExporterCollectorNetClassConfig](#nodeexportercollectornetclassconfig)
* [NodeExporterCollectorNetDevConfig](#nodeexportercollectornetdevconfig)
* [NodeExporterCollectorSystemdConfig](#nodeexportercollectorsystemdconfig)
* [NodeExporterCollectorTcpStatConfig](#nodeexportercollectortcpstatconfig)
* [NodeExporterConfig](#nodeexporterconfig)
* [OpenShiftStateMetricsConfig](#openshiftstatemetricsconfig)
Expand Down Expand Up @@ -212,6 +213,7 @@ The `NodeExporterCollectorConfig` resource defines settings for individual colle
| netdev | [NodeExporterCollectorNetDevConfig](#nodeexportercollectornetdevconfig) | Defines the configuration of the `netdev` collector, which collects network devices statistics. Enabled by default. |
| netclass | [NodeExporterCollectorNetClassConfig](#nodeexportercollectornetclassconfig) | Defines the configuration of the `netclass` collector, which collects information about network devices. Enabled by default. |
| buddyinfo | [NodeExporterCollectorBuddyInfoConfig](#nodeexportercollectorbuddyinfoconfig) | Defines the configuration of the `buddyinfo` collector, which collects statistics about memory fragmentation from the `node_buddyinfo_blocks` metric. This metric collects data from `/proc/buddyinfo`. Disabled by default. |
| systemd | [NodeExporterCollectorSystemdConfig](#nodeexportercollectorsystemdconfig) | Defines the configuration of the `systemd` collector, which collects statistics on systemd daemon and its managed services. Disabled by default. |

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

Expand Down Expand Up @@ -261,6 +263,21 @@ The `NodeExporterCollectorNetDevConfig` resource works as an on/off switch for t

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

## NodeExporterCollectorSystemdConfig

#### Description

The `NodeExporterCollectorSystemdConfig` resource works as an on/off switch for the `systemd` collector of the `node-exporter` agent. By default, the `systemd` collector is disabled.


<em>appears in: [NodeExporterCollectorConfig](#nodeexportercollectorconfig)</em>

| Property | Type | Description |
| -------- | ---- | ----------- |
| enabled | bool | A Boolean flag that enables or disables the `systemd` colletor. |

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

## NodeExporterCollectorTcpStatConfig

#### Description
Expand Down
1 change: 1 addition & 0 deletions Documentation/openshiftdocs/index.adoc
Expand Up @@ -50,6 +50,7 @@ The configuration file itself is always defined under the `config.yaml` key in t
* link:modules/nodeexportercollectorcpufreqconfig.adoc[NodeExporterCollectorCpufreqConfig]
* link:modules/nodeexportercollectornetclassconfig.adoc[NodeExporterCollectorNetClassConfig]
* link:modules/nodeexportercollectornetdevconfig.adoc[NodeExporterCollectorNetDevConfig]
* link:modules/nodeexportercollectorsystemdconfig.adoc[NodeExporterCollectorSystemdConfig]
* link:modules/nodeexportercollectortcpstatconfig.adoc[NodeExporterCollectorTcpStatConfig]
* link:modules/nodeexporterconfig.adoc[NodeExporterConfig]
* link:modules/openshiftstatemetricsconfig.adoc[OpenShiftStateMetricsConfig]
Expand Down
Expand Up @@ -28,6 +28,8 @@ Appears in: link:nodeexporterconfig.adoc[NodeExporterConfig]

|buddyinfo|link:nodeexportercollectorbuddyinfoconfig.adoc[NodeExporterCollectorBuddyInfoConfig]|Defines the configuration of the `buddyinfo` collector, which collects statistics about memory fragmentation from the `node_buddyinfo_blocks` metric. This metric collects data from `/proc/buddyinfo`. Disabled by default.

|systemd|link:nodeexportercollectorsystemdconfig.adoc[NodeExporterCollectorSystemdConfig]|Defines the configuration of the `systemd` collector, which collects statistics on systemd daemon and its managed services. Disabled by default.

|===

link:../index.adoc[Back to TOC]
@@ -0,0 +1,25 @@
// 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

== NodeExporterCollectorSystemdConfig

=== Description

The `NodeExporterCollectorSystemdConfig` resource works as an on/off switch for the `systemd` collector of the `node-exporter` agent. By default, the `systemd` collector is disabled.



Appears in: link:nodeexportercollectorconfig.adoc[NodeExporterCollectorConfig]

[options="header"]
|===
| Property | Type | Description
|enabled|bool|A Boolean flag that enables or disables the `systemd` colletor.

|===

link:../index.adoc[Back to TOC]
3 changes: 3 additions & 0 deletions assets/node-exporter/daemonset.yaml
Expand Up @@ -41,6 +41,9 @@ spec:
- --collector.cpu.info
- --collector.textfile.directory=/var/node_exporter/textfile
- --no-collector.btrfs
env:
- name: DBUS_SYSTEM_BUS_ADDRESS
value: unix:path=/host/root/var/run/dbus/system_bus_socket
image: quay.io/prometheus/node-exporter:v1.5.0
name: node-exporter
resources:
Expand Down
7 changes: 7 additions & 0 deletions jsonnet/components/node-exporter.libsonnet
Expand Up @@ -230,6 +230,13 @@ function(params)
// node-exporter has issue in rolling out with security context
// changes in kube-prometheus hence overidding the changes
securityContext: {},
env: [
{
// This is required for the systemd collector to connect to the host's dbus socket.
name: 'DBUS_SYSTEM_BUS_ADDRESS',
value: 'unix:path=/host/root/var/run/dbus/system_bus_socket',
},
],
},
super.containers,
),
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/manifests.go
Expand Up @@ -857,6 +857,12 @@ func (f *Factory) updateNodeExporterArgs(args []string) []string {
args = setArg(args, "--no-collector.buddyinfo", "")
}

if f.config.ClusterMonitoringConfiguration.NodeExporterConfig.Collectors.Systemd.Enabled {
args = setArg(args, "--collector.systemd", "")
} else {
args = setArg(args, "--no-collector.systemd", "")
}

return args
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/manifests/manifests_test.go
Expand Up @@ -2916,13 +2916,15 @@ func TestNodeExporterCollectorSettings(t *testing.T) {
"--collector.netdev",
"--collector.netclass",
"--no-collector.buddyinfo",
"--no-collector.systemd",
},
argsAbsent: []string{"--collector.cpufreq",
"--collector.tcpstat",
"--no-collector.netdev",
"--no-collector.netclass",
"--collector.netclass.netlink",
"--collector.buddyinfo",
"--collector.systemd",
},
},
{
Expand Down Expand Up @@ -2993,6 +2995,17 @@ nodeExporter:
argsPresent: []string{"--collector.buddyinfo"},
argsAbsent: []string{"--no-collector.buddyinfo"},
},
{
name: "enable systemd collector",
config: `
nodeExporter:
collectors:
systemd:
enabled: true
`,
argsPresent: []string{"--collector.systemd"},
argsAbsent: []string{"--no-collector.systemd"},
},
}

for _, test := range tests {
Expand Down
11 changes: 11 additions & 0 deletions pkg/manifests/types.go
Expand Up @@ -297,6 +297,9 @@ type NodeExporterCollectorConfig struct {
// Defines the configuration of the `buddyinfo` collector, which collects statistics about memory fragmentation from the `node_buddyinfo_blocks` metric. This metric collects data from `/proc/buddyinfo`.
// Disabled by default.
BuddyInfo NodeExporterCollectorBuddyInfoConfig `json:"buddyinfo,omitempty"`
// Defines the configuration of the `systemd` collector, which collects statistics on systemd daemon and its managed services.
// Disabled by default.
Systemd NodeExporterCollectorSystemdConfig `json:"systemd,omitempty"`
}

// The `NodeExporterCollectorCpufreqConfig` resource works as an on/off switch for
Expand Down Expand Up @@ -388,6 +391,14 @@ type NodeExporterCollectorBuddyInfoConfig struct {
Enabled bool `json:"enabled,omitempty"`
}

// The `NodeExporterCollectorSystemdConfig` resource works as an on/off switch for
// the `systemd` collector of the `node-exporter` agent.
// By default, the `systemd` collector is disabled.
type NodeExporterCollectorSystemdConfig struct {
// A Boolean flag that enables or disables the `systemd` colletor.
Enabled bool `json:"enabled,omitempty"`
}

// The `UserWorkloadConfiguration` resource defines the settings
// responsible for user-defined projects in the
// `user-workload-monitoring-config` config map in the
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/node_exporter_test.go
Expand Up @@ -60,6 +60,14 @@ nodeExporter:
nodeExporter:
collectors:
buddyinfo:
enabled: true`,
},
{
nameCollector: "systemd",
config: `
nodeExporter:
collectors:
systemd:
enabled: true`,
},
}
Expand Down

0 comments on commit a161f24

Please sign in to comment.