diff --git a/plugins/inputs/smartctl/README.md b/plugins/inputs/smartctl/README.md index 9692605994d1e..376a7c1c889be 100644 --- a/plugins/inputs/smartctl/README.md +++ b/plugins/inputs/smartctl/README.md @@ -59,6 +59,14 @@ plugin ordering. See [CONFIGURATION.md][CONFIGURATION.md] for more details. ## * idle: check the device unless it is in sleep, standby, or idle mode # nocheck = "standby" + ## Metric version changes the naming of tags in the smartctl_attributes + ## outputs. Currently "smartctl_attribute" metrics include the attribute + ## name in the "name" tag, and the associated device is not in any tag, + ## making it harder to associate them to the "smartctl" metrics. + ## metric_version = 2 will use the "name" tag for the the device name, + ## and a new "attribute" tag for the attribute name. + metric_version = 1 + ## Timeout for the cli command to complete # timeout = "30s" ``` @@ -113,7 +121,8 @@ having issues. - smartctl_attributes - tags - model (model name of the storage device) - - name (name of the attribute) + - name (name of the attribute - or the device id if selected by `metric_version=2`) + - attribute (name of the attribute - if selected by `metric_version=2`) - serial (serial number of the device) - type (device type like SATA etc) - wwn (world wide number of the device) diff --git a/plugins/inputs/smartctl/sample.conf b/plugins/inputs/smartctl/sample.conf index 85cd4d5624699..c7e367da4d55f 100644 --- a/plugins/inputs/smartctl/sample.conf +++ b/plugins/inputs/smartctl/sample.conf @@ -26,5 +26,13 @@ ## * idle: check the device unless it is in sleep, standby, or idle mode # nocheck = "standby" + ## Metric version changes the naming of tags in the smartctl_attributes + ## outputs. Currently "smartctl_attribute" metrics include the attribute + ## name in the "name" tag, and the associated device is not in any tag, + ## making it harder to associate them to the "smartctl" metrics. + ## metric_version = 2 will use the "name" tag for the the device name, + ## and a new "attribute" tag for the attribute name. + # metric_version = 1 + ## Timeout for the cli command to complete # timeout = "30s" diff --git a/plugins/inputs/smartctl/smartctl.go b/plugins/inputs/smartctl/smartctl.go index b4f34ca2f58f8..27da77e839c89 100644 --- a/plugins/inputs/smartctl/smartctl.go +++ b/plugins/inputs/smartctl/smartctl.go @@ -28,6 +28,7 @@ type Smartctl struct { Timeout config.Duration `toml:"timeout"` DevicesInclude []string `toml:"devices_include"` DevicesExclude []string `toml:"devices_exclude"` + MetricVersion int `toml:"metric_version"` Log telegraf.Logger `toml:"-"` deviceFilter filter.Filter diff --git a/plugins/inputs/smartctl/smartctl_device.go b/plugins/inputs/smartctl/smartctl_device.go index 7bbb37ef82c31..b46b0422c376b 100644 --- a/plugins/inputs/smartctl/smartctl_device.go +++ b/plugins/inputs/smartctl/smartctl_device.go @@ -136,7 +136,12 @@ func (s *Smartctl) scanDevice(acc telegraf.Accumulator, deviceName, deviceType s for k, v := range tags { attributeTags[k] = v } - attributeTags["name"] = attribute.Name + + if s.MetricVersion == 2 { + attributeTags["attribute"] = attribute.Name + } else { + attributeTags["name"] = attribute.Name // overwrite device name + } fields := map[string]interface{}{ "raw_value": attribute.Raw.Value,