1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
From: Martina Ferrari <tina@debian.org>
Date: Mon, 13 Nov 2023 13:49:27 +0100
Subject: Set defaults that make sense for Debian systems
Forwarded: not-needed
We remove the deprecated options completely because they were introduced in
1.0.0 and were never part of a stable release, and are causing issues with
the default value setting as it then makes the code consider it a usage and
errors out when the legacy option is used.
This patch also enables the systemd collector by default.
---
collector/filesystem_linux.go | 2 +-
collector/netdev_common.go | 20 --------------------
collector/systemd_linux.go | 23 ++---------------------
collector/textfile.go | 2 +-
4 files changed, 4 insertions(+), 43 deletions(-)
diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go
index 3a7bda4..81a738c 100644
--- a/collector/filesystem_linux.go
+++ b/collector/filesystem_linux.go
@@ -32,7 +32,7 @@ import (
)
const (
- defMountPointsExcluded = "^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+|var/lib/containers/storage/.+)($|/)"
+ defMountPointsExcluded = "^/(dev|proc|run|sys|mnt|media|var/lib/docker/.+|var/lib/containers/storage/.+)($|/)"
defFSTypesExcluded = "^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
)
diff --git a/collector/netdev_common.go b/collector/netdev_common.go
index c19e5df..7125ae6 100644
--- a/collector/netdev_common.go
+++ b/collector/netdev_common.go
@@ -31,9 +31,7 @@ import (
var (
netdevDeviceInclude = kingpin.Flag("collector.netdev.device-include", "Regexp of net devices to include (mutually exclusive to device-exclude).").String()
- oldNetdevDeviceInclude = kingpin.Flag("collector.netdev.device-whitelist", "DEPRECATED: Use collector.netdev.device-include").Hidden().String()
netdevDeviceExclude = kingpin.Flag("collector.netdev.device-exclude", "Regexp of net devices to exclude (mutually exclusive to device-include).").String()
- oldNetdevDeviceExclude = kingpin.Flag("collector.netdev.device-blacklist", "DEPRECATED: Use collector.netdev.device-exclude").Hidden().String()
netdevAddressInfo = kingpin.Flag("collector.netdev.address-info", "Collect address-info for every device").Bool()
netdevDetailedMetrics = kingpin.Flag("collector.netdev.enable-detailed-metrics", "Use (incompatible) metric names that provide more detailed stats on Linux").Bool()
)
@@ -54,24 +52,6 @@ func init() {
// NewNetDevCollector returns a new Collector exposing network device stats.
func NewNetDevCollector(logger *slog.Logger) (Collector, error) {
- if *oldNetdevDeviceInclude != "" {
- if *netdevDeviceInclude == "" {
- logger.Warn("--collector.netdev.device-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-include")
- *netdevDeviceInclude = *oldNetdevDeviceInclude
- } else {
- return nil, errors.New("--collector.netdev.device-whitelist and --collector.netdev.device-include are mutually exclusive")
- }
- }
-
- if *oldNetdevDeviceExclude != "" {
- if *netdevDeviceExclude == "" {
- logger.Warn("--collector.netdev.device-blacklist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-exclude")
- *netdevDeviceExclude = *oldNetdevDeviceExclude
- } else {
- return nil, errors.New("--collector.netdev.device-blacklist and --collector.netdev.device-exclude are mutually exclusive")
- }
- }
-
if *netdevDeviceExclude != "" && *netdevDeviceInclude != "" {
return nil, errors.New("device-exclude & device-include are mutually exclusive")
}
diff --git a/collector/systemd_linux.go b/collector/systemd_linux.go
index ee2ded8..b1a7ebf 100644
--- a/collector/systemd_linux.go
+++ b/collector/systemd_linux.go
@@ -18,7 +18,6 @@ package collector
import (
"context"
- "errors"
"fmt"
"log/slog"
"math"
@@ -46,13 +45,11 @@ var (
systemdUnitIncludeSet = true
return nil
}).String()
- oldSystemdUnitInclude = kingpin.Flag("collector.systemd.unit-whitelist", "DEPRECATED: Use --collector.systemd.unit-include").Hidden().String()
systemdUnitExcludeSet bool
- systemdUnitExclude = kingpin.Flag("collector.systemd.unit-exclude", "Regexp of systemd units to exclude. Units must both match include and not match exclude to be included.").Default(".+\\.(automount|device|mount|scope|slice)").PreAction(func(c *kingpin.ParseContext) error {
+ systemdUnitExclude = kingpin.Flag("collector.systemd.unit-exclude", "Regexp of systemd units to exclude. Units must both match include and not match exclude to be included.").Default(".+\\.(automount|device|mount|scope|slice|target)").PreAction(func(c *kingpin.ParseContext) error {
systemdUnitExcludeSet = true
return nil
}).String()
- oldSystemdUnitExclude = kingpin.Flag("collector.systemd.unit-blacklist", "DEPRECATED: Use collector.systemd.unit-exclude").Hidden().String()
systemdPrivate = kingpin.Flag("collector.systemd.private", "Establish a private, direct connection to systemd without dbus (Strongly discouraged since it requires root. For testing purposes only).").Hidden().Bool()
enableTaskMetrics = kingpin.Flag("collector.systemd.enable-task-metrics", "Enables service unit tasks metrics unit_tasks_current and unit_tasks_max").Bool()
enableRestartsMetrics = kingpin.Flag("collector.systemd.enable-restarts-metrics", "Enables service unit metric service_restart_total").Bool()
@@ -83,7 +80,7 @@ type systemdCollector struct {
var unitStatesName = []string{"active", "activating", "deactivating", "inactive", "failed"}
func init() {
- registerCollector("systemd", defaultDisabled, NewSystemdCollector)
+ registerCollector("systemd", defaultEnabled, NewSystemdCollector)
}
// NewSystemdCollector returns a new Collector exposing systemd statistics.
@@ -133,22 +130,6 @@ func NewSystemdCollector(logger *slog.Logger) (Collector, error) {
prometheus.BuildFQName(namespace, subsystem, "version"),
"Detected systemd version", []string{"version"}, nil)
- if *oldSystemdUnitExclude != "" {
- if !systemdUnitExcludeSet {
- logger.Warn("--collector.systemd.unit-blacklist is DEPRECATED and will be removed in 2.0.0, use --collector.systemd.unit-exclude")
- *systemdUnitExclude = *oldSystemdUnitExclude
- } else {
- return nil, errors.New("--collector.systemd.unit-blacklist and --collector.systemd.unit-exclude are mutually exclusive")
- }
- }
- if *oldSystemdUnitInclude != "" {
- if !systemdUnitIncludeSet {
- logger.Warn("--collector.systemd.unit-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.systemd.unit-include")
- *systemdUnitInclude = *oldSystemdUnitInclude
- } else {
- return nil, errors.New("--collector.systemd.unit-whitelist and --collector.systemd.unit-include are mutually exclusive")
- }
- }
logger.Info("Parsed flag --collector.systemd.unit-include", "flag", *systemdUnitInclude)
systemdUnitIncludePattern := regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *systemdUnitInclude))
logger.Info("Parsed flag --collector.systemd.unit-exclude", "flag", *systemdUnitExclude)
diff --git a/collector/textfile.go b/collector/textfile.go
index 3e0cc45..e04499d 100644
--- a/collector/textfile.go
+++ b/collector/textfile.go
@@ -32,7 +32,7 @@ import (
)
var (
- textFileDirectories = kingpin.Flag("collector.textfile.directory", "Directory to read text files with metrics from, supports glob matching. (repeatable)").Default("").Strings()
+ textFileDirectories = kingpin.Flag("collector.textfile.directory", "Directory to read text files with metrics from, supports glob matching. (repeatable)").Default("/var/lib/prometheus/node-exporter").Strings()
mtimeDesc = prometheus.NewDesc(
"node_textfile_mtime_seconds",
"Unixtime mtime of textfiles successfully read.",
|