From 69d76e8051b92ef38ea2293887561b513651a5fd Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Tue, 2 Jan 2024 17:03:11 -0800 Subject: [PATCH] remove collectd/df monitor (#3996) --- .../signalfx-agent/pkg/core/modules_linux.go | 1 - .../pkg/monitors/collectd/df/df.go | 93 ------------------- .../pkg/monitors/collectd/df/df.tmpl | 25 ----- .../pkg/monitors/collectd/df/genmetadata.go | 78 ---------------- .../pkg/monitors/collectd/df/metadata.yaml | 81 ---------------- .../pkg/monitors/collectd/df/template.go | 41 -------- .../pkg/monitors/filesystems/metadata.yaml | 22 ----- pkg/receiver/smartagentreceiver/config.go | 2 +- 8 files changed, 1 insertion(+), 342 deletions(-) delete mode 100644 internal/signalfx-agent/pkg/monitors/collectd/df/df.go delete mode 100644 internal/signalfx-agent/pkg/monitors/collectd/df/df.tmpl delete mode 100644 internal/signalfx-agent/pkg/monitors/collectd/df/genmetadata.go delete mode 100644 internal/signalfx-agent/pkg/monitors/collectd/df/metadata.yaml delete mode 100644 internal/signalfx-agent/pkg/monitors/collectd/df/template.go diff --git a/internal/signalfx-agent/pkg/core/modules_linux.go b/internal/signalfx-agent/pkg/core/modules_linux.go index 6401ea2f2d..1cb174e905 100644 --- a/internal/signalfx-agent/pkg/core/modules_linux.go +++ b/internal/signalfx-agent/pkg/core/modules_linux.go @@ -16,7 +16,6 @@ import ( _ "github.com/signalfx/signalfx-agent/pkg/monitors/collectd/cpu" _ "github.com/signalfx/signalfx-agent/pkg/monitors/collectd/cpufreq" _ "github.com/signalfx/signalfx-agent/pkg/monitors/collectd/custom" - _ "github.com/signalfx/signalfx-agent/pkg/monitors/collectd/df" _ "github.com/signalfx/signalfx-agent/pkg/monitors/collectd/disk" _ "github.com/signalfx/signalfx-agent/pkg/monitors/collectd/genericjmx" _ "github.com/signalfx/signalfx-agent/pkg/monitors/collectd/hadoopjmx" diff --git a/internal/signalfx-agent/pkg/monitors/collectd/df/df.go b/internal/signalfx-agent/pkg/monitors/collectd/df/df.go deleted file mode 100644 index 5f050bd3f6..0000000000 --- a/internal/signalfx-agent/pkg/monitors/collectd/df/df.go +++ /dev/null @@ -1,93 +0,0 @@ -//go:build linux -// +build linux - -package df - -//go:generate ../../../../scripts/collectd-template-to-go df.tmpl - -import ( - "github.com/signalfx/signalfx-agent/pkg/core/config" - "github.com/signalfx/signalfx-agent/pkg/monitors" - "github.com/signalfx/signalfx-agent/pkg/monitors/collectd" -) - -func init() { - monitors.Register(&monitorMetadata, func() interface{} { - return &Monitor{ - MonitorCore: *collectd.NewMonitorCore(CollectdTemplate), - } - }, &Config{}) -} - -// Config is the monitor-specific config with the generic config embedded -type Config struct { - config.MonitorConfig `yaml:",inline" singleInstance:"true"` - // Path to the root of the host filesystem. Useful when running in a - // container and the host filesystem is mounted in some subdirectory under - // /. - HostFSPath string `yaml:"hostFSPath"` - - // If true, the filesystems selected by `fsTypes` and `mountPoints` will be - // excluded and all others included. - IgnoreSelected *bool `yaml:"ignoreSelected" default:"true"` - - // The filesystem types to include/exclude. - FSTypes []string `yaml:"fsTypes" default:"[\"aufs\", \"overlay\", \"tmpfs\", \"proc\", \"sysfs\", \"nsfs\", \"cgroup\", \"devpts\", \"selinuxfs\", \"devtmpfs\", \"debugfs\", \"mqueue\", \"hugetlbfs\", \"securityfs\", \"pstore\", \"binfmt_misc\", \"autofs\"]"` - - // The mount paths to include/exclude, is interpreted as a regex if - // surrounded by `/`. Note that you need to include the full path as the - // agent will see it, irrespective of the hostFSPath option. - MountPoints []string `yaml:"mountPoints" default:"[\"/^/var/lib/docker/\", \"/^/var/lib/rkt/pods/\", \"/^/net//\", \"/^/smb//\"]"` - ReportByDevice bool `yaml:"reportByDevice" default:"false"` - ReportInodes bool `yaml:"reportInodes" default:"false"` - - // If true percent based metrics will be reported. - ValuesPercentage bool `yaml:"valuesPercentage" default:"false"` -} - -// Monitor is the main type that represents the monitor -type Monitor struct { - collectd.MonitorCore -} - -// GetExtraMetrics returns additional metrics to allow through. -func (c *Config) GetExtraMetrics() []string { - var extraMetrics []string - if c.ReportInodes { - extraMetrics = append(extraMetrics, groupMetricsMap[groupInodes]...) - } - if c.ValuesPercentage { - extraMetrics = append(extraMetrics, groupMetricsMap[groupPercentage]...) - } - if c.ReportInodes && c.ValuesPercentage { - extraMetrics = append(extraMetrics, percentInodesFree, percentInodesReserved, percentInodesUsed) - } - return extraMetrics -} - -// Configure configures and runs the plugin in collectd -func (m *Monitor) Configure(config *Config) error { - // conf is a config shallow copy that will be mutated and used to configure moni tor - conf := *config - // Setting group flags in conf for enable extra metrics - if m.Output.HasEnabledMetricInGroup(groupInodes) { - conf.ReportInodes = true - } - if m.Output.HasEnabledMetricInGroup(groupPercentage) { - conf.ValuesPercentage = true - } - if m.isReportInodesAndValuesPercentageMetric() { - conf.ReportInodes = true - conf.ValuesPercentage = true - } - return m.SetConfigurationAndRun(&conf, collectd.WithDeprecationWarningLog("filesystems")) -} - -func (m *Monitor) isReportInodesAndValuesPercentageMetric() bool { - for _, metric := range m.Output.EnabledMetrics() { - if metric == percentInodesFree || metric == percentInodesReserved || metric == percentInodesUsed { - return true - } - } - return false -} diff --git a/internal/signalfx-agent/pkg/monitors/collectd/df/df.tmpl b/internal/signalfx-agent/pkg/monitors/collectd/df/df.tmpl deleted file mode 100644 index 755b46f165..0000000000 --- a/internal/signalfx-agent/pkg/monitors/collectd/df/df.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -LoadPlugin df - - ChangeRoot "{{.HostFSPath}}" - IgnoreSelected {{toBool .IgnoreSelected}} -{{range .FSTypes}} - FSType "{{.}}" -{{- end}} -{{range .MountPoints}} - MountPoint "{{.}}" -{{- end}} - ReportByDevice {{if .ReportByDevice}}true{{else}}false{{end}} - ReportInodes {{if .ReportInodes}}true{{else}}false{{end}} - ValuesPercentage {{if .ValuesPercentage}}true{{else}}false{{end}} - - - - - - Plugin "^df$" - - - MetaData "monitorID" "{{.MonitorID}}" - - - diff --git a/internal/signalfx-agent/pkg/monitors/collectd/df/genmetadata.go b/internal/signalfx-agent/pkg/monitors/collectd/df/genmetadata.go deleted file mode 100644 index e32a829ca2..0000000000 --- a/internal/signalfx-agent/pkg/monitors/collectd/df/genmetadata.go +++ /dev/null @@ -1,78 +0,0 @@ -// Code generated by monitor-code-gen. DO NOT EDIT. - -package df - -import ( - "github.com/signalfx/golib/v3/datapoint" - "github.com/signalfx/signalfx-agent/pkg/monitors" -) - -const monitorType = "collectd/df" - -const ( - groupInodes = "inodes" - groupPercentage = "percentage" -) - -var groupSet = map[string]bool{ - groupInodes: true, - groupPercentage: true, -} - -const ( - dfComplexFree = "df_complex.free" - dfComplexReserved = "df_complex.reserved" - dfComplexUsed = "df_complex.used" - dfInodesFree = "df_inodes.free" - dfInodesReserved = "df_inodes.reserved" - dfInodesUsed = "df_inodes.used" - percentBytesFree = "percent_bytes.free" - percentBytesReserved = "percent_bytes.reserved" - percentBytesUsed = "percent_bytes.used" - percentInodesFree = "percent_inodes.free" - percentInodesReserved = "percent_inodes.reserved" - percentInodesUsed = "percent_inodes.used" -) - -var metricSet = map[string]monitors.MetricInfo{ - dfComplexFree: {Type: datapoint.Gauge}, - dfComplexReserved: {Type: datapoint.Gauge}, - dfComplexUsed: {Type: datapoint.Gauge}, - dfInodesFree: {Type: datapoint.Gauge, Group: groupInodes}, - dfInodesReserved: {Type: datapoint.Gauge, Group: groupInodes}, - dfInodesUsed: {Type: datapoint.Gauge, Group: groupInodes}, - percentBytesFree: {Type: datapoint.Gauge, Group: groupPercentage}, - percentBytesReserved: {Type: datapoint.Gauge, Group: groupPercentage}, - percentBytesUsed: {Type: datapoint.Gauge, Group: groupPercentage}, - percentInodesFree: {Type: datapoint.Gauge}, - percentInodesReserved: {Type: datapoint.Gauge}, - percentInodesUsed: {Type: datapoint.Gauge}, -} - -var defaultMetrics = map[string]bool{ - dfComplexFree: true, - dfComplexUsed: true, -} - -var groupMetricsMap = map[string][]string{ - groupInodes: { - dfInodesFree, - dfInodesReserved, - dfInodesUsed, - }, - groupPercentage: { - percentBytesFree, - percentBytesReserved, - percentBytesUsed, - }, -} - -var monitorMetadata = monitors.Metadata{ - MonitorType: "collectd/df", - DefaultMetrics: defaultMetrics, - Metrics: metricSet, - SendUnknown: false, - Groups: groupSet, - GroupMetricsMap: groupMetricsMap, - SendAll: false, -} diff --git a/internal/signalfx-agent/pkg/monitors/collectd/df/metadata.yaml b/internal/signalfx-agent/pkg/monitors/collectd/df/metadata.yaml deleted file mode 100644 index 0e95f12588..0000000000 --- a/internal/signalfx-agent/pkg/monitors/collectd/df/metadata.yaml +++ /dev/null @@ -1,81 +0,0 @@ -monitors: -- dimensions: - doc: | - Tracks free disk space on the host using the collectd [df - plugin](https://collectd.org/wiki/index.php/Plugin:DF). - - Note that on Linux a filesystem **must** be mounted in the same filesystem - namespace that the agent is running in for this monitor to be able to - collect statistics about that filesystem. This is mostly an issue when - running the agent in a container. - - **This plugin is deprecated in favor of the `filesystems` monitor.** - metrics: - df_complex.free: - description: |- - Measures free disk space in bytes on this file system. - default: true - type: gauge - df_complex.reserved: - description: |- - Measures disk space in bytes reserved for the super-user on this file system. - default: false - type: gauge - df_complex.used: - description: |- - Measures used disk space in bytes on this file system. - default: true - type: gauge - df_inodes.free: - description: |- - Measures free inodes in the file system. Inodes are structures used by Unix filesystems to store metadata about files. - default: false - type: gauge - group: inodes - df_inodes.reserved: - description: |- - Measures inodes reserved for the super user in the file system. Inodes are structures used by Unix filesystems to store metadata about files. - default: false - type: gauge - group: inodes - df_inodes.used: - description: |- - Measures used inodes in the file system. Inodes are structures used by Unix filesystems to store metadata about files. - default: false - type: gauge - group: inodes - percent_bytes.free: - description: |- - Measures free disk space as a percentage of total disk space on this file system. - default: false - type: gauge - group: percentage - percent_bytes.reserved: - description: |- - Measures disk space reserved for the super-user as a percentage of total disk space of this file system. - default: false - type: gauge - group: percentage - percent_bytes.used: - description: |- - Measures used disk space as a percentage of total disk space of this file system. - default: false - type: gauge - group: percentage - percent_inodes.free: - description: |- - Measures free inodes as a percentage of total inodes in the file system. Inodes are structures used by file systems to store information about files (other than its content). - default: false - type: gauge - percent_inodes.reserved: - description: |- - Measures inodes reserved for the super-user as a percentage of total inodes in the file system. Inodes are structures used by file systems to store information about files (other than its content). - default: false - type: gauge - percent_inodes.used: - description: |- - Measures used inodes as a percentage of total inodes in the file system. Inodes are structures used by file systems to store information about files (other than its content). - default: false - type: gauge - monitorType: collectd/df - properties: diff --git a/internal/signalfx-agent/pkg/monitors/collectd/df/template.go b/internal/signalfx-agent/pkg/monitors/collectd/df/template.go deleted file mode 100644 index 8bb34f8d9d..0000000000 --- a/internal/signalfx-agent/pkg/monitors/collectd/df/template.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build linux -// +build linux - -package df - -// AUTOGENERATED BY scripts/collectd-template-to-go. DO NOT EDIT!! - -import ( - "text/template" - - "github.com/signalfx/signalfx-agent/pkg/monitors/collectd" -) - -// CollectdTemplate is a template for a df collectd config file -var CollectdTemplate = template.Must(collectd.InjectTemplateFuncs(template.New("df")).Parse(` -LoadPlugin df - - ChangeRoot "{{.HostFSPath}}" - IgnoreSelected {{toBool .IgnoreSelected}} -{{range .FSTypes}} - FSType "{{.}}" -{{- end}} -{{range .MountPoints}} - MountPoint "{{.}}" -{{- end}} - ReportByDevice {{if .ReportByDevice}}true{{else}}false{{end}} - ReportInodes {{if .ReportInodes}}true{{else}}false{{end}} - ValuesPercentage {{if .ValuesPercentage}}true{{else}}false{{end}} - - - - - - Plugin "^df$" - - - MetaData "monitorID" "{{.MonitorID}}" - - - -`)).Option("missingkey=error") diff --git a/internal/signalfx-agent/pkg/monitors/filesystems/metadata.yaml b/internal/signalfx-agent/pkg/monitors/filesystems/metadata.yaml index baabaabf1a..bc7e5724d9 100644 --- a/internal/signalfx-agent/pkg/monitors/filesystems/metadata.yaml +++ b/internal/signalfx-agent/pkg/monitors/filesystems/metadata.yaml @@ -13,28 +13,6 @@ monitors: - type: filesystems hostFSPath: /hostfs ``` - - ## Migrating from collectd/df - The `collectd/df` monitor is being deprecated in favor of the `filesystems` - monitor. While the `collectd/df` monitor will still be available in - 5.0, it is recommended that you switch to the `filesystems` monitor soon - after upgrading. There are a few incompatibilities to be aware of between - the two monitors: - - - `collectd/df` used a dimension called `plugin_instance` to identify the - mount point or device of the filesystem. This dimension is completely - removed in the `filesystems` monitor and replaced by the `mountpoint` - and `device` dimensions. You no longer have to select between the two - (the `reportByDevice` option on `collectd/df`) as both are always - reported. - - - The mountpoints in the `plugin_instance` dimension of `collectd/df` - were reported with `-` instead of the more conventional `/` separated - path segments. The `filesystems` monitor always reports mountpoints in - the `mountpoint` dimension and uses the conventional `/` separator. - - - The `collectd/df` plugin set a dimension `plugin: df` on all datapoints, - but `filesystems` has no such comparable dimension. metrics: df_complex.free: description: Free disk space in bytes diff --git a/pkg/receiver/smartagentreceiver/config.go b/pkg/receiver/smartagentreceiver/config.go index 83c774a898..70696e6926 100644 --- a/pkg/receiver/smartagentreceiver/config.go +++ b/pkg/receiver/smartagentreceiver/config.go @@ -38,7 +38,7 @@ var ( errDimensionClientValue = fmt.Errorf("dimensionClients must be an array of compatible exporter names") nonWindowsMonitors = map[string]bool{ "collectd/activemq": true, "collectd/apache": true, "collectd/cassandra": true, "collectd/chrony": true, - "collectd/cpu": true, "collectd/cpufreq": true, "collectd/custom": true, "collectd/df": true, "collectd/disk": true, + "collectd/cpu": true, "collectd/cpufreq": true, "collectd/custom": true, "collectd/disk": true, "collectd/genericjmx": true, "collectd/hadoopjmx": true, "collectd/kafka": true, "collectd/kafka_consumer": true, "collectd/kafka_producer": true, "collectd/load": true, "collectd/memcached": true, "collectd/memory": true, "collectd/mysql": true, "collectd/netinterface": true, "collectd/nginx": true, "collectd/php-fpm": true,