diff options
author | Paul Gier <pgier@redhat.com> | 2019-02-07 08:59:32 -0600 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2019-02-07 15:59:32 +0100 |
commit | e0d6d1185988bb1eb33779539399dd0e6cab0238 (patch) | |
tree | 737784bba3553c7eb8719b10aa0f71b14d138054 | |
parent | 6ea0aa73e4ab40259d843b41adeea43b1a78379b (diff) | |
download | prometheus_node_collector-e0d6d1185988bb1eb33779539399dd0e6cab0238.tar.bz2 prometheus_node_collector-e0d6d1185988bb1eb33779539399dd0e6cab0238.tar.xz prometheus_node_collector-e0d6d1185988bb1eb33779539399dd0e6cab0238.zip |
netclass_linux: remove varying labels from the 'up' metric (#1243)
* netclass_linux: remove varying labels from the 'up' metric
This moves the variable label values such as 'operstate' out of
the 'network_up' metric and into a separate metric called '_info'.
This allows the 'up' metric to remain continous over state changes.
Fixes #1236
Signed-off-by: Paul Gier <pgier@redhat.com>
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | collector/fixtures/e2e-64k-page-output.txt | 7 | ||||
-rw-r--r-- | collector/fixtures/e2e-output.txt | 7 | ||||
-rw-r--r-- | collector/netclass_linux.go | 18 |
4 files changed, 26 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d95bc2..77f84cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -5,6 +5,7 @@ | |||
5 | * Renamed `interface` label to `device` in netclass collector for consistency with | 5 | * Renamed `interface` label to `device` in netclass collector for consistency with |
6 | other network metrics #1224 | 6 | other network metrics #1224 |
7 | * The cpufreq metrics now separate the `cpufreq` and `scaling` data based on what the driver provides. #1248 | 7 | * The cpufreq metrics now separate the `cpufreq` and `scaling` data based on what the driver provides. #1248 |
8 | * The labels for the network_up metric have changed, see issue #1236 | ||
8 | 9 | ||
9 | ### Changes | 10 | ### Changes |
10 | 11 | ||
@@ -15,6 +16,7 @@ | |||
15 | * [CHANGE] Add a limit to the number of in-flight requests #1166 | 16 | * [CHANGE] Add a limit to the number of in-flight requests #1166 |
16 | * [CHANGE] Add separate cpufreq and scaling metrics #1248 | 17 | * [CHANGE] Add separate cpufreq and scaling metrics #1248 |
17 | * [ENHANCEMENT] Add Infiniband counters #1120 | 18 | * [ENHANCEMENT] Add Infiniband counters #1120 |
19 | * [ENHANCEMENT] Move network_up labels into new metric network_info #1236 | ||
18 | * [FEATURE] Add a flag to disable exporter metrics #1148 | 20 | * [FEATURE] Add a flag to disable exporter metrics #1148 |
19 | * [FEATURE] Add kstat-based Solaris metrics for boottime, cpu and zfs collectors #1197 | 21 | * [FEATURE] Add kstat-based Solaris metrics for boottime, cpu and zfs collectors #1197 |
20 | * [FEATURE] Add uname collector for FreeBSD #1239 | 22 | * [FEATURE] Add uname collector for FreeBSD #1239 |
diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 7e61462..aa96e91 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt | |||
@@ -1835,6 +1835,9 @@ node_network_iface_link{interface="eth0"} 2 | |||
1835 | # HELP node_network_iface_link_mode iface_link_mode value of /sys/class/net/<iface>. | 1835 | # HELP node_network_iface_link_mode iface_link_mode value of /sys/class/net/<iface>. |
1836 | # TYPE node_network_iface_link_mode gauge | 1836 | # TYPE node_network_iface_link_mode gauge |
1837 | node_network_iface_link_mode{interface="eth0"} 1 | 1837 | node_network_iface_link_mode{interface="eth0"} 1 |
1838 | # HELP node_network_info Non-numeric data from /sys/class/net/<iface>, value is always 1. | ||
1839 | # TYPE node_network_info gauge | ||
1840 | node_network_info{address="01:01:01:01:01:01",broadcast="ff:ff:ff:ff:ff:ff",device="eth0",duplex="full",ifalias="",operstate="up"} 1 | ||
1838 | # HELP node_network_mtu_bytes mtu_bytes value of /sys/class/net/<iface>. | 1841 | # HELP node_network_mtu_bytes mtu_bytes value of /sys/class/net/<iface>. |
1839 | # TYPE node_network_mtu_bytes gauge | 1842 | # TYPE node_network_mtu_bytes gauge |
1840 | node_network_mtu_bytes{interface="eth0"} 1500 | 1843 | node_network_mtu_bytes{interface="eth0"} 1500 |
@@ -2045,9 +2048,9 @@ node_network_transmit_packets_total{device="💩0"} 304261 | |||
2045 | # HELP node_network_transmit_queue_length transmit_queue_length value of /sys/class/net/<iface>. | 2048 | # HELP node_network_transmit_queue_length transmit_queue_length value of /sys/class/net/<iface>. |
2046 | # TYPE node_network_transmit_queue_length gauge | 2049 | # TYPE node_network_transmit_queue_length gauge |
2047 | node_network_transmit_queue_length{interface="eth0"} 1000 | 2050 | node_network_transmit_queue_length{interface="eth0"} 1000 |
2048 | # HELP node_network_up Valid operstate for interface. | 2051 | # HELP node_network_up Value is 1 if operstate is 'up', 0 otherwise. |
2049 | # TYPE node_network_up gauge | 2052 | # TYPE node_network_up gauge |
2050 | node_network_up{address="01:01:01:01:01:01",broadcast="ff:ff:ff:ff:ff:ff",duplex="full",ifalias="",interface="eth0",operstate="up"} 1 | 2053 | node_network_up{device="eth0"} 1 |
2051 | # HELP node_nf_conntrack_entries Number of currently allocated flow entries for connection tracking. | 2054 | # HELP node_nf_conntrack_entries Number of currently allocated flow entries for connection tracking. |
2052 | # TYPE node_nf_conntrack_entries gauge | 2055 | # TYPE node_nf_conntrack_entries gauge |
2053 | node_nf_conntrack_entries 123 | 2056 | node_nf_conntrack_entries 123 |
diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 2f9e097..d278833 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt | |||
@@ -1835,6 +1835,9 @@ node_network_iface_link{device="eth0"} 2 | |||
1835 | # HELP node_network_iface_link_mode iface_link_mode value of /sys/class/net/<iface>. | 1835 | # HELP node_network_iface_link_mode iface_link_mode value of /sys/class/net/<iface>. |
1836 | # TYPE node_network_iface_link_mode gauge | 1836 | # TYPE node_network_iface_link_mode gauge |
1837 | node_network_iface_link_mode{device="eth0"} 1 | 1837 | node_network_iface_link_mode{device="eth0"} 1 |
1838 | # HELP node_network_info Non-numeric data from /sys/class/net/<iface>, value is always 1. | ||
1839 | # TYPE node_network_info gauge | ||
1840 | node_network_info{address="01:01:01:01:01:01",broadcast="ff:ff:ff:ff:ff:ff",device="eth0",duplex="full",ifalias="",operstate="up"} 1 | ||
1838 | # HELP node_network_mtu_bytes mtu_bytes value of /sys/class/net/<iface>. | 1841 | # HELP node_network_mtu_bytes mtu_bytes value of /sys/class/net/<iface>. |
1839 | # TYPE node_network_mtu_bytes gauge | 1842 | # TYPE node_network_mtu_bytes gauge |
1840 | node_network_mtu_bytes{device="eth0"} 1500 | 1843 | node_network_mtu_bytes{device="eth0"} 1500 |
@@ -2045,9 +2048,9 @@ node_network_transmit_packets_total{device="💩0"} 304261 | |||
2045 | # HELP node_network_transmit_queue_length transmit_queue_length value of /sys/class/net/<iface>. | 2048 | # HELP node_network_transmit_queue_length transmit_queue_length value of /sys/class/net/<iface>. |
2046 | # TYPE node_network_transmit_queue_length gauge | 2049 | # TYPE node_network_transmit_queue_length gauge |
2047 | node_network_transmit_queue_length{device="eth0"} 1000 | 2050 | node_network_transmit_queue_length{device="eth0"} 1000 |
2048 | # HELP node_network_up Valid operstate for device. | 2051 | # HELP node_network_up Value is 1 if operstate is 'up', 0 otherwise. |
2049 | # TYPE node_network_up gauge | 2052 | # TYPE node_network_up gauge |
2050 | node_network_up{address="01:01:01:01:01:01",broadcast="ff:ff:ff:ff:ff:ff",device="eth0",duplex="full",ifalias="",operstate="up"} 1 | 2053 | node_network_up{device="eth0"} 1 |
2051 | # HELP node_nf_conntrack_entries Number of currently allocated flow entries for connection tracking. | 2054 | # HELP node_nf_conntrack_entries Number of currently allocated flow entries for connection tracking. |
2052 | # TYPE node_nf_conntrack_entries gauge | 2055 | # TYPE node_nf_conntrack_entries gauge |
2053 | node_nf_conntrack_entries 123 | 2056 | node_nf_conntrack_entries 123 |
diff --git a/collector/netclass_linux.go b/collector/netclass_linux.go index fffbd84..d70db58 100644 --- a/collector/netclass_linux.go +++ b/collector/netclass_linux.go | |||
@@ -22,7 +22,7 @@ import ( | |||
22 | 22 | ||
23 | "github.com/prometheus/client_golang/prometheus" | 23 | "github.com/prometheus/client_golang/prometheus" |
24 | "github.com/prometheus/procfs/sysfs" | 24 | "github.com/prometheus/procfs/sysfs" |
25 | "gopkg.in/alecthomas/kingpin.v2" | 25 | kingpin "gopkg.in/alecthomas/kingpin.v2" |
26 | ) | 26 | ) |
27 | 27 | ||
28 | var ( | 28 | var ( |
@@ -57,8 +57,8 @@ func (c *netClassCollector) Update(ch chan<- prometheus.Metric) error { | |||
57 | for _, ifaceInfo := range netClass { | 57 | for _, ifaceInfo := range netClass { |
58 | upDesc := prometheus.NewDesc( | 58 | upDesc := prometheus.NewDesc( |
59 | prometheus.BuildFQName(namespace, c.subsystem, "up"), | 59 | prometheus.BuildFQName(namespace, c.subsystem, "up"), |
60 | "Valid operstate for device.", | 60 | "Value is 1 if operstate is 'up', 0 otherwise.", |
61 | []string{"device", "address", "broadcast", "duplex", "operstate", "ifalias"}, | 61 | []string{"device"}, |
62 | nil, | 62 | nil, |
63 | ) | 63 | ) |
64 | upValue := 0.0 | 64 | upValue := 0.0 |
@@ -66,7 +66,17 @@ func (c *netClassCollector) Update(ch chan<- prometheus.Metric) error { | |||
66 | upValue = 1.0 | 66 | upValue = 1.0 |
67 | } | 67 | } |
68 | 68 | ||
69 | ch <- prometheus.MustNewConstMetric(upDesc, prometheus.GaugeValue, upValue, ifaceInfo.Name, ifaceInfo.Address, ifaceInfo.Broadcast, ifaceInfo.Duplex, ifaceInfo.OperState, ifaceInfo.IfAlias) | 69 | ch <- prometheus.MustNewConstMetric(upDesc, prometheus.GaugeValue, upValue, ifaceInfo.Name) |
70 | |||
71 | infoDesc := prometheus.NewDesc( | ||
72 | prometheus.BuildFQName(namespace, c.subsystem, "info"), | ||
73 | "Non-numeric data from /sys/class/net/<iface>, value is always 1.", | ||
74 | []string{"device", "address", "broadcast", "duplex", "operstate", "ifalias"}, | ||
75 | nil, | ||
76 | ) | ||
77 | infoValue := 1.0 | ||
78 | |||
79 | ch <- prometheus.MustNewConstMetric(infoDesc, prometheus.GaugeValue, infoValue, ifaceInfo.Name, ifaceInfo.Address, ifaceInfo.Broadcast, ifaceInfo.Duplex, ifaceInfo.OperState, ifaceInfo.IfAlias) | ||
70 | 80 | ||
71 | if ifaceInfo.AddrAssignType != nil { | 81 | if ifaceInfo.AddrAssignType != nil { |
72 | pushMetric(ch, c.subsystem, "address_assign_type", *ifaceInfo.AddrAssignType, ifaceInfo.Name, prometheus.GaugeValue) | 82 | pushMetric(ch, c.subsystem, "address_assign_type", *ifaceInfo.AddrAssignType, ifaceInfo.Name, prometheus.GaugeValue) |