mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-13 17:14:23 -08:00
Fix diskstats exclude flags (#2487)
Correctly handle the new `collector.diskstats.device-exclude` flag to avoid errors when using the old `collector.diskstats.ignored-devices` flag. Fixes: https://github.com/prometheus/node_exporter/issues/2486 Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
7da1321761
commit
8b87a2ecdf
|
@ -33,8 +33,19 @@ const (
|
||||||
var (
|
var (
|
||||||
diskLabelNames = []string{"device"}
|
diskLabelNames = []string{"device"}
|
||||||
|
|
||||||
diskstatsDeviceExclude = kingpin.Flag("collector.diskstats.device-exclude", "Regexp of diskstats devices to exclude (mutually exclusive to device-include).").Default(diskstatsDefaultIgnoredDevices).String()
|
diskstatsDeviceExcludeSet bool
|
||||||
oldDiskstatsDeviceExclude = kingpin.Flag("collector.diskstats.ignored-devices", "DEPRECATED: Use collector.diskstats.device-exclude").String()
|
diskstatsDeviceExclude = kingpin.Flag(
|
||||||
|
"collector.diskstats.device-exclude",
|
||||||
|
"Regexp of diskstats devices to exclude (mutually exclusive to device-include).",
|
||||||
|
).Default(diskstatsDefaultIgnoredDevices).PreAction(func(c *kingpin.ParseContext) error {
|
||||||
|
diskstatsDeviceExcludeSet = true
|
||||||
|
return nil
|
||||||
|
}).String()
|
||||||
|
oldDiskstatsDeviceExclude = kingpin.Flag(
|
||||||
|
"collector.diskstats.ignored-devices",
|
||||||
|
"DEPRECATED: Use collector.diskstats.device-exclude",
|
||||||
|
).Hidden().String()
|
||||||
|
|
||||||
diskstatsDeviceInclude = kingpin.Flag("collector.diskstats.device-include", "Regexp of diskstats devices to include (mutually exclusive to device-exclude).").String()
|
diskstatsDeviceInclude = kingpin.Flag("collector.diskstats.device-include", "Regexp of diskstats devices to include (mutually exclusive to device-exclude).").String()
|
||||||
|
|
||||||
readsCompletedDesc = prometheus.NewDesc(
|
readsCompletedDesc = prometheus.NewDesc(
|
||||||
|
@ -84,7 +95,7 @@ var (
|
||||||
|
|
||||||
func newDiskstatsDeviceFilter(logger log.Logger) (deviceFilter, error) {
|
func newDiskstatsDeviceFilter(logger log.Logger) (deviceFilter, error) {
|
||||||
if *oldDiskstatsDeviceExclude != "" {
|
if *oldDiskstatsDeviceExclude != "" {
|
||||||
if *diskstatsDeviceExclude == "" {
|
if !diskstatsDeviceExcludeSet {
|
||||||
level.Warn(logger).Log("msg", "--collector.diskstats.ignored-devices is DEPRECATED and will be removed in 2.0.0, use --collector.diskstats.device-exclude")
|
level.Warn(logger).Log("msg", "--collector.diskstats.ignored-devices is DEPRECATED and will be removed in 2.0.0, use --collector.diskstats.device-exclude")
|
||||||
*diskstatsDeviceExclude = *oldDiskstatsDeviceExclude
|
*diskstatsDeviceExclude = *oldDiskstatsDeviceExclude
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue