From 4db443e5a62aed2dd3607de5131f12971c083a5d Mon Sep 17 00:00:00 2001 From: Alper Polat <101826653+gitperr@users.noreply.github.com> Date: Sat, 27 Jan 2024 18:06:25 +0200 Subject: [PATCH 01/48] Bump golang-builder version (#2908) Signed-off-by: Alper Polat --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e40a0667ef..3715e300dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,7 +60,7 @@ jobs: machine: image: ubuntu-2204:current environment: - DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.18-base + DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.21-base REPO_PATH: github.com/prometheus/node_exporter steps: - prometheus/setup_environment From 94ddad4deccf2a411de5fe4ffb402303e1b54d91 Mon Sep 17 00:00:00 2001 From: David O'Rourke Date: Mon, 29 Jan 2024 04:08:53 -0800 Subject: [PATCH 02/48] exec_bsd: Fix labels for vm.stats.sys.v_syscall sysctl (#2895) Signed-off-by: David O'Rourke --- collector/exec_bsd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/exec_bsd.go b/collector/exec_bsd.go index 7ae5e2ee32..9c123991f0 100644 --- a/collector/exec_bsd.go +++ b/collector/exec_bsd.go @@ -61,8 +61,8 @@ func NewExecCollector(logger log.Logger) (Collector, error) { name: "exec_system_calls_total", description: "System calls since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_syscall", + labels: nil, }, - labels: nil, { name: "exec_device_interrupts_total", description: "Device interrupts since system boot. Resets at architecture unsigned integer.", From 34467b1d7a40c4cfc9493ca2af778ffba49340fe Mon Sep 17 00:00:00 2001 From: tyltr Date: Mon, 29 Jan 2024 20:09:38 +0800 Subject: [PATCH 03/48] chore:remove constant from function (#2884) Signed-off-by: tyltr --- collector/timex.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/collector/timex.go b/collector/timex.go index c444d3ea14..69cbc1a1d0 100644 --- a/collector/timex.go +++ b/collector/timex.go @@ -38,6 +38,9 @@ const ( // 1 second in nanoSeconds = 1000000000 microSeconds = 1000000 + + // See NOTES in adjtimex(2). + ppm16frac = 1000000.0 * 65536.0 ) type timexCollector struct { @@ -183,8 +186,6 @@ func (c *timexCollector) Update(ch chan<- prometheus.Metric) error { } else { divisor = microSeconds } - // See NOTES in adjtimex(2). - const ppm16frac = 1000000.0 * 65536.0 ch <- c.syncStatus.mustNewConstMetric(syncStatus) ch <- c.offset.mustNewConstMetric(float64(timex.Offset) / divisor) From 1ae329e39364bff9686017058ab9a4752e617211 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 17:59:31 +0100 Subject: [PATCH 04/48] build(deps): bump github.com/prometheus/common from 0.45.0 to 0.46.0 (#2910) Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.45.0 to 0.46.0. - [Release notes](https://github.com/prometheus/common/releases) - [Commits](https://github.com/prometheus/common/compare/v0.45.0...v0.46.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 13 ++++++------- go.sum | 26 ++++++++++++-------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 26619861ec..019149eb6b 100644 --- a/go.mod +++ b/go.mod @@ -24,12 +24,12 @@ require ( github.com/prometheus-community/go-runit v0.1.0 github.com/prometheus/client_golang v1.18.0 github.com/prometheus/client_model v0.5.0 - github.com/prometheus/common v0.45.0 + github.com/prometheus/common v0.46.0 github.com/prometheus/exporter-toolkit v0.11.0 github.com/prometheus/procfs v0.12.0 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 - golang.org/x/sys v0.15.0 + golang.org/x/sys v0.16.0 howett.net/plist v1.0.1 ) @@ -43,7 +43,6 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/mdlayher/genetlink v1.3.2 // indirect github.com/mdlayher/socket v0.4.1 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect @@ -51,12 +50,12 @@ require ( github.com/xhit/go-str2duration/v2 v2.1.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/net v0.19.0 // indirect - golang.org/x/oauth2 v0.12.0 // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 6f6293f623..1a584ea0bc 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,6 @@ github.com/lufia/iostat v1.2.1 h1:tnCdZBIglgxD47RyD55kfWQcJMGzO+1QBziSQfesf2k= github.com/lufia/iostat v1.2.1/go.mod h1:rEPNA0xXgjHQjuI5Cy05sLlS2oRcSlWHRLrvh/AQ+Pg= github.com/mattn/go-xmlrpc v0.0.3 h1:Y6WEMLEsqs3RviBrAa1/7qmbGB7DVD3brZIbqMbQdGY= github.com/mattn/go-xmlrpc v0.0.3/go.mod h1:mqc2dz7tP5x5BKlCahN/n+hs7OSZKJkS9JsHNBRlrxA= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/mdlayher/ethtool v0.1.0 h1:XAWHsmKhyPOo42qq/yTPb0eFBGUKKTR1rE0dVrWVQ0Y= github.com/mdlayher/ethtool v0.1.0/go.mod h1:fBMLn2UhfRGtcH5ZFjr+6GUiHEjZsItFD7fSn7jbZVQ= github.com/mdlayher/genetlink v1.3.2 h1:KdrNKe+CTu+IbZnm/GVUMXSqBBLqcGpRDa0xkQy56gw= @@ -77,8 +75,8 @@ github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+ github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= -github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= +github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= @@ -99,22 +97,22 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= -golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4= -golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= +golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= @@ -125,8 +123,8 @@ google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6 google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= From 14949db87feaa716af3aea4775262302f99d74c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:03:01 +0100 Subject: [PATCH 05/48] build(deps): bump github.com/jsimonetti/rtnetlink from 1.4.0 to 1.4.1 (#2909) Bumps [github.com/jsimonetti/rtnetlink](https://github.com/jsimonetti/rtnetlink) from 1.4.0 to 1.4.1. - [Release notes](https://github.com/jsimonetti/rtnetlink/releases) - [Commits](https://github.com/jsimonetti/rtnetlink/compare/v1.4.0...v1.4.1) --- updated-dependencies: - dependency-name: github.com/jsimonetti/rtnetlink dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 019149eb6b..7de9d10c1d 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/hodgesds/perf-utils v0.7.0 github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 github.com/josharian/native v1.1.0 - github.com/jsimonetti/rtnetlink v1.4.0 + github.com/jsimonetti/rtnetlink v1.4.1 github.com/lufia/iostat v1.2.1 github.com/mattn/go-xmlrpc v0.0.3 github.com/mdlayher/ethtool v0.1.0 diff --git a/go.sum b/go.sum index 1a584ea0bc..111cecd41c 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,8 @@ github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtL github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/jsimonetti/rtnetlink v1.4.0 h1:Z1BF0fRgcETPEa0Kt0MRk3yV5+kF1FWTni6KUFKrq2I= -github.com/jsimonetti/rtnetlink v1.4.0/go.mod h1:5W1jDvWdnthFJ7fxYX1GMK07BUpI4oskfOqvPteYS6E= +github.com/jsimonetti/rtnetlink v1.4.1 h1:JfD4jthWBqZMEffc5RjgmlzpYttAVw1sdnmiNaPO3hE= +github.com/jsimonetti/rtnetlink v1.4.1/go.mod h1:xJjT7t59UIZ62GLZbv6PLLo8VFrostJMPBAheR6OM8w= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/lufia/iostat v1.2.1 h1:tnCdZBIglgxD47RyD55kfWQcJMGzO+1QBziSQfesf2k= From fe78e7e51ae7d01db2849813927a5ad282dfcef3 Mon Sep 17 00:00:00 2001 From: TaoGe <6657718+yowenter@users.noreply.github.com> Date: Sat, 3 Feb 2024 17:13:12 +0800 Subject: [PATCH 06/48] fix hwmon nil ptr (#2873) * fix hwmon nil ptr syslink maybe lost in some cases. --------- Signed-off-by: TaoGe <6657718+yowenter@users.noreply.github.com> --- collector/hwmon_linux.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/collector/hwmon_linux.go b/collector/hwmon_linux.go index 3ad469a61a..476eed7b30 100644 --- a/collector/hwmon_linux.go +++ b/collector/hwmon_linux.go @@ -446,7 +446,10 @@ func (c *hwMonCollector) Update(ch chan<- prometheus.Metric) error { for _, hwDir := range hwmonFiles { hwmonXPathName := filepath.Join(hwmonPathName, hwDir.Name()) - fileInfo, _ := os.Lstat(hwmonXPathName) + fileInfo, err := os.Lstat(hwmonXPathName) + if err != nil { + continue + } if fileInfo.Mode()&os.ModeSymlink > 0 { fileInfo, err = os.Stat(hwmonXPathName) From 29fca60a451830891581c6a5be447e655c9dc43f Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Wed, 7 Feb 2024 15:06:24 +0100 Subject: [PATCH 07/48] Fix hwmon error capture (#2915) Fix golangci-lint "ineffectual assignment" by correctly capturing any errors within the hwmon gathering loop. Signed-off-by: Ben Kochie --- collector/hwmon_linux.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/collector/hwmon_linux.go b/collector/hwmon_linux.go index 476eed7b30..a8086d309e 100644 --- a/collector/hwmon_linux.go +++ b/collector/hwmon_linux.go @@ -444,6 +444,7 @@ func (c *hwMonCollector) Update(ch chan<- prometheus.Metric) error { return err } + var lastErr error for _, hwDir := range hwmonFiles { hwmonXPathName := filepath.Join(hwmonPathName, hwDir.Name()) fileInfo, err := os.Lstat(hwmonXPathName) @@ -462,10 +463,10 @@ func (c *hwMonCollector) Update(ch chan<- prometheus.Metric) error { continue } - if lastErr := c.updateHwmon(ch, hwmonXPathName); lastErr != nil { - err = lastErr + if err = c.updateHwmon(ch, hwmonXPathName); err != nil { + lastErr = err } } - return err + return lastErr } From d54744a555197fa1875b85658d5e8c033b72e03b Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Wed, 7 Feb 2024 22:57:18 +0100 Subject: [PATCH 08/48] Update common Prometheus files (#2917) Signed-off-by: prombot --- Makefile.common | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index bc2a07d728..5fd1782371 100644 --- a/Makefile.common +++ b/Makefile.common @@ -62,10 +62,10 @@ SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= GOLANGCI_LINT_VERSION ?= v1.55.2 -# golangci-lint only supports linux, darwin and windows platforms on i386/amd64. +# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) - ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) + ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386 arm64)) # If we're in CI and there is an Actions file, that means the linter # is being run in Actions, so we don't need to run it here. ifneq (,$(SKIP_GOLANGCI_LINT)) From 6d18ce7bcae7102ebb13049915c7e31789f8382d Mon Sep 17 00:00:00 2001 From: Caleb Webber Date: Wed, 14 Feb 2024 03:13:18 -0500 Subject: [PATCH 09/48] Revert "Add ZFS freebsd per dataset stats (#2753)" (#2925) This reverts commit f34aaa61092fe7e3c6618fdb0b0d16a68a291ff7. Signed-off-by: Caleb Webber --- collector/exec_bsd.go | 6 ---- collector/memory_bsd.go | 12 ------- collector/netisr_freebsd.go | 6 ---- collector/sysctl_bsd.go | 3 -- collector/zfs_freebsd.go | 72 ------------------------------------- collector/zfs_linux.go | 4 +-- collector/zfs_linux_test.go | 2 +- 7 files changed, 3 insertions(+), 102 deletions(-) diff --git a/collector/exec_bsd.go b/collector/exec_bsd.go index 9c123991f0..87cb3ceeb4 100644 --- a/collector/exec_bsd.go +++ b/collector/exec_bsd.go @@ -49,37 +49,31 @@ func NewExecCollector(logger log.Logger) (Collector, error) { name: "exec_context_switches_total", description: "Context switches since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_swtch", - labels: nil, }, { name: "exec_traps_total", description: "Traps since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_trap", - labels: nil, }, { name: "exec_system_calls_total", description: "System calls since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_syscall", - labels: nil, }, { name: "exec_device_interrupts_total", description: "Device interrupts since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_intr", - labels: nil, }, { name: "exec_software_interrupts_total", description: "Software interrupts since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_soft", - labels: nil, }, { name: "exec_forks_total", description: "Number of fork() calls since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.vm.v_forks", - labels: nil, }, }, logger: logger, diff --git a/collector/memory_bsd.go b/collector/memory_bsd.go index 6f16ac896d..6af9d8aaa4 100644 --- a/collector/memory_bsd.go +++ b/collector/memory_bsd.go @@ -69,21 +69,18 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { description: "Recently used by userland", mib: "vm.stats.vm.v_active_count", conversion: fromPage, - labels: nil, }, { name: "inactive_bytes", description: "Not recently used by userland", mib: "vm.stats.vm.v_inactive_count", conversion: fromPage, - labels: nil, }, { name: "wired_bytes", description: "Locked in memory by kernel, mlock, etc", mib: "vm.stats.vm.v_wire_count", conversion: fromPage, - labels: nil, }, { name: "user_wired_bytes", @@ -91,49 +88,42 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_user_wire_count", conversion: fromPage, dataType: bsdSysctlTypeCLong, - labels: nil, }, { name: "cache_bytes", description: "Almost free, backed by swap or files, available for re-allocation", mib: "vm.stats.vm.v_cache_count", conversion: fromPage, - labels: nil, }, { name: "buffer_bytes", description: "Disk IO Cache entries for non ZFS filesystems, only usable by kernel", mib: "vfs.bufspace", dataType: bsdSysctlTypeCLong, - labels: nil, }, { name: "free_bytes", description: "Unallocated, available for allocation", mib: "vm.stats.vm.v_free_count", conversion: fromPage, - labels: nil, }, { name: "laundry_bytes", description: "Dirty not recently used by userland", mib: "vm.stats.vm.v_laundry_count", conversion: fromPage, - labels: nil, }, { name: "size_bytes", description: "Total physical memory size", mib: "vm.stats.vm.v_page_count", conversion: fromPage, - labels: nil, }, { name: "swap_size_bytes", description: "Total swap memory size", mib: mibSwapTotal, dataType: bsdSysctlTypeUint64, - labels: nil, }, // Descriptions via: top(1) { @@ -142,7 +132,6 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_swappgsin", valueType: prometheus.CounterValue, conversion: fromPage, - labels: nil, }, { name: "swap_out_bytes_total", @@ -150,7 +139,6 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_swappgsout", valueType: prometheus.CounterValue, conversion: fromPage, - labels: nil, }, }, }, nil diff --git a/collector/netisr_freebsd.go b/collector/netisr_freebsd.go index 43991f3ab9..442bcdc6a7 100644 --- a/collector/netisr_freebsd.go +++ b/collector/netisr_freebsd.go @@ -45,7 +45,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.numthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "maxprot", @@ -53,7 +52,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxprot", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "defaultqlimit", @@ -61,7 +59,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.defaultqlimit", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "maxqlimit", @@ -69,7 +66,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxqlimit", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "bindthreads", @@ -77,7 +73,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.bindthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "maxthreads", @@ -85,7 +80,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, }, logger: logger, diff --git a/collector/sysctl_bsd.go b/collector/sysctl_bsd.go index df5c9f93f1..2ab248ed2e 100644 --- a/collector/sysctl_bsd.go +++ b/collector/sysctl_bsd.go @@ -59,9 +59,6 @@ type bsdSysctl struct { // Post-retrieval conversion hooks conversion func(float64) float64 - - // Prometheus labels - labels prometheus.Labels } func (b bsdSysctl) Value() (float64, error) { diff --git a/collector/zfs_freebsd.go b/collector/zfs_freebsd.go index 0e4d969275..bc4aa1c3f7 100644 --- a/collector/zfs_freebsd.go +++ b/collector/zfs_freebsd.go @@ -17,13 +17,9 @@ package collector import ( - "fmt" - "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" - - "golang.org/x/sys/unix" ) type zfsCollector struct { @@ -48,7 +44,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.linear_cnt", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "abdstats_linear_data_bytes", @@ -56,7 +51,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.linear_data_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "abdstats_scatter_chunk_waste_bytes", @@ -64,7 +58,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.scatter_chunk_waste", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "abdstats_scatter_count_total", @@ -72,7 +65,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.scatter_cnt", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "abdstats_scatter_data_bytes", @@ -80,7 +72,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.scatter_data_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "abdstats_struct_bytes", @@ -88,7 +79,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.struct_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_anon_bytes", @@ -96,7 +86,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.anon_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_c_bytes", @@ -104,7 +93,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.c", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_c_max_bytes", @@ -112,7 +100,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.c_max", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_c_min_bytes", @@ -120,7 +107,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.c_min", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_data_bytes", @@ -128,7 +114,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.data_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_demand_data_hits_total", @@ -136,7 +121,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.demand_data_hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "arcstats_demand_data_misses_total", @@ -144,7 +128,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.demand_data_misses", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "arcstats_demand_metadata_hits_total", @@ -152,7 +135,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.demand_metadata_hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "arcstats_demand_metadata_misses_total", @@ -160,7 +142,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.demand_metadata_misses", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "arcstats_hdr_bytes", @@ -168,7 +149,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.hdr_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_hits_total", @@ -176,7 +156,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "arcstats_misses_total", @@ -184,7 +163,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.misses", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "arcstats_mfu_ghost_hits_total", @@ -192,7 +170,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mfu_ghost_hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "arcstats_mfu_ghost_size", @@ -200,7 +177,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mfu_ghost_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_mfu_bytes", @@ -208,7 +184,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mfu_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_mru_ghost_hits_total", @@ -216,7 +191,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mru_ghost_hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "arcstats_mru_ghost_bytes", @@ -224,7 +198,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mru_ghost_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_mru_bytes", @@ -232,7 +205,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mru_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_other_bytes", @@ -240,7 +212,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.other_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, // when FreeBSD 14.0+, `meta/pm/pd` install of `p`. { @@ -249,7 +220,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.p", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "arcstats_meta_bytes", @@ -278,7 +248,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "zfetchstats_hits_total", @@ -286,7 +255,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.zfetchstats.hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, { name: "zfetchstats_misses_total", @@ -294,7 +262,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.zfetchstats.misses", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, - labels: nil, }, }, logger: logger, @@ -320,42 +287,3 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error { return nil } - -func (c *zfsCollector) parseFreeBSDPoolObjsetStats() error { - - sysCtlMetrics := []string{ - "nunlinked", "nunlinks", "nread", "reads", "nwritten", "writes", - } - zfsPoolMibPrefix := "kstat.zfs.pool.dataset" - zfsDatasetNames := []string{} - - zfsDatasets, err := unix.Sysctl(zfsPoolMibPrefix) - if err != nil { - return fmt.Errorf("couldn't get sysctl: %w", err) - } - - for dataset, _ := range zfsDatasets { - if strings.HasSuffix(dataset, ".dataset_name") { - zfsDatasetNames = append(zfsDatasetNames, strings.SplitAfter(dataset, ".")[3]) - } - } - - for zpoolDataset := range zfsDatasetsNames { - zfsDatasetLabels := map[string]string{ - "dataset": zpoolDataset, - "zpool": strings.SplitAfter(zpoolDataset, "/")[0], - } - for metric := range sysCtlMetrics { - c.sysctls = append(c.sysctls, bsdSysctl{ - name: fmt.SprintF("node_zfs_zpool_dataset_%s", metric), - description: fmt.SprintF("node_zfs_zpool_dataset_%s", metric), - mib: fmt.Sprintf("%s.%s.%s", zfsPoolMibPrefix, poolObj, metric), - dataType: bsdSysctlTypeUint64, - valueType: prometheus.CounterValue, - labels: zfsDatasetLabels, - }) - } - } - - return nil -} diff --git a/collector/zfs_linux.go b/collector/zfs_linux.go index e7be4a9836..ec195b3d62 100644 --- a/collector/zfs_linux.go +++ b/collector/zfs_linux.go @@ -104,7 +104,7 @@ func (c *zfsCollector) updatePoolStats(ch chan<- prometheus.Metric) error { return errZFSNotAvailable } - err = c.parseLinuxPoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { + err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { ch <- c.constPoolObjsetMetric(poolName, datasetName, s, v) }) file.Close() @@ -220,7 +220,7 @@ func (c *zfsCollector) parsePoolProcfsFile(reader io.Reader, zpoolPath string, h return scanner.Err() } -func (c *zfsCollector) parseLinuxPoolObjsetFile(reader io.Reader, zpoolPath string, handler func(string, string, zfsSysctl, uint64)) error { +func (c *zfsCollector) parsePoolObjsetFile(reader io.Reader, zpoolPath string, handler func(string, string, zfsSysctl, uint64)) error { scanner := bufio.NewScanner(reader) parseLine := false diff --git a/collector/zfs_linux_test.go b/collector/zfs_linux_test.go index f6ce8d9487..69e4ed8fc1 100644 --- a/collector/zfs_linux_test.go +++ b/collector/zfs_linux_test.go @@ -332,7 +332,7 @@ func TestZpoolObjsetParsing(t *testing.T) { t.Fatal(err) } - err = c.parseLinuxPoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { + err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { if s != zfsSysctl("kstat.zfs.misc.objset.writes") { return } From 9f1f791ac2e1377781c4f8807a23d86d92ad6499 Mon Sep 17 00:00:00 2001 From: DongWei Date: Wed, 14 Feb 2024 22:36:16 +0800 Subject: [PATCH 10/48] filesystem: fix mountTimeout not working issue (#2903) Signed-off-by: DongWei --- collector/filesystem_linux.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index 6e7623e203..2251cc4b8f 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -122,16 +122,8 @@ func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemSta buf := new(unix.Statfs_t) err := unix.Statfs(rootfsFilePath(labels.mountPoint), buf) - stuckMountsMtx.Lock() close(success) - // If the mount has been marked as stuck, unmark it and log it's recovery. - if _, ok := stuckMounts[labels.mountPoint]; ok { - level.Debug(c.logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", labels.mountPoint) - delete(stuckMounts, labels.mountPoint) - } - stuckMountsMtx.Unlock() - if err != nil { level.Debug(c.logger).Log("msg", "Error on statfs() system call", "rootfs", rootfsFilePath(labels.mountPoint), "err", err) return filesystemStats{ @@ -161,17 +153,29 @@ func stuckMountWatcher(mountPoint string, success chan struct{}, logger log.Logg select { case <-success: // Success + // If the mount has been marked as stuck, unmark it and log it's recovery. + stuckMountsMtx.Lock() + defer stuckMountsMtx.Unlock() + if _, ok := stuckMounts[mountPoint]; ok { + level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint) + delete(stuckMounts, mountPoint) + } case <-mountCheckTimer.C: // Timed out, mark mount as stuck stuckMountsMtx.Lock() + defer stuckMountsMtx.Unlock() select { case <-success: // Success came in just after the timeout was reached, don't label the mount as stuck + // If the mount has been marked as stuck, unmark it and log it's recovery. + if _, ok := stuckMounts[mountPoint]; ok { + level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint) + delete(stuckMounts, mountPoint) + } default: level.Debug(logger).Log("msg", "Mount point timed out, it is being labeled as stuck and will not be monitored", "mountpoint", mountPoint) stuckMounts[mountPoint] = struct{}{} } - stuckMountsMtx.Unlock() } } From 9f9473859bd04fd22a2f3a29cf44c9894b3b5e76 Mon Sep 17 00:00:00 2001 From: Taylor Sly Date: Fri, 16 Feb 2024 02:58:22 -0500 Subject: [PATCH 11/48] Fix description for NodeDiskIOSaturation alert (#2929) NodeDiskIOSaturation description should say 30m per the "for" clause Signed-off-by: Taylor Sly --- docs/node-mixin/alerts/alerts.libsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/node-mixin/alerts/alerts.libsonnet b/docs/node-mixin/alerts/alerts.libsonnet index 34d5314cc0..c346480906 100644 --- a/docs/node-mixin/alerts/alerts.libsonnet +++ b/docs/node-mixin/alerts/alerts.libsonnet @@ -388,7 +388,7 @@ annotations: { summary: 'Disk IO queue is high.', description: ||| - Disk IO queue (aqu-sq) is high on {{ $labels.device }} at {{ $labels.instance }}, has been above %(diskIOSaturationThreshold)d for the last 15 minutes, is currently at {{ printf "%%.2f" $value }}. + Disk IO queue (aqu-sq) is high on {{ $labels.device }} at {{ $labels.instance }}, has been above %(diskIOSaturationThreshold)d for the last 30 minutes, is currently at {{ printf "%%.2f" $value }}. This symptom might indicate disk saturation. ||| % $._config, }, From 09014c0c5ca7d24bbad09e821efe6c676702f12f Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Fri, 16 Feb 2024 09:41:06 +0100 Subject: [PATCH 12/48] Enforce no subprocess policy (#2926) Add depguard to golangci-lint to enforce the no-os/exec policy. Signed-off-by: Ben Kochie --- .golangci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 3f7e4589cb..472b3a5e13 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,6 @@ linters: enable: + - depguard - misspell - revive disable: @@ -19,6 +20,14 @@ issues: - errcheck linters-settings: + depguard: + rules: + no_exec_policy: + files: + - "!$test" + deny: + - pkg: "os/exec" + desc: "Using os/exec to run sub processes it not allowed by policy" errcheck: exclude-functions: # Used in HTTP handlers, any error is handled by the server itself. From 12192475c8e88b6147fbbca5b0a883a01f691d8b Mon Sep 17 00:00:00 2001 From: Pamela Mei <126221706+PamelaMei-SAP@users.noreply.github.com> Date: Sun, 18 Feb 2024 19:04:30 +0800 Subject: [PATCH 13/48] filesystem: surface device errors (#2923) filesystem: surface filesystem device error Fixes: #2918 --------- Signed-off-by: Pamela Mei i540369 --- collector/filesystem_common.go | 18 +++++++++--------- collector/filesystem_linux.go | 11 +++++++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/collector/filesystem_common.go b/collector/filesystem_common.go index f5dde59ab7..f5d5135241 100644 --- a/collector/filesystem_common.go +++ b/collector/filesystem_common.go @@ -60,7 +60,7 @@ var ( "Regexp of filesystem types to ignore for filesystem collector.", ).Hidden().String() - filesystemLabelNames = []string{"device", "mountpoint", "fstype"} + filesystemLabelNames = []string{"device", "mountpoint", "fstype", "device_error"} ) type filesystemCollector struct { @@ -73,7 +73,7 @@ type filesystemCollector struct { } type filesystemLabels struct { - device, mountPoint, fsType, options string + device, mountPoint, fsType, options, deviceError string } type filesystemStats struct { @@ -184,11 +184,11 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) error { ch <- prometheus.MustNewConstMetric( c.deviceErrorDesc, prometheus.GaugeValue, - s.deviceError, s.labels.device, s.labels.mountPoint, s.labels.fsType, + s.deviceError, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError, ) ch <- prometheus.MustNewConstMetric( c.roDesc, prometheus.GaugeValue, - s.ro, s.labels.device, s.labels.mountPoint, s.labels.fsType, + s.ro, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError, ) if s.deviceError > 0 { @@ -197,23 +197,23 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) error { ch <- prometheus.MustNewConstMetric( c.sizeDesc, prometheus.GaugeValue, - s.size, s.labels.device, s.labels.mountPoint, s.labels.fsType, + s.size, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError, ) ch <- prometheus.MustNewConstMetric( c.freeDesc, prometheus.GaugeValue, - s.free, s.labels.device, s.labels.mountPoint, s.labels.fsType, + s.free, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError, ) ch <- prometheus.MustNewConstMetric( c.availDesc, prometheus.GaugeValue, - s.avail, s.labels.device, s.labels.mountPoint, s.labels.fsType, + s.avail, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError, ) ch <- prometheus.MustNewConstMetric( c.filesDesc, prometheus.GaugeValue, - s.files, s.labels.device, s.labels.mountPoint, s.labels.fsType, + s.files, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError, ) ch <- prometheus.MustNewConstMetric( c.filesFreeDesc, prometheus.GaugeValue, - s.filesFree, s.labels.device, s.labels.mountPoint, s.labels.fsType, + s.filesFree, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError, ) } return nil diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index 2251cc4b8f..23e5359d11 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -85,6 +85,7 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) { stuckMountsMtx.Lock() if _, ok := stuckMounts[labels.mountPoint]; ok { + labels.deviceError = "mountpoint timeout" stats = append(stats, filesystemStats{ labels: labels, deviceError: 1, @@ -125,6 +126,7 @@ func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemSta close(success) if err != nil { + labels.deviceError = err.Error() level.Debug(c.logger).Log("msg", "Error on statfs() system call", "rootfs", rootfsFilePath(labels.mountPoint), "err", err) return filesystemStats{ labels: labels, @@ -211,10 +213,11 @@ func parseFilesystemLabels(r io.Reader) ([]filesystemLabels, error) { parts[1] = strings.Replace(parts[1], "\\011", "\t", -1) filesystems = append(filesystems, filesystemLabels{ - device: parts[0], - mountPoint: rootfsStripPrefix(parts[1]), - fsType: parts[2], - options: parts[3], + device: parts[0], + mountPoint: rootfsStripPrefix(parts[1]), + fsType: parts[2], + options: parts[3], + deviceError: "", }) } From 3a02ab1cf051d2f80f3b688c977961033300fda3 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Tue, 20 Feb 2024 10:31:08 +0100 Subject: [PATCH 14/48] Revert "filesystem: fix mountTimeout not working issue (#2903)" (#2932) This reverts commit 9f1f791ac2e1377781c4f8807a23d86d92ad6499. Signed-off-by: Ben Kochie --- collector/filesystem_linux.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index 23e5359d11..1d0c8493b9 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -123,8 +123,16 @@ func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemSta buf := new(unix.Statfs_t) err := unix.Statfs(rootfsFilePath(labels.mountPoint), buf) + stuckMountsMtx.Lock() close(success) + // If the mount has been marked as stuck, unmark it and log it's recovery. + if _, ok := stuckMounts[labels.mountPoint]; ok { + level.Debug(c.logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", labels.mountPoint) + delete(stuckMounts, labels.mountPoint) + } + stuckMountsMtx.Unlock() + if err != nil { labels.deviceError = err.Error() level.Debug(c.logger).Log("msg", "Error on statfs() system call", "rootfs", rootfsFilePath(labels.mountPoint), "err", err) @@ -155,29 +163,17 @@ func stuckMountWatcher(mountPoint string, success chan struct{}, logger log.Logg select { case <-success: // Success - // If the mount has been marked as stuck, unmark it and log it's recovery. - stuckMountsMtx.Lock() - defer stuckMountsMtx.Unlock() - if _, ok := stuckMounts[mountPoint]; ok { - level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint) - delete(stuckMounts, mountPoint) - } case <-mountCheckTimer.C: // Timed out, mark mount as stuck stuckMountsMtx.Lock() - defer stuckMountsMtx.Unlock() select { case <-success: // Success came in just after the timeout was reached, don't label the mount as stuck - // If the mount has been marked as stuck, unmark it and log it's recovery. - if _, ok := stuckMounts[mountPoint]; ok { - level.Debug(logger).Log("msg", "Mount point has recovered, monitoring will resume", "mountpoint", mountPoint) - delete(stuckMounts, mountPoint) - } default: level.Debug(logger).Log("msg", "Mount point timed out, it is being labeled as stuck and will not be monitored", "mountpoint", mountPoint) stuckMounts[mountPoint] = struct{}{} } + stuckMountsMtx.Unlock() } } From c371a7f582bf2b9a185fc51bd0d3e842937a8ab2 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Mon, 26 Feb 2024 19:30:39 +0100 Subject: [PATCH 15/48] Update common Prometheus files (#2939) Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 8f25279111..0e8515722f 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -28,7 +28,7 @@ jobs: - name: install Go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: 1.21.x + go-version: 1.22.x - name: Install snmp_exporter/generator dependencies run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' From 3866d2a8296fd6de5d48f51242e61d02341bb169 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Mon, 4 Mar 2024 18:55:14 +0100 Subject: [PATCH 16/48] Update common Prometheus files (#2946) Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 0e8515722f..4dc7b830f6 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -33,6 +33,6 @@ jobs: run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' - name: Lint - uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 + uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 with: version: v1.55.2 From cdb1e4c7e2671e98042a5fccff498030e87568eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:57:44 +0100 Subject: [PATCH 17/48] build(deps): bump golang.org/x/sys from 0.16.0 to 0.17.0 (#2943) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.16.0 to 0.17.0. - [Commits](https://github.com/golang/sys/compare/v0.16.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7de9d10c1d..d47be68b81 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/prometheus/procfs v0.12.0 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 - golang.org/x/sys v0.16.0 + golang.org/x/sys v0.17.0 howett.net/plist v1.0.1 ) diff --git a/go.sum b/go.sum index 111cecd41c..5dca6f365d 100644 --- a/go.sum +++ b/go.sum @@ -111,8 +111,8 @@ golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= From 762f15ea971b7b121e784a065ae2543ff1ca4f4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:57:55 +0100 Subject: [PATCH 18/48] build(deps): bump github.com/prometheus/client_golang (#2942) Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.18.0 to 1.19.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/v1.19.0/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.18.0...v1.19.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index d47be68b81..6a403bce86 100644 --- a/go.mod +++ b/go.mod @@ -22,9 +22,9 @@ require ( github.com/mdlayher/wifi v0.1.0 github.com/opencontainers/selinux v1.11.0 github.com/prometheus-community/go-runit v0.1.0 - github.com/prometheus/client_golang v1.18.0 + github.com/prometheus/client_golang v1.19.0 github.com/prometheus/client_model v0.5.0 - github.com/prometheus/common v0.46.0 + github.com/prometheus/common v0.48.0 github.com/prometheus/exporter-toolkit v0.11.0 github.com/prometheus/procfs v0.12.0 github.com/safchain/ethtool v0.3.0 diff --git a/go.sum b/go.sum index 5dca6f365d..ededd93b3f 100644 --- a/go.sum +++ b/go.sum @@ -71,12 +71,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus-community/go-runit v0.1.0 h1:uTWEj/Fn2RoLdfg/etSqwzgYNOYPrARx1BHUN052tGA= github.com/prometheus-community/go-runit v0.1.0/go.mod h1:AvJ9Jo3gAFu2lbM4+qfjdpq30FfiLDJZKbQ015u08IQ= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= -github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= +github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= +github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= From d502a147c363f8a5410a447c6fe6aa5cb8252b1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:06:12 +0100 Subject: [PATCH 19/48] build(deps): bump github.com/prometheus/client_model from 0.5.0 to 0.6.0 (#2944) Bumps [github.com/prometheus/client_model](https://github.com/prometheus/client_model) from 0.5.0 to 0.6.0. - [Release notes](https://github.com/prometheus/client_model/releases) - [Commits](https://github.com/prometheus/client_model/compare/v0.5.0...v0.6.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_model dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6a403bce86..398f34adf9 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/opencontainers/selinux v1.11.0 github.com/prometheus-community/go-runit v0.1.0 github.com/prometheus/client_golang v1.19.0 - github.com/prometheus/client_model v0.5.0 + github.com/prometheus/client_model v0.6.0 github.com/prometheus/common v0.48.0 github.com/prometheus/exporter-toolkit v0.11.0 github.com/prometheus/procfs v0.12.0 diff --git a/go.sum b/go.sum index ededd93b3f..1a2a15df6f 100644 --- a/go.sum +++ b/go.sum @@ -73,8 +73,8 @@ github.com/prometheus-community/go-runit v0.1.0 h1:uTWEj/Fn2RoLdfg/etSqwzgYNOYPr github.com/prometheus-community/go-runit v0.1.0/go.mod h1:AvJ9Jo3gAFu2lbM4+qfjdpq30FfiLDJZKbQ015u08IQ= github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= -github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= -github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= +github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= From 4ec07ee08c5a94ace9164b08dbcc80ee3bfc1b8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:16:50 +0100 Subject: [PATCH 20/48] build(deps): bump golang.org/x/sys from 0.17.0 to 0.18.0 (#2948) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.17.0 to 0.18.0. - [Commits](https://github.com/golang/sys/compare/v0.17.0...v0.18.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 398f34adf9..0a6a104711 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/prometheus/procfs v0.12.0 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 - golang.org/x/sys v0.17.0 + golang.org/x/sys v0.18.0 howett.net/plist v1.0.1 ) diff --git a/go.sum b/go.sum index 1a2a15df6f..d96c0b9e8b 100644 --- a/go.sum +++ b/go.sum @@ -111,8 +111,8 @@ golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= From 90c7f0f27942ebcef0edb1777c85f4d2e5e4eaf7 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Fri, 8 Mar 2024 09:49:22 +0100 Subject: [PATCH 21/48] Update common Prometheus files (#2949) Signed-off-by: prombot --- Makefile.common | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile.common b/Makefile.common index 5fd1782371..92558151e3 100644 --- a/Makefile.common +++ b/Makefile.common @@ -169,12 +169,16 @@ common-vet: common-lint: $(GOLANGCI_LINT) ifdef GOLANGCI_LINT @echo ">> running golangci-lint" -# 'go list' needs to be executed before staticcheck to prepopulate the modules cache. -# Otherwise staticcheck might fail randomly for some reason not yet explained. - $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs) endif +.PHONY: common-lint-fix +common-lint-fix: $(GOLANGCI_LINT) +ifdef GOLANGCI_LINT + @echo ">> running golangci-lint fix" + $(GOLANGCI_LINT) run --fix $(GOLANGCI_LINT_OPTS) $(pkgs) +endif + .PHONY: common-yamllint common-yamllint: @echo ">> running yamllint on all YAML files in the repository" From 8dbeac961ea3ab5491ac9266ccab777a4a98876d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 10:01:54 +0100 Subject: [PATCH 22/48] build(deps): bump github.com/prometheus/procfs from 0.12.0 to 0.13.0 (#2952) Bumps [github.com/prometheus/procfs](https://github.com/prometheus/procfs) from 0.12.0 to 0.13.0. - [Release notes](https://github.com/prometheus/procfs/releases) - [Commits](https://github.com/prometheus/procfs/compare/v0.12.0...v0.13.0) --- updated-dependencies: - dependency-name: github.com/prometheus/procfs dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 0a6a104711..098d25fbf6 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/prometheus/client_model v0.6.0 github.com/prometheus/common v0.48.0 github.com/prometheus/exporter-toolkit v0.11.0 - github.com/prometheus/procfs v0.12.0 + github.com/prometheus/procfs v0.13.0 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 golang.org/x/sys v0.18.0 @@ -53,7 +53,7 @@ require ( golang.org/x/crypto v0.18.0 // indirect golang.org/x/net v0.20.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/sync v0.6.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.32.0 // indirect diff --git a/go.sum b/go.sum index d96c0b9e8b..3439fcded6 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSz github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= +github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0= github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs= @@ -106,8 +106,8 @@ golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From cc491333212472ba78ad421a3a2958846cfcb2ef Mon Sep 17 00:00:00 2001 From: Adrian Berger <43774417+adberger@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:41:36 +0100 Subject: [PATCH 23/48] Add multi-cluster support for Nodes dashboard (#2945) Signed-off-by: Adrian Berger --- docs/node-mixin/lib/prom-mixin.libsonnet | 95 ++++++++++++++---------- 1 file changed, 56 insertions(+), 39 deletions(-) diff --git a/docs/node-mixin/lib/prom-mixin.libsonnet b/docs/node-mixin/lib/prom-mixin.libsonnet index 6c4d990481..5d2e7bd0ce 100644 --- a/docs/node-mixin/lib/prom-mixin.libsonnet +++ b/docs/node-mixin/lib/prom-mixin.libsonnet @@ -27,6 +27,23 @@ local table = grafana70.panel.table; type: 'datasource', }, + local clusterTemplatePrototype = + template.new( + 'cluster', + '$datasource', + '', + hide=if config.showMultiCluster then '' else '2', + refresh='time', + label='Cluster', + ), + local clusterTemplate = + if platform == 'Darwin' then + clusterTemplatePrototype + { query: 'label_values(node_uname_info{%(nodeExporterSelector)s, sysname="Darwin"}, %(clusterLabel)s)' % config } + else + clusterTemplatePrototype + { query: 'label_values(node_uname_info{%(nodeExporterSelector)s, sysname!="Darwin"}, %(clusterLabel)s)' % config }, + local instanceTemplatePrototype = template.new( 'instance', @@ -38,11 +55,10 @@ local table = grafana70.panel.table; local instanceTemplate = if platform == 'Darwin' then instanceTemplatePrototype - { query: 'label_values(node_uname_info{%(nodeExporterSelector)s, sysname="Darwin"}, instance)' % config } + { query: 'label_values(node_uname_info{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster", sysname="Darwin"}, instance)' % config } else instanceTemplatePrototype - { query: 'label_values(node_uname_info{%(nodeExporterSelector)s, sysname!="Darwin"}, instance)' % config }, - + { query: 'label_values(node_uname_info{%(nodeExporterSelector)s, %(clusterLabel)s="$cluster", sysname!="Darwin"}, instance)' % config }, local idleCPU = graphPanel.new( @@ -57,9 +73,9 @@ local table = grafana70.panel.table; .addTarget(prometheus.target( ||| ( - (1 - sum without (mode) (rate(node_cpu_seconds_total{%(nodeExporterSelector)s, mode=~"idle|iowait|steal", instance="$instance"}[$__rate_interval]))) + (1 - sum without (mode) (rate(node_cpu_seconds_total{%(nodeExporterSelector)s, mode=~"idle|iowait|steal", instance="$instance", %(clusterLabel)s="$cluster"}[$__rate_interval]))) / ignoring(cpu) group_left - count without (cpu, mode) (node_cpu_seconds_total{%(nodeExporterSelector)s, mode="idle", instance="$instance"}) + count without (cpu, mode) (node_cpu_seconds_total{%(nodeExporterSelector)s, mode="idle", instance="$instance", %(clusterLabel)s="$cluster"}) ) ||| % config, legendFormat='{{cpu}}', @@ -75,10 +91,10 @@ local table = grafana70.panel.table; min=0, fill=0, ) - .addTarget(prometheus.target('node_load1{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='1m load average')) - .addTarget(prometheus.target('node_load5{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='5m load average')) - .addTarget(prometheus.target('node_load15{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='15m load average')) - .addTarget(prometheus.target('count(node_cpu_seconds_total{%(nodeExporterSelector)s, instance="$instance", mode="idle"})' % config, legendFormat='logical cores')), + .addTarget(prometheus.target('node_load1{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='1m load average')) + .addTarget(prometheus.target('node_load5{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='5m load average')) + .addTarget(prometheus.target('node_load15{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='15m load average')) + .addTarget(prometheus.target('count(node_cpu_seconds_total{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", mode="idle"})' % config, legendFormat='logical cores')), local memoryGraphPanelPrototype = graphPanel.new( @@ -94,44 +110,44 @@ local table = grafana70.panel.table; .addTarget(prometheus.target( ||| ( - node_memory_MemTotal_bytes{%(nodeExporterSelector)s, instance="$instance"} + node_memory_MemTotal_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} - - node_memory_MemFree_bytes{%(nodeExporterSelector)s, instance="$instance"} + node_memory_MemFree_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} - - node_memory_Buffers_bytes{%(nodeExporterSelector)s, instance="$instance"} + node_memory_Buffers_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} - - node_memory_Cached_bytes{%(nodeExporterSelector)s, instance="$instance"} + node_memory_Cached_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} ) ||| % config, legendFormat='memory used' )) - .addTarget(prometheus.target('node_memory_Buffers_bytes{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='memory buffers')) - .addTarget(prometheus.target('node_memory_Cached_bytes{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='memory cached')) - .addTarget(prometheus.target('node_memory_MemFree_bytes{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='memory free')) + .addTarget(prometheus.target('node_memory_Buffers_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='memory buffers')) + .addTarget(prometheus.target('node_memory_Cached_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='memory cached')) + .addTarget(prometheus.target('node_memory_MemFree_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='memory free')) else if platform == 'Darwin' then // not useful to stack memoryGraphPanelPrototype { stack: false } - .addTarget(prometheus.target('node_memory_total_bytes{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='Physical Memory')) + .addTarget(prometheus.target('node_memory_total_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='Physical Memory')) .addTarget(prometheus.target( ||| ( - node_memory_internal_bytes{%(nodeExporterSelector)s, instance="$instance"} - - node_memory_purgeable_bytes{%(nodeExporterSelector)s, instance="$instance"} + - node_memory_wired_bytes{%(nodeExporterSelector)s, instance="$instance"} + - node_memory_compressed_bytes{%(nodeExporterSelector)s, instance="$instance"} + node_memory_internal_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} - + node_memory_purgeable_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} + + node_memory_wired_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} + + node_memory_compressed_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} ) ||| % config, legendFormat='Memory Used' )) .addTarget(prometheus.target( ||| ( - node_memory_internal_bytes{%(nodeExporterSelector)s, instance="$instance"} - - node_memory_purgeable_bytes{%(nodeExporterSelector)s, instance="$instance"} + node_memory_internal_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} - + node_memory_purgeable_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"} ) ||| % config, legendFormat='App Memory' )) - .addTarget(prometheus.target('node_memory_wired_bytes{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='Wired Memory')) - .addTarget(prometheus.target('node_memory_compressed_bytes{%(nodeExporterSelector)s, instance="$instance"}' % config, legendFormat='Compressed')), + .addTarget(prometheus.target('node_memory_wired_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='Wired Memory')) + .addTarget(prometheus.target('node_memory_compressed_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}' % config, legendFormat='Compressed')), // NOTE: avg() is used to circumvent a label change caused by a node_exporter rollout. local memoryGaugePanelPrototype = @@ -155,8 +171,8 @@ local table = grafana70.panel.table; ||| 100 - ( - avg(node_memory_MemAvailable_bytes{%(nodeExporterSelector)s, instance="$instance"}) / - avg(node_memory_MemTotal_bytes{%(nodeExporterSelector)s, instance="$instance"}) + avg(node_memory_MemAvailable_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}) / + avg(node_memory_MemTotal_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}) * 100 ) ||| % config, @@ -168,12 +184,12 @@ local table = grafana70.panel.table; ||| ( ( - avg(node_memory_internal_bytes{%(nodeExporterSelector)s, instance="$instance"}) - - avg(node_memory_purgeable_bytes{%(nodeExporterSelector)s, instance="$instance"}) + - avg(node_memory_wired_bytes{%(nodeExporterSelector)s, instance="$instance"}) + - avg(node_memory_compressed_bytes{%(nodeExporterSelector)s, instance="$instance"}) + avg(node_memory_internal_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}) - + avg(node_memory_purgeable_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}) + + avg(node_memory_wired_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}) + + avg(node_memory_compressed_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}) ) / - avg(node_memory_total_bytes{%(nodeExporterSelector)s, instance="$instance"}) + avg(node_memory_total_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster"}) ) * 100 @@ -190,17 +206,17 @@ local table = grafana70.panel.table; ) // TODO: Does it make sense to have those three in the same panel? .addTarget(prometheus.target( - 'rate(node_disk_read_bytes_total{%(nodeExporterSelector)s, instance="$instance", %(diskDeviceSelector)s}[$__rate_interval])' % config, + 'rate(node_disk_read_bytes_total{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(diskDeviceSelector)s}[$__rate_interval])' % config, legendFormat='{{device}} read', intervalFactor=1, )) .addTarget(prometheus.target( - 'rate(node_disk_written_bytes_total{%(nodeExporterSelector)s, instance="$instance", %(diskDeviceSelector)s}[$__rate_interval])' % config, + 'rate(node_disk_written_bytes_total{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(diskDeviceSelector)s}[$__rate_interval])' % config, legendFormat='{{device}} written', intervalFactor=1, )) .addTarget(prometheus.target( - 'rate(node_disk_io_time_seconds_total{%(nodeExporterSelector)s, instance="$instance", %(diskDeviceSelector)s}[$__rate_interval])' % config, + 'rate(node_disk_io_time_seconds_total{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(diskDeviceSelector)s}[$__rate_interval])' % config, legendFormat='{{device}} io time', intervalFactor=1, )) + @@ -232,7 +248,7 @@ local table = grafana70.panel.table; .addThresholdStep(color='red', value=0.9) .addTarget(prometheus.target( ||| - max by (mountpoint) (node_filesystem_size_bytes{%(nodeExporterSelector)s, instance="$instance", %(fsSelector)s, %(fsMountpointSelector)s}) + max by (mountpoint) (node_filesystem_size_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(fsSelector)s, %(fsMountpointSelector)s}) ||| % config, legendFormat='', instant=true, @@ -240,7 +256,7 @@ local table = grafana70.panel.table; )) .addTarget(prometheus.target( ||| - max by (mountpoint) (node_filesystem_avail_bytes{%(nodeExporterSelector)s, instance="$instance", %(fsSelector)s, %(fsMountpointSelector)s}) + max by (mountpoint) (node_filesystem_avail_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(fsSelector)s, %(fsMountpointSelector)s}) ||| % config, legendFormat='', instant=true, @@ -421,7 +437,7 @@ local table = grafana70.panel.table; fill=0, ) .addTarget(prometheus.target( - 'rate(node_network_receive_bytes_total{%(nodeExporterSelector)s, instance="$instance", device!="lo"}[$__rate_interval]) * 8' % config, + 'rate(node_network_receive_bytes_total{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", device!="lo"}[$__rate_interval]) * 8' % config, legendFormat='{{device}}', intervalFactor=1, )), @@ -437,7 +453,7 @@ local table = grafana70.panel.table; fill=0, ) .addTarget(prometheus.target( - 'rate(node_network_transmit_bytes_total{%(nodeExporterSelector)s, instance="$instance", device!="lo"}[$__rate_interval]) * 8' % config, + 'rate(node_network_transmit_bytes_total{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", device!="lo"}[$__rate_interval]) * 8' % config, legendFormat='{{device}}', intervalFactor=1, )), @@ -473,6 +489,7 @@ local table = grafana70.panel.table; local templates = [ prometheusDatasourceTemplate, + clusterTemplate, instanceTemplate, ], From 5e412a689ab56ae1bef1dfb34442137d809fc5d8 Mon Sep 17 00:00:00 2001 From: linuxgcc Date: Fri, 8 Mar 2024 22:06:03 +0800 Subject: [PATCH 24/48] disable selinux,fix end-to-end-test.sh error(#2934) (#2937) Signed-off-by: heyitao Co-authored-by: heyitao --- collector/fixtures/e2e-64k-page-output.txt | 4 ---- collector/fixtures/e2e-output.txt | 4 ---- end-to-end-test.sh | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 5b0ac8db46..c670fd9560 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -2933,7 +2933,6 @@ node_scrape_collector_success{collector="processes"} 1 node_scrape_collector_success{collector="qdisc"} 1 node_scrape_collector_success{collector="rapl"} 1 node_scrape_collector_success{collector="schedstat"} 1 -node_scrape_collector_success{collector="selinux"} 1 node_scrape_collector_success{collector="slabinfo"} 1 node_scrape_collector_success{collector="sockstat"} 1 node_scrape_collector_success{collector="softirqs"} 1 @@ -2951,9 +2950,6 @@ node_scrape_collector_success{collector="xfrm"} 1 node_scrape_collector_success{collector="xfs"} 1 node_scrape_collector_success{collector="zfs"} 1 node_scrape_collector_success{collector="zoneinfo"} 1 -# HELP node_selinux_enabled SELinux is enabled, 1 is true, 0 is false -# TYPE node_selinux_enabled gauge -node_selinux_enabled 0 # HELP node_slabinfo_active_objects The number of objects that are currently active (i.e., in use). # TYPE node_slabinfo_active_objects gauge node_slabinfo_active_objects{slab="dmaengine-unmap-128"} 1206 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 8920e56203..2caceedbb4 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2955,7 +2955,6 @@ node_scrape_collector_success{collector="processes"} 1 node_scrape_collector_success{collector="qdisc"} 1 node_scrape_collector_success{collector="rapl"} 1 node_scrape_collector_success{collector="schedstat"} 1 -node_scrape_collector_success{collector="selinux"} 1 node_scrape_collector_success{collector="slabinfo"} 1 node_scrape_collector_success{collector="sockstat"} 1 node_scrape_collector_success{collector="softirqs"} 1 @@ -2973,9 +2972,6 @@ node_scrape_collector_success{collector="xfrm"} 1 node_scrape_collector_success{collector="xfs"} 1 node_scrape_collector_success{collector="zfs"} 1 node_scrape_collector_success{collector="zoneinfo"} 1 -# HELP node_selinux_enabled SELinux is enabled, 1 is true, 0 is false -# TYPE node_selinux_enabled gauge -node_selinux_enabled 0 # HELP node_slabinfo_active_objects The number of objects that are currently active (i.e., in use). # TYPE node_slabinfo_active_objects gauge node_slabinfo_active_objects{slab="dmaengine-unmap-128"} 1206 diff --git a/end-to-end-test.sh b/end-to-end-test.sh index 46d52603e7..60263d54eb 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh @@ -40,7 +40,6 @@ enabled_collectors=$(cat << COLLECTORS qdisc rapl schedstat - selinux slabinfo sockstat softirqs @@ -58,6 +57,7 @@ enabled_collectors=$(cat << COLLECTORS COLLECTORS ) disabled_collectors=$(cat << COLLECTORS + selinux filesystem timex uname From 95efb86f6b49fe12ae69920eb660f2512cc1d64b Mon Sep 17 00:00:00 2001 From: Gavin Lam Date: Sat, 9 Mar 2024 04:00:06 -0500 Subject: [PATCH 25/48] Add new collector and metrics for watchdog (#2309) (#2880) Signed-off-by: Gavin Lam --- README.md | 1 + collector/fixtures/e2e-64k-page-output.txt | 26 ++++ collector/fixtures/e2e-output.txt | 26 ++++ collector/fixtures/sys.ttar | 69 +++++++++++ collector/watchdog.go | 133 +++++++++++++++++++++ collector/watchdog_test.go | 92 ++++++++++++++ end-to-end-test.sh | 1 + 7 files changed, 348 insertions(+) create mode 100644 collector/watchdog.go create mode 100644 collector/watchdog_test.go diff --git a/README.md b/README.md index 87b4e4ba01..5856df806c 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,7 @@ softirqs | Exposes detailed softirq statistics from `/proc/softirqs`. | Linux sysctl | Expose sysctl values from `/proc/sys`. Use `--collector.sysctl.include(-info)` to configure. | Linux systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux tcpstat | Exposes TCP connection status information from `/proc/net/tcp` and `/proc/net/tcp6`. (Warning: the current version has potential performance issues in high load situations.) | Linux +watchdog | Exposes statistics from `/sys/class/watchdog` | Linux wifi | Exposes WiFi device and station statistics. | Linux xfrm | Exposes statistics from `/proc/net/xfrm_stat` | Linux zoneinfo | Exposes NUMA memory zone metrics. | Linux diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index c670fd9560..e3de810caf 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -2945,6 +2945,7 @@ node_scrape_collector_success{collector="thermal_zone"} 1 node_scrape_collector_success{collector="time"} 1 node_scrape_collector_success{collector="udp_queues"} 1 node_scrape_collector_success{collector="vmstat"} 1 +node_scrape_collector_success{collector="watchdog"} 1 node_scrape_collector_success{collector="wifi"} 1 node_scrape_collector_success{collector="xfrm"} 1 node_scrape_collector_success{collector="xfs"} 1 @@ -3218,6 +3219,31 @@ node_vmstat_pswpin 1476 # HELP node_vmstat_pswpout /proc/vmstat information field pswpout. # TYPE node_vmstat_pswpout untyped node_vmstat_pswpout 35045 +# HELP node_watchdog_access_cs0 Value of /sys/class/watchdog//access_cs0 +# TYPE node_watchdog_access_cs0 gauge +node_watchdog_access_cs0{name="watchdog0"} 0 +# HELP node_watchdog_bootstatus Value of /sys/class/watchdog//bootstatus +# TYPE node_watchdog_bootstatus gauge +node_watchdog_bootstatus{name="watchdog0"} 1 +# HELP node_watchdog_fw_version Value of /sys/class/watchdog//fw_version +# TYPE node_watchdog_fw_version gauge +node_watchdog_fw_version{name="watchdog0"} 2 +# HELP node_watchdog_info Info of /sys/class/watchdog/ +# TYPE node_watchdog_info gauge +node_watchdog_info{identity="",name="watchdog1",options="",pretimeout_governor="",state="",status=""} 1 +node_watchdog_info{identity="Software Watchdog",name="watchdog0",options="0x8380",pretimeout_governor="noop",state="active",status="0x8000"} 1 +# HELP node_watchdog_nowayout Value of /sys/class/watchdog//nowayout +# TYPE node_watchdog_nowayout gauge +node_watchdog_nowayout{name="watchdog0"} 0 +# HELP node_watchdog_pretimeout_seconds Value of /sys/class/watchdog//pretimeout +# TYPE node_watchdog_pretimeout_seconds gauge +node_watchdog_pretimeout_seconds{name="watchdog0"} 120 +# HELP node_watchdog_timeleft_seconds Value of /sys/class/watchdog//timeleft +# TYPE node_watchdog_timeleft_seconds gauge +node_watchdog_timeleft_seconds{name="watchdog0"} 300 +# HELP node_watchdog_timeout_seconds Value of /sys/class/watchdog//timeout +# TYPE node_watchdog_timeout_seconds gauge +node_watchdog_timeout_seconds{name="watchdog0"} 60 # HELP node_wifi_interface_frequency_hertz The current frequency a WiFi interface is operating at, in hertz. # TYPE node_wifi_interface_frequency_hertz gauge node_wifi_interface_frequency_hertz{device="wlan0"} 2.412e+09 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 2caceedbb4..5b6cfbe1dd 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2967,6 +2967,7 @@ node_scrape_collector_success{collector="thermal_zone"} 1 node_scrape_collector_success{collector="time"} 1 node_scrape_collector_success{collector="udp_queues"} 1 node_scrape_collector_success{collector="vmstat"} 1 +node_scrape_collector_success{collector="watchdog"} 1 node_scrape_collector_success{collector="wifi"} 1 node_scrape_collector_success{collector="xfrm"} 1 node_scrape_collector_success{collector="xfs"} 1 @@ -3240,6 +3241,31 @@ node_vmstat_pswpin 1476 # HELP node_vmstat_pswpout /proc/vmstat information field pswpout. # TYPE node_vmstat_pswpout untyped node_vmstat_pswpout 35045 +# HELP node_watchdog_access_cs0 Value of /sys/class/watchdog//access_cs0 +# TYPE node_watchdog_access_cs0 gauge +node_watchdog_access_cs0{name="watchdog0"} 0 +# HELP node_watchdog_bootstatus Value of /sys/class/watchdog//bootstatus +# TYPE node_watchdog_bootstatus gauge +node_watchdog_bootstatus{name="watchdog0"} 1 +# HELP node_watchdog_fw_version Value of /sys/class/watchdog//fw_version +# TYPE node_watchdog_fw_version gauge +node_watchdog_fw_version{name="watchdog0"} 2 +# HELP node_watchdog_info Info of /sys/class/watchdog/ +# TYPE node_watchdog_info gauge +node_watchdog_info{identity="",name="watchdog1",options="",pretimeout_governor="",state="",status=""} 1 +node_watchdog_info{identity="Software Watchdog",name="watchdog0",options="0x8380",pretimeout_governor="noop",state="active",status="0x8000"} 1 +# HELP node_watchdog_nowayout Value of /sys/class/watchdog//nowayout +# TYPE node_watchdog_nowayout gauge +node_watchdog_nowayout{name="watchdog0"} 0 +# HELP node_watchdog_pretimeout_seconds Value of /sys/class/watchdog//pretimeout +# TYPE node_watchdog_pretimeout_seconds gauge +node_watchdog_pretimeout_seconds{name="watchdog0"} 120 +# HELP node_watchdog_timeleft_seconds Value of /sys/class/watchdog//timeleft +# TYPE node_watchdog_timeleft_seconds gauge +node_watchdog_timeleft_seconds{name="watchdog0"} 300 +# HELP node_watchdog_timeout_seconds Value of /sys/class/watchdog//timeout +# TYPE node_watchdog_timeout_seconds gauge +node_watchdog_timeout_seconds{name="watchdog0"} 60 # HELP node_wifi_interface_frequency_hertz The current frequency a WiFi interface is operating at, in hertz. # TYPE node_wifi_interface_frequency_hertz gauge node_wifi_interface_frequency_hertz{device="wlan0"} 2.412e+09 diff --git a/collector/fixtures/sys.ttar b/collector/fixtures/sys.ttar index 213c8b3867..0573cfd312 100644 --- a/collector/fixtures/sys.ttar +++ b/collector/fixtures/sys.ttar @@ -1717,6 +1717,75 @@ SymlinkTo: ../../devices/virtual/thermal/cooling_device0 Path: sys/class/thermal/thermal_zone0 SymlinkTo: ../../devices/virtual/thermal/thermal_zone0 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/class/watchdog +Mode: 775 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/class/watchdog/watchdog0 +Mode: 775 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/access_cs0 +Lines: 1 +0EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/bootstatus +Lines: 1 +1EOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/fw_version +Lines: 1 +2EOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/identity +Lines: 1 +Software WatchdogEOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/nowayout +Lines: 1 +0EOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/options +Lines: 1 +0x8380EOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/pretimeout +Lines: 1 +120EOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/pretimeout_governor +Lines: 1 +noopEOF +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/state +Lines: 1 +activeEOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/status +Lines: 1 +0x8000EOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/timeleft +Lines: 1 +300EOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/watchdog/watchdog0/timeout +Lines: 1 +60EOF +Mode: 444 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/class/watchdog/watchdog1 +Mode: 775 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/devices Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/collector/watchdog.go b/collector/watchdog.go new file mode 100644 index 0000000000..b4cb83d535 --- /dev/null +++ b/collector/watchdog.go @@ -0,0 +1,133 @@ +// Copyright 2023 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build linux && !nowatchdog +// +build linux,!nowatchdog + +package collector + +import ( + "fmt" + + "github.com/go-kit/log" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/procfs/sysfs" +) + +type watchdogCollector struct { + fs sysfs.FS + logger log.Logger +} + +func init() { + registerCollector("watchdog", defaultDisabled, NewWatchdogCollector) +} + +// NewWatchdogCollector returns a new Collector exposing watchdog stats. +func NewWatchdogCollector(logger log.Logger) (Collector, error) { + fs, err := sysfs.NewFS(*sysPath) + if err != nil { + return nil, fmt.Errorf("failed to open procfs: %w", err) + } + + return &watchdogCollector{ + fs: fs, + logger: logger, + }, nil +} + +var ( + watchdogBootstatusDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "watchdog", "bootstatus"), + "Value of /sys/class/watchdog//bootstatus", + []string{"name"}, nil, + ) + watchdogFwVersionDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "watchdog", "fw_version"), + "Value of /sys/class/watchdog//fw_version", + []string{"name"}, nil, + ) + watchdogNowayoutDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "watchdog", "nowayout"), + "Value of /sys/class/watchdog//nowayout", + []string{"name"}, nil, + ) + watchdogTimeleftDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "watchdog", "timeleft_seconds"), + "Value of /sys/class/watchdog//timeleft", + []string{"name"}, nil, + ) + watchdogTimeoutDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "watchdog", "timeout_seconds"), + "Value of /sys/class/watchdog//timeout", + []string{"name"}, nil, + ) + watchdogPretimeoutDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "watchdog", "pretimeout_seconds"), + "Value of /sys/class/watchdog//pretimeout", + []string{"name"}, nil, + ) + watchdogAccessCs0Desc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "watchdog", "access_cs0"), + "Value of /sys/class/watchdog//access_cs0", + []string{"name"}, nil, + ) + watchdogInfoDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "watchdog", "info"), + "Info of /sys/class/watchdog/", + []string{"name", "options", "identity", "state", "status", "pretimeout_governor"}, nil, + ) +) + +func toLabelValue(ptr *string) string { + if ptr == nil { + return "" + } + return *ptr +} + +func (c *watchdogCollector) Update(ch chan<- prometheus.Metric) error { + watchdogClass, err := c.fs.WatchdogClass() + if err != nil { + return err + } + + for _, wd := range watchdogClass { + if wd.Bootstatus != nil { + ch <- prometheus.MustNewConstMetric(watchdogBootstatusDesc, prometheus.GaugeValue, float64(*wd.Bootstatus), wd.Name) + } + if wd.FwVersion != nil { + ch <- prometheus.MustNewConstMetric(watchdogFwVersionDesc, prometheus.GaugeValue, float64(*wd.FwVersion), wd.Name) + } + if wd.Nowayout != nil { + ch <- prometheus.MustNewConstMetric(watchdogNowayoutDesc, prometheus.GaugeValue, float64(*wd.Nowayout), wd.Name) + } + if wd.Timeleft != nil { + ch <- prometheus.MustNewConstMetric(watchdogTimeleftDesc, prometheus.GaugeValue, float64(*wd.Timeleft), wd.Name) + } + if wd.Timeout != nil { + ch <- prometheus.MustNewConstMetric(watchdogTimeoutDesc, prometheus.GaugeValue, float64(*wd.Timeout), wd.Name) + } + if wd.Pretimeout != nil { + ch <- prometheus.MustNewConstMetric(watchdogPretimeoutDesc, prometheus.GaugeValue, float64(*wd.Pretimeout), wd.Name) + } + if wd.AccessCs0 != nil { + ch <- prometheus.MustNewConstMetric(watchdogAccessCs0Desc, prometheus.GaugeValue, float64(*wd.AccessCs0), wd.Name) + } + + ch <- prometheus.MustNewConstMetric(watchdogInfoDesc, prometheus.GaugeValue, 1.0, + wd.Name, toLabelValue(wd.Options), toLabelValue(wd.Identity), toLabelValue(wd.State), toLabelValue(wd.Status), toLabelValue(wd.PretimeoutGovernor)) + } + + return nil +} diff --git a/collector/watchdog_test.go b/collector/watchdog_test.go new file mode 100644 index 0000000000..7cf9418574 --- /dev/null +++ b/collector/watchdog_test.go @@ -0,0 +1,92 @@ +// Copyright 2023 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file ewcept in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !nowatchdog +// +build !nowatchdog + +package collector + +import ( + "fmt" + "os" + "strings" + "testing" + + "github.com/go-kit/log" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/testutil" +) + +type testWatchdogCollector struct { + wc Collector +} + +func (c testWatchdogCollector) Collect(ch chan<- prometheus.Metric) { + c.wc.Update(ch) +} + +func (c testWatchdogCollector) Describe(ch chan<- *prometheus.Desc) { + prometheus.DescribeByCollect(c, ch) +} + +func TestWatchdogStats(t *testing.T) { + testcase := `# HELP node_watchdog_access_cs0 Value of /sys/class/watchdog//access_cs0 + # TYPE node_watchdog_access_cs0 gauge + node_watchdog_access_cs0{name="watchdog0"} 0 + # HELP node_watchdog_bootstatus Value of /sys/class/watchdog//bootstatus + # TYPE node_watchdog_bootstatus gauge + node_watchdog_bootstatus{name="watchdog0"} 1 + # HELP node_watchdog_fw_version Value of /sys/class/watchdog//fw_version + # TYPE node_watchdog_fw_version gauge + node_watchdog_fw_version{name="watchdog0"} 2 + # HELP node_watchdog_info Info of /sys/class/watchdog/ + # TYPE node_watchdog_info gauge + node_watchdog_info{identity="",name="watchdog1",options="",pretimeout_governor="",state="",status=""} 1 + node_watchdog_info{identity="Software Watchdog",name="watchdog0",options="0x8380",pretimeout_governor="noop",state="active",status="0x8000"} 1 + # HELP node_watchdog_nowayout Value of /sys/class/watchdog//nowayout + # TYPE node_watchdog_nowayout gauge + node_watchdog_nowayout{name="watchdog0"} 0 + # HELP node_watchdog_pretimeout_seconds Value of /sys/class/watchdog//pretimeout + # TYPE node_watchdog_pretimeout_seconds gauge + node_watchdog_pretimeout_seconds{name="watchdog0"} 120 + # HELP node_watchdog_timeleft_seconds Value of /sys/class/watchdog//timeleft + # TYPE node_watchdog_timeleft_seconds gauge + node_watchdog_timeleft_seconds{name="watchdog0"} 300 + # HELP node_watchdog_timeout_seconds Value of /sys/class/watchdog//timeout + # TYPE node_watchdog_timeout_seconds gauge + node_watchdog_timeout_seconds{name="watchdog0"} 60 + ` + *sysPath = "fixtures/sys" + + logger := log.NewLogfmtLogger(os.Stderr) + c, err := NewWatchdogCollector(logger) + if err != nil { + t.Fatal(err) + } + reg := prometheus.NewRegistry() + reg.MustRegister(&testWatchdogCollector{wc: c}) + + sink := make(chan prometheus.Metric) + go func() { + err = c.Update(sink) + if err != nil { + panic(fmt.Errorf("failed to update collector: %s", err)) + } + close(sink) + }() + + err = testutil.GatherAndCompare(reg, strings.NewReader(testcase)) + if err != nil { + t.Fatal(err) + } +} diff --git a/end-to-end-test.sh b/end-to-end-test.sh index 60263d54eb..35e4534e6d 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh @@ -49,6 +49,7 @@ enabled_collectors=$(cat << COLLECTORS thermal_zone udp_queues vmstat + watchdog wifi xfrm xfs From 94ef5cc666ce6c797e1e7fbe9082cb1dc42af1f4 Mon Sep 17 00:00:00 2001 From: Gavin Lam Date: Thu, 14 Mar 2024 02:50:55 -0400 Subject: [PATCH 26/48] Enable watchdog module by default; Add no data error (#2953) Signed-off-by: Gavin Lam --- README.md | 2 +- collector/watchdog.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5856df806c..ad385650a4 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ timex | Exposes selected adjtimex(2) system call stats. | Linux udp_queues | Exposes UDP total lengths of the rx_queue and tx_queue from `/proc/net/udp` and `/proc/net/udp6`. | Linux uname | Exposes system information as provided by the uname system call. | Darwin, FreeBSD, Linux, OpenBSD vmstat | Exposes statistics from `/proc/vmstat`. | Linux +watchdog | Exposes statistics from `/sys/class/watchdog` | Linux xfs | Exposes XFS runtime statistics. | Linux (kernel 4.4+) zfs | Exposes [ZFS](http://open-zfs.org/) performance statistics. | FreeBSD, [Linux](http://zfsonlinux.org/), Solaris @@ -204,7 +205,6 @@ softirqs | Exposes detailed softirq statistics from `/proc/softirqs`. | Linux sysctl | Expose sysctl values from `/proc/sys`. Use `--collector.sysctl.include(-info)` to configure. | Linux systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux tcpstat | Exposes TCP connection status information from `/proc/net/tcp` and `/proc/net/tcp6`. (Warning: the current version has potential performance issues in high load situations.) | Linux -watchdog | Exposes statistics from `/sys/class/watchdog` | Linux wifi | Exposes WiFi device and station statistics. | Linux xfrm | Exposes statistics from `/proc/net/xfrm_stat` | Linux zoneinfo | Exposes NUMA memory zone metrics. | Linux diff --git a/collector/watchdog.go b/collector/watchdog.go index b4cb83d535..01351be9b5 100644 --- a/collector/watchdog.go +++ b/collector/watchdog.go @@ -17,9 +17,12 @@ package collector import ( + "errors" "fmt" + "os" "github.com/go-kit/log" + "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/procfs/sysfs" ) @@ -30,7 +33,7 @@ type watchdogCollector struct { } func init() { - registerCollector("watchdog", defaultDisabled, NewWatchdogCollector) + registerCollector("watchdog", defaultEnabled, NewWatchdogCollector) } // NewWatchdogCollector returns a new Collector exposing watchdog stats. @@ -99,6 +102,10 @@ func toLabelValue(ptr *string) string { func (c *watchdogCollector) Update(ch chan<- prometheus.Metric) error { watchdogClass, err := c.fs.WatchdogClass() if err != nil { + if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrInvalid) { + level.Debug(c.logger).Log("msg", "Could not read watchdog stats", "err", err) + return ErrNoData + } return err } From 666a5d719326d1193f5dd93867523f2f3ecf0a87 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Sun, 17 Mar 2024 16:32:01 +0100 Subject: [PATCH 27/48] Update common Prometheus files (#2954) Signed-off-by: prombot --- Makefile.common | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile.common b/Makefile.common index 92558151e3..49ed5f5478 100644 --- a/Makefile.common +++ b/Makefile.common @@ -208,6 +208,10 @@ common-tarball: promu @echo ">> building release tarball" $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) +.PHONY: common-docker-repo-name +common-docker-repo-name: + @echo "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)" + .PHONY: common-docker $(BUILD_DOCKER_ARCHS) common-docker: $(BUILD_DOCKER_ARCHS) $(BUILD_DOCKER_ARCHS): common-docker-%: From 9d359d082f55114bba58fb0b4be4d6ffb5683cf0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Mar 2024 16:32:11 +0100 Subject: [PATCH 28/48] build(deps): bump google.golang.org/protobuf from 1.32.0 to 1.33.0 (#2955) Bumps google.golang.org/protobuf from 1.32.0 to 1.33.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 098d25fbf6..ea6b91a6f1 100644 --- a/go.mod +++ b/go.mod @@ -56,6 +56,6 @@ require ( golang.org/x/sync v0.6.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.32.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 3439fcded6..15f9dadbfa 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,8 @@ google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6 google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= From 32ac7f48110fdce1c1b6bdbfcb58a7043cfef3f1 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Mon, 18 Mar 2024 19:32:49 +0100 Subject: [PATCH 29/48] Update common Prometheus files (#2959) Signed-off-by: prombot --- .github/workflows/container_description.yml | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/container_description.yml diff --git a/.github/workflows/container_description.yml b/.github/workflows/container_description.yml new file mode 100644 index 0000000000..0b8a8cc05f --- /dev/null +++ b/.github/workflows/container_description.yml @@ -0,0 +1,55 @@ +--- +name: Push README to Docker Hub +on: + push: + paths: + - "README.md" + - ".github/workflows/container_description.yml" + branches: [ main, master ] + +permissions: + contents: read + +jobs: + PushDockerHubReadme: + runs-on: ubuntu-latest + name: Push README to Docker Hub + if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. + steps: + - name: git checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Set docker hub repo name + run: echo "DOCKER_REPO_NAME=$(make common-docker-repo-name)" >> $GITHUB_ENV + - name: Push README to Dockerhub + uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1 + env: + DOCKER_USER: ${{ secrets.DOCKER_HUB_LOGIN }} + DOCKER_PASS: ${{ secrets.DOCKER_HUB_PASSWORD }} + with: + destination_container_repo: ${{ env.DOCKER_REPO_NAME }} + provider: dockerhub + short_description: ${{ env.DOCKER_REPO_NAME }} + readme_file: 'README.md' + + PushQuayIoReadme: + runs-on: ubuntu-latest + name: Push README to quay.io + if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. + steps: + - name: git checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Set quay.io org name + run: echo "DOCKER_REPO=$(echo quay.io/${GITHUB_REPOSITORY_OWNER} | tr -d '-')" >> $GITHUB_ENV + - name: Set quay.io repo name + run: echo "DOCKER_REPO_NAME=$(make common-docker-repo-name)" >> $GITHUB_ENV + - name: Push README to quay.io + uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1 + env: + DOCKER_APIKEY: ${{ secrets.QUAY_IO_API_TOKEN }} + with: + destination_container_repo: ${{ env.DOCKER_REPO_NAME }} + provider: quay + readme_file: 'README.md' + + + From 274cd51ce71137b8b7d41cb2131438dc684b539d Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Thu, 21 Mar 2024 09:15:02 +0100 Subject: [PATCH 30/48] Update common Prometheus files (#2964) Signed-off-by: prombot --- .github/workflows/container_description.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/container_description.yml b/.github/workflows/container_description.yml index 0b8a8cc05f..8a57107dd9 100644 --- a/.github/workflows/container_description.yml +++ b/.github/workflows/container_description.yml @@ -19,7 +19,7 @@ jobs: - name: git checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Set docker hub repo name - run: echo "DOCKER_REPO_NAME=$(make common-docker-repo-name)" >> $GITHUB_ENV + run: echo "DOCKER_REPO_NAME=$(make docker-repo-name)" >> $GITHUB_ENV - name: Push README to Dockerhub uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1 env: @@ -41,7 +41,7 @@ jobs: - name: Set quay.io org name run: echo "DOCKER_REPO=$(echo quay.io/${GITHUB_REPOSITORY_OWNER} | tr -d '-')" >> $GITHUB_ENV - name: Set quay.io repo name - run: echo "DOCKER_REPO_NAME=$(make common-docker-repo-name)" >> $GITHUB_ENV + run: echo "DOCKER_REPO_NAME=$(make docker-repo-name)" >> $GITHUB_ENV - name: Push README to quay.io uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1 env: @@ -50,6 +50,3 @@ jobs: destination_container_repo: ${{ env.DOCKER_REPO_NAME }} provider: quay readme_file: 'README.md' - - - From b3bbd1f52c0198cc92b40aa992508804f0e5f4c0 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Thu, 29 Feb 2024 22:00:45 +0100 Subject: [PATCH 31/48] Sanitize ethtool metric name keys Apply the same metric name sanitization to the keys as to the metric names. This avoids conflicting help strings in the metric registry. Fixes: https://github.com/prometheus/node_exporter/issues/2893 Signed-off-by: Ben Kochie --- collector/ethtool_linux.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/collector/ethtool_linux.go b/collector/ethtool_linux.go index 0111701bbe..7412c27c37 100644 --- a/collector/ethtool_linux.go +++ b/collector/ethtool_linux.go @@ -445,18 +445,19 @@ func (c *ethtoolCollector) Update(ch chan<- prometheus.Metric) error { // Sanitizing the metric names can lead to duplicate metric names. Therefore check for clashes beforehand. metricFQNames := make(map[string]string) for metric := range stats { - if !c.metricsPattern.MatchString(metric) { + metricName := SanitizeMetricName(metric) + if !c.metricsPattern.MatchString(metricName) { continue } - metricFQName := buildEthtoolFQName(metric) + metricFQName := buildEthtoolFQName(metricName) existingMetric, exists := metricFQNames[metricFQName] if exists { level.Debug(c.logger).Log("msg", "dropping duplicate metric name", "device", device, - "metricFQName", metricFQName, "metric1", existingMetric, "metric2", metric) - // Keep the metric as "deleted" in the dict in case there are 3 duplicates. + "metricFQName", metricFQName, "metric1", existingMetric, "metric2", metricName) + // Keep the metricName as "deleted" in the dict in case there are 3 duplicates. metricFQNames[metricFQName] = "" } else { - metricFQNames[metricFQName] = metric + metricFQNames[metricFQName] = metricName } } From 6425f079d162ebd22d4c6c4e4d7e4a36ebbe2239 Mon Sep 17 00:00:00 2001 From: prombot Date: Thu, 21 Mar 2024 17:47:50 +0000 Subject: [PATCH 32/48] Update common Prometheus files Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 2 +- .yamllint | 2 ++ Makefile.common | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 4dc7b830f6..5670d6079b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -35,4 +35,4 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 with: - version: v1.55.2 + version: v1.56.2 diff --git a/.yamllint b/.yamllint index 955a5a6270..1859cb624b 100644 --- a/.yamllint +++ b/.yamllint @@ -1,5 +1,7 @@ --- extends: default +ignore: | + ui/react-app/node_modules rules: braces: diff --git a/Makefile.common b/Makefile.common index 49ed5f5478..0acfb9d806 100644 --- a/Makefile.common +++ b/Makefile.common @@ -49,7 +49,7 @@ endif GOTEST := $(GO) test GOTEST_DIR := ifneq ($(CIRCLE_JOB),) -ifneq ($(shell command -v gotestsum > /dev/null),) +ifneq ($(shell command -v gotestsum 2> /dev/null),) GOTEST_DIR := test-results GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml -- endif @@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_ SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.55.2 +GOLANGCI_LINT_VERSION ?= v1.56.2 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) @@ -182,7 +182,7 @@ endif .PHONY: common-yamllint common-yamllint: @echo ">> running yamllint on all YAML files in the repository" -ifeq (, $(shell command -v yamllint > /dev/null)) +ifeq (, $(shell command -v yamllint 2> /dev/null)) @echo "yamllint not installed so skipping" else yamllint . From 641cf2c6b13adb8ae13b353cbdb76d3332ba8a1d Mon Sep 17 00:00:00 2001 From: occupyhabit <164632559+occupyhabit@users.noreply.github.com> Date: Sat, 23 Mar 2024 23:22:21 +0800 Subject: [PATCH 33/48] chore: fix some typos (#2974) Signed-off-by: occupyhabit --- ttar | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ttar b/ttar index b0171a12b5..e6cade7614 100755 --- a/ttar +++ b/ttar @@ -212,16 +212,16 @@ function extract { local eof_without_newline if [ "$size" -gt 0 ]; then if [[ "$line" =~ [^\\]EOF ]]; then - # An EOF not preceeded by a backslash indicates that the line + # An EOF not preceded by a backslash indicates that the line # does not end with a newline eof_without_newline=1 else eof_without_newline=0 fi # Replace NULLBYTE with null byte if at beginning of line - # Replace NULLBYTE with null byte unless preceeded by backslash + # Replace NULLBYTE with null byte unless preceded by backslash # Remove one backslash in front of NULLBYTE (if any) - # Remove EOF unless preceeded by backslash + # Remove EOF unless preceded by backslash # Remove one backslash in front of EOF if [ $USE_PYTHON -eq 1 ]; then echo -n "$line" | python -c "$PYTHON_EXTRACT_FILTER" >> "$path" From ebddab47e10dea74ce5503ae9ef183c7d4e79ec7 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Sun, 24 Mar 2024 11:13:03 +0530 Subject: [PATCH 34/48] collector/textfile: Avoid inconsistent help-texts (#2962) Avoid metrics with inconsistent help-texts. The earlier behaviour has been preserved in the sense that the first encountered instance is still used to generate metrics, whereas the subsequent inconsistent ones are ignored along with a few peripheral changes. ``` # HELP node_scrape_collector_duration_seconds node_exporter: Duration of a collector scrape. #TYPE node_scrape_collector_duration_seconds gauge node_scrape_collector_duration_seconds{collector="textfile"} 0.0004005 # HELP node_scrape_collector_success node_exporter: Whether a collector succeeded. # TYPE node_scrape_collector_success gauge node_scrape_collector_success{collector="textfile"} 1 # HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. # TYPE node_textfile_mtime_seconds gauge node_textfile_mtime_seconds{file="/Users/rexagod/repositories/misc/node_exporter/ne-bar.prom"} 1.710812009e+09 node_textfile_mtime_seconds{file="/Users/rexagod/repositories/misc/node_exporter/ne-foo.prom"} 1.710811982e+09 # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise # TYPE node_textfile_scrape_error gauge node_textfile_scrape_error 1 # HELP promhttp_metric_handler_errors_total Total number of internal errors encountered by the promhttp metric handler. # TYPE promhttp_metric_handler_errors_total counter promhttp_metric_handler_errors_total{cause="encoding"} 0 promhttp_metric_handler_errors_total{cause="gathering"} 0 # HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served. # TYPE promhttp_metric_handler_requests_in_flight gauge promhttp_metric_handler_requests_in_flight 1 # HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code. # TYPE promhttp_metric_handler_requests_total counter promhttp_metric_handler_requests_total{code="200"} 0 promhttp_metric_handler_requests_total{code="500"} 0 promhttp_metric_handler_requests_total{code="503"} 0 # HELP tau_infrastructure_performing_maintenance_task At what timestamp a given task started or stopped, the last time it was run. # TYPE tau_infrastructure_performing_maintenance_task gauge tau_infrastructure_performing_maintenance_task{main_task="nightly",start_or_stop="start",sub_task="main"} 1.64728080198446e+09 ``` Fixes: #2317 Signed-off-by: Pranshu Srivastava --- .../textfile/metrics_merge_different_help.out | 2 +- collector/textfile.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/collector/fixtures/textfile/metrics_merge_different_help.out b/collector/fixtures/textfile/metrics_merge_different_help.out index ba161f0779..b9385a752a 100644 --- a/collector/fixtures/textfile/metrics_merge_different_help.out +++ b/collector/fixtures/textfile/metrics_merge_different_help.out @@ -8,4 +8,4 @@ node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_different_help node_textfile_mtime_seconds{file="fixtures/textfile/metrics_merge_different_help/b.prom"} 1 # HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise # TYPE node_textfile_scrape_error gauge -node_textfile_scrape_error 0 +node_textfile_scrape_error 1 diff --git a/collector/textfile.go b/collector/textfile.go index 48133f7c98..4f1fd0b8c7 100644 --- a/collector/textfile.go +++ b/collector/textfile.go @@ -193,6 +193,7 @@ func (c *textFileCollector) Update(ch chan<- prometheus.Metric) error { var errored bool var parsedFamilies []*dto.MetricFamily metricsNamesToFiles := map[string][]string{} + metricsNamesToHelpTexts := map[string][2]string{} paths, err := filepath.Glob(c.path) if err != nil || len(paths) == 0 { @@ -218,6 +219,23 @@ func (c *textFileCollector) Update(ch chan<- prometheus.Metric) error { mtime, families, err := c.processFile(path, f.Name(), ch) for _, mf := range families { + // Check for metrics with inconsistent help texts and take the first help text occurrence. + if helpTexts, seen := metricsNamesToHelpTexts[*mf.Name]; seen { + if mf.Help != nil && helpTexts[0] != *mf.Help || helpTexts[1] != "" { + metricsNamesToHelpTexts[*mf.Name] = [2]string{helpTexts[0], *mf.Help} + errored = true + level.Error(c.logger).Log("msg", "inconsistent metric help text", + "metric", *mf.Name, + "original_help_text", helpTexts[0], + "new_help_text", *mf.Help, + // Only the first file path will be recorded in case of two or more inconsistent help texts. + "file", metricsNamesToFiles[*mf.Name][0]) + continue + } + } + if mf.Help != nil { + metricsNamesToHelpTexts[*mf.Name] = [2]string{*mf.Help} + } metricsNamesToFiles[*mf.Name] = append(metricsNamesToFiles[*mf.Name], metricsFilePath) parsedFamilies = append(parsedFamilies, mf) } From 3accd4cf8286e69d70516abdced6bf186274322a Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Sun, 24 Mar 2024 15:00:46 +0100 Subject: [PATCH 35/48] Update common Prometheus files (#2973) Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 5670d6079b..a7a40c1be5 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: install Go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: From b6227af54b20d147463e1672a3e8bfca47fa10ee Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Wed, 3 Apr 2024 10:23:03 +0000 Subject: [PATCH 36/48] os_release.go: Added support end parsing support. (#2982) * os_release.go: Added support end parsing support. Fixes: #2977 Signed-off-by: Jonathan Davies * os_release_test.go: Added TestParseOSSupportEnd. Signed-off-by: Jonathan Davies --------- Signed-off-by: Jonathan Davies --- collector/os_release.go | 23 ++++++++++++++++++++ collector/os_release_test.go | 42 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/collector/os_release.go b/collector/os_release.go index 14a025a454..5d2e94296c 100644 --- a/collector/os_release.go +++ b/collector/os_release.go @@ -53,6 +53,7 @@ type osRelease struct { BuildID string ImageID string ImageVersion string + SupportEnd string } type osReleaseCollector struct { @@ -65,6 +66,8 @@ type osReleaseCollector struct { osReleaseFilenames []string // all os-release file names to check version float64 versionDesc *prometheus.Desc + supportEnd time.Time + supportEndDesc *prometheus.Desc } type Plist struct { @@ -97,6 +100,11 @@ func NewOSCollector(logger log.Logger) (Collector, error) { "Metric containing the major.minor part of the OS version.", []string{"id", "id_like", "name"}, nil, ), + supportEndDesc: prometheus.NewDesc( + prometheus.BuildFQName(namespace, "os", "support_end_timestamp_seconds"), + "Metric containing the end-of-life date timestamp of the OS.", + nil, nil, + ), }, nil } @@ -115,6 +123,7 @@ func parseOSRelease(r io.Reader) (*osRelease, error) { BuildID: env["BUILD_ID"], ImageID: env["IMAGE_ID"], ImageVersion: env["IMAGE_VERSION"], + SupportEnd: env["SUPPORT_END"], }, err } @@ -169,6 +178,15 @@ func (c *osReleaseCollector) UpdateStruct(path string) error { } else { c.version = 0 } + + if c.os.SupportEnd != "" { + c.supportEnd, err = time.Parse("2006-01-02", c.os.SupportEnd) + + if err != nil { + return err + } + } + return nil } @@ -195,6 +213,11 @@ func (c *osReleaseCollector) Update(ch chan<- prometheus.Metric) error { ch <- prometheus.MustNewConstMetric(c.versionDesc, prometheus.GaugeValue, c.version, c.os.ID, c.os.IDLike, c.os.Name) } + + if c.os.SupportEnd != "" { + ch <- prometheus.MustNewConstMetric(c.supportEndDesc, prometheus.GaugeValue, float64(c.supportEnd.Unix())) + } + return nil } diff --git a/collector/os_release_test.go b/collector/os_release_test.go index 46838f15f1..b45ee0edfa 100644 --- a/collector/os_release_test.go +++ b/collector/os_release_test.go @@ -33,12 +33,28 @@ SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" ` +const nixosTapir string = `BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues" +BUILD_ID="23.11.20240328.219951b" +DOCUMENTATION_URL="https://nixos.org/learn.html" +HOME_URL="https://nixos.org/" +ID=nixos +LOGO="nix-snowflake" +NAME=NixOS +PRETTY_NAME="NixOS 23.11 (Tapir)" +SUPPORT_END="2024-06-30" +SUPPORT_URL="https://nixos.org/community.html" +VERSION="23.11 (Tapir)" +VERSION_CODENAME=tapir +VERSION_ID="23.11" +` + func TestParseOSRelease(t *testing.T) { want := &osRelease{ Name: "Ubuntu", ID: "ubuntu", IDLike: "debian", PrettyName: "Ubuntu 20.04.2 LTS", + SupportEnd: "", Version: "20.04.2 LTS (Focal Fossa)", VersionID: "20.04", VersionCodename: "focal", @@ -75,6 +91,32 @@ func TestParseOSRelease(t *testing.T) { } } +func TestParseOSSupportEnd(t *testing.T) { + want := &osRelease{ + BuildID: "23.11.20240328.219951b", + Name: "NixOS", + ID: "nixos", + IDLike: "", + ImageID: "", + ImageVersion: "", + PrettyName: "NixOS 23.11 (Tapir)", + SupportEnd: "2024-06-30", + Variant: "", + VariantID: "", + Version: "23.11 (Tapir)", + VersionID: "23.11", + VersionCodename: "tapir", + } + + got, err := parseOSRelease(strings.NewReader(nixosTapir)) + if err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(want, got) { + t.Fatalf("should have %+v osRelease: got %+v", want, got) + } +} + func TestUpdateStruct(t *testing.T) { wantedOS := &osRelease{ Name: "Ubuntu", From 29cdbd63fe943d7a4542bdc2fa3176e4edfd35fd Mon Sep 17 00:00:00 2001 From: Daniel Kimsey <90741+dekimsey@users.noreply.github.com> Date: Sat, 23 Mar 2024 13:57:56 -0500 Subject: [PATCH 37/48] zfs: Log mib when sysctl read fails on FreeBSD When the zfs collector fails on FreeBSD it doesn't log which `mib` triggered the issue. This makes diagnostics hard. Incompatibilities in the list of supported mibs is not uncommon with major os updates. By adding this change, it'll be easier for users to report the specific mib that is triggering the failure. Related to #2847 Signed-off-by: Daniel Kimsey <90741+dekimsey@users.noreply.github.com> --- collector/zfs_freebsd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/zfs_freebsd.go b/collector/zfs_freebsd.go index bc4aa1c3f7..804d4f58a9 100644 --- a/collector/zfs_freebsd.go +++ b/collector/zfs_freebsd.go @@ -273,7 +273,7 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error { v, err := m.Value() if err != nil { // debug logging - level.Debug(c.logger).Log("name", m.name, "couldn't get sysctl:", err) + level.Debug(c.logger).Log("name", m.name, "mib", m.mib, "couldn't get sysctl:", err) continue } From 7d4103c08918db8e117032170beeba4cfea0ebac Mon Sep 17 00:00:00 2001 From: looklose Date: Wed, 10 Apr 2024 19:59:46 +0800 Subject: [PATCH 38/48] chore: fix typo in comment Signed-off-by: looklose --- collector/systemd_linux.go | 2 +- docs/node-mixin/config.libsonnet | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/collector/systemd_linux.go b/collector/systemd_linux.go index 3323251114..e0d35bcde6 100644 --- a/collector/systemd_linux.go +++ b/collector/systemd_linux.go @@ -75,7 +75,7 @@ type systemdCollector struct { socketCurrentConnectionsDesc *prometheus.Desc socketRefusedConnectionsDesc *prometheus.Desc systemdVersionDesc *prometheus.Desc - // Use regexps for more flexability than device_filter.go allows + // Use regexps for more flexibility than device_filter.go allows systemdUnitIncludePattern *regexp.Regexp systemdUnitExcludePattern *regexp.Regexp logger log.Logger diff --git a/docs/node-mixin/config.libsonnet b/docs/node-mixin/config.libsonnet index bf6c83edd3..df2af23f92 100644 --- a/docs/node-mixin/config.libsonnet +++ b/docs/node-mixin/config.libsonnet @@ -73,7 +73,7 @@ fsSpaceAvailableWarningThreshold: 5, fsSpaceAvailableCriticalThreshold: 3, - // Memory utilzation (%) level on which to trigger the + // Memory utilization (%) level on which to trigger the // 'NodeMemoryHighUtilization' alert. memoryHighUtilizationThreshold: 90, From bf67c859bb762fd9460c9b6a8cb2961ad258bcd1 Mon Sep 17 00:00:00 2001 From: Ayoub Mrini Date: Mon, 15 Apr 2024 10:52:59 +0100 Subject: [PATCH 39/48] fibre_channel: update procfs to take into account optional attributes (#2933) Signed-off-by: machine424 --- collector/fibrechannel_linux.go | 12 ---- collector/fixtures/e2e-64k-page-output.txt | 16 +++++ collector/fixtures/e2e-output.txt | 16 +++++ collector/fixtures/sys.ttar | 81 ++++++++++++++++++++++ 4 files changed, 113 insertions(+), 12 deletions(-) diff --git a/collector/fibrechannel_linux.go b/collector/fibrechannel_linux.go index 32e4d1e733..13a3b5dc16 100644 --- a/collector/fibrechannel_linux.go +++ b/collector/fibrechannel_linux.go @@ -66,18 +66,6 @@ func NewFibreChannelCollector(logger log.Logger) (Collector, error) { "rx_words_total": "Number of words received by host port", "tx_frames_total": "Number of frames transmitted by host port", "link_failure_total": "Number of times the host port link has failed", - "name": "Name of Fibre Channel HBA", - "speed": "Current operating speed", - "port_state": "Current port state", - "port_type": "Port type, what the port is connected to", - "symbolic_name": "Symbolic Name", - "node_name": "Node Name as hexadecimal string", - "port_id": "Port ID as string", - "port_name": "Port Name as hexadecimal string", - "fabric_name": "Fabric Name; 0 if PTP", - "dev_loss_tmo": "Device Loss Timeout in seconds", - "supported_classes": "The FC classes supported", - "supported_speeds": "The FC speeds supported", } i.metricDescs = make(map[string]*prometheus.Desc) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index e3de810caf..99c58abaf7 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -742,48 +742,64 @@ node_entropy_available_bits 1337 node_entropy_pool_size_bits 4096 # HELP node_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which node_exporter was built, and the goos and goarch for the build. # TYPE node_exporter_build_info gauge +# HELP node_fibrechannel_dumped_frames_total Number of dumped frames +# TYPE node_fibrechannel_dumped_frames_total counter +node_fibrechannel_dumped_frames_total{fc_host="host1"} 0 # HELP node_fibrechannel_error_frames_total Number of errors in frames # TYPE node_fibrechannel_error_frames_total counter node_fibrechannel_error_frames_total{fc_host="host0"} 0 +node_fibrechannel_error_frames_total{fc_host="host1"} 19 # HELP node_fibrechannel_fcp_packet_aborts_total Number of aborted packets # TYPE node_fibrechannel_fcp_packet_aborts_total counter node_fibrechannel_fcp_packet_aborts_total{fc_host="host0"} 19 # HELP node_fibrechannel_info Non-numeric data from /sys/class/fc_host/, value is always 1. # TYPE node_fibrechannel_info gauge +node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1 node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host0",port_id="000002",port_name="1000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1 # HELP node_fibrechannel_invalid_crc_total Invalid Cyclic Redundancy Check count # TYPE node_fibrechannel_invalid_crc_total counter node_fibrechannel_invalid_crc_total{fc_host="host0"} 2 +node_fibrechannel_invalid_crc_total{fc_host="host1"} 32 # HELP node_fibrechannel_invalid_tx_words_total Number of invalid words transmitted by host port # TYPE node_fibrechannel_invalid_tx_words_total counter node_fibrechannel_invalid_tx_words_total{fc_host="host0"} 8 +node_fibrechannel_invalid_tx_words_total{fc_host="host1"} 128 # HELP node_fibrechannel_link_failure_total Number of times the host port link has failed # TYPE node_fibrechannel_link_failure_total counter node_fibrechannel_link_failure_total{fc_host="host0"} 9 +node_fibrechannel_link_failure_total{fc_host="host1"} 144 # HELP node_fibrechannel_loss_of_signal_total Number of times signal has been lost # TYPE node_fibrechannel_loss_of_signal_total counter node_fibrechannel_loss_of_signal_total{fc_host="host0"} 17 +node_fibrechannel_loss_of_signal_total{fc_host="host1"} 272 # HELP node_fibrechannel_loss_of_sync_total Number of failures on either bit or transmission word boundaries # TYPE node_fibrechannel_loss_of_sync_total counter node_fibrechannel_loss_of_sync_total{fc_host="host0"} 16 +node_fibrechannel_loss_of_sync_total{fc_host="host1"} 256 # HELP node_fibrechannel_nos_total Number Not_Operational Primitive Sequence received by host port # TYPE node_fibrechannel_nos_total counter node_fibrechannel_nos_total{fc_host="host0"} 18 +node_fibrechannel_nos_total{fc_host="host1"} 288 # HELP node_fibrechannel_rx_frames_total Number of frames received # TYPE node_fibrechannel_rx_frames_total counter node_fibrechannel_rx_frames_total{fc_host="host0"} 3 +node_fibrechannel_rx_frames_total{fc_host="host1"} 48 # HELP node_fibrechannel_rx_words_total Number of words received by host port # TYPE node_fibrechannel_rx_words_total counter node_fibrechannel_rx_words_total{fc_host="host0"} 4 +node_fibrechannel_rx_words_total{fc_host="host1"} 64 # HELP node_fibrechannel_seconds_since_last_reset_total Number of seconds since last host port reset # TYPE node_fibrechannel_seconds_since_last_reset_total counter node_fibrechannel_seconds_since_last_reset_total{fc_host="host0"} 7 +node_fibrechannel_seconds_since_last_reset_total{fc_host="host1"} 112 # HELP node_fibrechannel_tx_frames_total Number of frames transmitted by host port # TYPE node_fibrechannel_tx_frames_total counter node_fibrechannel_tx_frames_total{fc_host="host0"} 5 +node_fibrechannel_tx_frames_total{fc_host="host1"} 80 # HELP node_fibrechannel_tx_words_total Number of words transmitted by host port # TYPE node_fibrechannel_tx_words_total counter node_fibrechannel_tx_words_total{fc_host="host0"} 6 +node_fibrechannel_tx_words_total{fc_host="host1"} 96 # HELP node_filefd_allocated File descriptor statistics: allocated. # TYPE node_filefd_allocated gauge node_filefd_allocated 1024 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 5b6cfbe1dd..d52cb99d04 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -764,48 +764,64 @@ node_entropy_available_bits 1337 node_entropy_pool_size_bits 4096 # HELP node_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which node_exporter was built, and the goos and goarch for the build. # TYPE node_exporter_build_info gauge +# HELP node_fibrechannel_dumped_frames_total Number of dumped frames +# TYPE node_fibrechannel_dumped_frames_total counter +node_fibrechannel_dumped_frames_total{fc_host="host1"} 0 # HELP node_fibrechannel_error_frames_total Number of errors in frames # TYPE node_fibrechannel_error_frames_total counter node_fibrechannel_error_frames_total{fc_host="host0"} 0 +node_fibrechannel_error_frames_total{fc_host="host1"} 19 # HELP node_fibrechannel_fcp_packet_aborts_total Number of aborted packets # TYPE node_fibrechannel_fcp_packet_aborts_total counter node_fibrechannel_fcp_packet_aborts_total{fc_host="host0"} 19 # HELP node_fibrechannel_info Non-numeric data from /sys/class/fc_host/, value is always 1. # TYPE node_fibrechannel_info gauge +node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1 node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host0",port_id="000002",port_name="1000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1 # HELP node_fibrechannel_invalid_crc_total Invalid Cyclic Redundancy Check count # TYPE node_fibrechannel_invalid_crc_total counter node_fibrechannel_invalid_crc_total{fc_host="host0"} 2 +node_fibrechannel_invalid_crc_total{fc_host="host1"} 32 # HELP node_fibrechannel_invalid_tx_words_total Number of invalid words transmitted by host port # TYPE node_fibrechannel_invalid_tx_words_total counter node_fibrechannel_invalid_tx_words_total{fc_host="host0"} 8 +node_fibrechannel_invalid_tx_words_total{fc_host="host1"} 128 # HELP node_fibrechannel_link_failure_total Number of times the host port link has failed # TYPE node_fibrechannel_link_failure_total counter node_fibrechannel_link_failure_total{fc_host="host0"} 9 +node_fibrechannel_link_failure_total{fc_host="host1"} 144 # HELP node_fibrechannel_loss_of_signal_total Number of times signal has been lost # TYPE node_fibrechannel_loss_of_signal_total counter node_fibrechannel_loss_of_signal_total{fc_host="host0"} 17 +node_fibrechannel_loss_of_signal_total{fc_host="host1"} 272 # HELP node_fibrechannel_loss_of_sync_total Number of failures on either bit or transmission word boundaries # TYPE node_fibrechannel_loss_of_sync_total counter node_fibrechannel_loss_of_sync_total{fc_host="host0"} 16 +node_fibrechannel_loss_of_sync_total{fc_host="host1"} 256 # HELP node_fibrechannel_nos_total Number Not_Operational Primitive Sequence received by host port # TYPE node_fibrechannel_nos_total counter node_fibrechannel_nos_total{fc_host="host0"} 18 +node_fibrechannel_nos_total{fc_host="host1"} 288 # HELP node_fibrechannel_rx_frames_total Number of frames received # TYPE node_fibrechannel_rx_frames_total counter node_fibrechannel_rx_frames_total{fc_host="host0"} 3 +node_fibrechannel_rx_frames_total{fc_host="host1"} 48 # HELP node_fibrechannel_rx_words_total Number of words received by host port # TYPE node_fibrechannel_rx_words_total counter node_fibrechannel_rx_words_total{fc_host="host0"} 4 +node_fibrechannel_rx_words_total{fc_host="host1"} 64 # HELP node_fibrechannel_seconds_since_last_reset_total Number of seconds since last host port reset # TYPE node_fibrechannel_seconds_since_last_reset_total counter node_fibrechannel_seconds_since_last_reset_total{fc_host="host0"} 7 +node_fibrechannel_seconds_since_last_reset_total{fc_host="host1"} 112 # HELP node_fibrechannel_tx_frames_total Number of frames transmitted by host port # TYPE node_fibrechannel_tx_frames_total counter node_fibrechannel_tx_frames_total{fc_host="host0"} 5 +node_fibrechannel_tx_frames_total{fc_host="host1"} 80 # HELP node_fibrechannel_tx_words_total Number of words transmitted by host port # TYPE node_fibrechannel_tx_words_total counter node_fibrechannel_tx_words_total{fc_host="host0"} 6 +node_fibrechannel_tx_words_total{fc_host="host1"} 96 # HELP node_filefd_allocated File descriptor statistics: allocated. # TYPE node_filefd_allocated gauge node_filefd_allocated 1024 diff --git a/collector/fixtures/sys.ttar b/collector/fixtures/sys.ttar index 0573cfd312..2cac29e493 100644 --- a/collector/fixtures/sys.ttar +++ b/collector/fixtures/sys.ttar @@ -288,6 +288,87 @@ Lines: 1 Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux Mode: 644 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/class/fc_host/host1 +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/speed +Lines: 1 +8 Gbit +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Directory: sys/class/fc_host/host1/statistics +Mode: 755 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/dumped_frames +Lines: 1 +0x0 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/error_frames +Lines: 1 +0x13 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/fcp_packet_aborts +Lines: 1 +0xffffffffffffffff +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/invalid_crc_count +Lines: 1 +0x20 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/invalid_tx_word_count +Lines: 1 +0x80 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/link_failure_count +Lines: 1 +0x90 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/loss_of_signal_count +Lines: 1 +0x110 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/loss_of_sync_count +Lines: 1 +0x100 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/nos_count +Lines: 1 +0x120 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/rx_frames +Lines: 1 +0x30 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/rx_words +Lines: 1 +0x40 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/seconds_since_last_reset +Lines: 1 +0x70 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/tx_frames +Lines: 1 +0x50 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/statistics/tx_words +Lines: 1 +0x60 +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Directory: sys/class/hwmon Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 02022208813d0f4a87432ffc8ef03903ab6763b5 Mon Sep 17 00:00:00 2001 From: coderwander <166724773+coderwander@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:43:16 +0800 Subject: [PATCH 40/48] refactor: Optimize code by using built-in constants in the standard library (#2989) Signed-off-by: coderwander <770732124@qq.com> --- collector/os_release.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/os_release.go b/collector/os_release.go index 5d2e94296c..9d0a7a1b31 100644 --- a/collector/os_release.go +++ b/collector/os_release.go @@ -180,7 +180,7 @@ func (c *osReleaseCollector) UpdateStruct(path string) error { } if c.os.SupportEnd != "" { - c.supportEnd, err = time.Parse("2006-01-02", c.os.SupportEnd) + c.supportEnd, err = time.Parse(time.DateOnly, c.os.SupportEnd) if err != nil { return err From 36e0d1f6d4267f6d3acd45505ec35341dcd1e0b0 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Wed, 17 Apr 2024 19:27:47 +0000 Subject: [PATCH 41/48] os_release.go: Removed caching of modtime/filename of os-release file. (#2987) Signed-off-by: Jonathan Davies --- collector/os_release.go | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/collector/os_release.go b/collector/os_release.go index 9d0a7a1b31..4c86740e61 100644 --- a/collector/os_release.go +++ b/collector/os_release.go @@ -60,8 +60,6 @@ type osReleaseCollector struct { infoDesc *prometheus.Desc logger log.Logger os *osRelease - osFilename string // file name of cached release information - osMtime time.Time // mtime of cached release file osMutex sync.RWMutex osReleaseFilenames []string // all os-release file names to check version float64 @@ -134,28 +132,10 @@ func (c *osReleaseCollector) UpdateStruct(path string) error { } defer releaseFile.Close() - stat, err := releaseFile.Stat() - if err != nil { - return err - } - - t := stat.ModTime() - c.osMutex.RLock() - upToDate := path == c.osFilename && t == c.osMtime - c.osMutex.RUnlock() - if upToDate { - // osReleaseCollector struct is already up-to-date. - return nil - } - // Acquire a lock to update the osReleaseCollector struct. c.osMutex.Lock() defer c.osMutex.Unlock() - level.Debug(c.logger).Log("msg", "file modification time has changed", - "file", path, "old_value", c.osMtime, "new_value", t) - c.osFilename = path - c.osMtime = t // SystemVersion.plist is xml file with MacOs version info if strings.Contains(releaseFile.Name(), "SystemVersion.plist") { c.os, err = getMacosProductVersion(releaseFile.Name()) From dc5d3ca0ae7835e08fb947dbd8268ba81aa595cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:15:14 +0200 Subject: [PATCH 42/48] build(deps): bump golang.org/x/net from 0.20.0 to 0.23.0 (#2996) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.20.0 to 0.23.0. - [Commits](https://github.com/golang/net/compare/v0.20.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index ea6b91a6f1..b34318008a 100644 --- a/go.mod +++ b/go.mod @@ -50,8 +50,8 @@ require ( github.com/xhit/go-str2duration/v2 v2.1.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/net v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/go.sum b/go.sum index 15f9dadbfa..5960e09622 100644 --- a/go.sum +++ b/go.sum @@ -97,13 +97,13 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= From e9e27138a88c6babb622503a99d8e35d8e813cd1 Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 19 Apr 2024 23:15:54 +0800 Subject: [PATCH 43/48] fix: data race of NetClassCollector metrics initialization when multiple requests happen (#2995) Signed-off-by: John Guo --- collector/netclass_linux.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/collector/netclass_linux.go b/collector/netclass_linux.go index 5d9324cdee..327c89aaf4 100644 --- a/collector/netclass_linux.go +++ b/collector/netclass_linux.go @@ -22,6 +22,7 @@ import ( "net" "os" "regexp" + "sync" "github.com/alecthomas/kingpin/v2" "github.com/go-kit/log" @@ -41,6 +42,7 @@ type netClassCollector struct { subsystem string ignoredDevicesPattern *regexp.Regexp metricDescs map[string]*prometheus.Desc + metricDescsMu sync.Mutex logger log.Logger } @@ -136,6 +138,9 @@ func (c *netClassCollector) netClassSysfsUpdate(ch chan<- prometheus.Metric) err } func (c *netClassCollector) getFieldDesc(name string) *prometheus.Desc { + c.metricDescsMu.Lock() + defer c.metricDescsMu.Unlock() + fieldDesc, exists := c.metricDescs[name] if !exists { From 5c4f9e727de4a213b702138f691480ae5a3053c7 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Fri, 19 Apr 2024 17:16:11 +0200 Subject: [PATCH 44/48] Update common Prometheus files (#2992) Signed-off-by: prombot --- .github/workflows/container_description.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/container_description.yml b/.github/workflows/container_description.yml index 8a57107dd9..d0368eaa1c 100644 --- a/.github/workflows/container_description.yml +++ b/.github/workflows/container_description.yml @@ -17,7 +17,7 @@ jobs: if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. steps: - name: git checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: Set docker hub repo name run: echo "DOCKER_REPO_NAME=$(make docker-repo-name)" >> $GITHUB_ENV - name: Push README to Dockerhub @@ -37,7 +37,7 @@ jobs: if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. steps: - name: git checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: Set quay.io org name run: echo "DOCKER_REPO=$(echo quay.io/${GITHUB_REPOSITORY_OWNER} | tr -d '-')" >> $GITHUB_ENV - name: Set quay.io repo name From acb36765b4bd904ddf7bd3d29a187dfb7aeddbb7 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sat, 20 Apr 2024 12:32:49 +0200 Subject: [PATCH 45/48] Update build (#3000) * Update Go to 1.22. * Update Go modules. * Use new version collector. * Use standard library slices package. Signed-off-by: Ben Kochie --- .circleci/config.yml | 4 ++-- .promu-cgo.yml | 3 +-- .promu.yml | 3 +-- collector/cpu_linux.go | 2 +- go.mod | 18 +++++++++--------- go.sum | 39 +++++++++++++++++++++++---------------- node_exporter.go | 3 ++- 7 files changed, 39 insertions(+), 33 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3715e300dc..0e29a6afdc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ executors: # should also be updated. golang: docker: - - image: cimg/go:1.21 + - image: cimg/go:1.22 arm: machine: image: ubuntu-2204:current @@ -60,7 +60,7 @@ jobs: machine: image: ubuntu-2204:current environment: - DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.21-base + DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.22-base REPO_PATH: github.com/prometheus/node_exporter steps: - prometheus/setup_environment diff --git a/.promu-cgo.yml b/.promu-cgo.yml index d6f825299e..f270f78a29 100644 --- a/.promu-cgo.yml +++ b/.promu-cgo.yml @@ -1,14 +1,13 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu.yml should also be updated. - version: 1.21 + version: 1.22 cgo: true repository: path: github.com/prometheus/node_exporter build: binaries: - name: node_exporter - flags: -a -tags 'netgo osusergo static_build' ldflags: | -X github.com/prometheus/common/version.Version={{.Version}} -X github.com/prometheus/common/version.Revision={{.Revision}} diff --git a/.promu.yml b/.promu.yml index d0a66635f2..8f883591a1 100644 --- a/.promu.yml +++ b/.promu.yml @@ -1,13 +1,12 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu-cgo.yml should also be updated. - version: 1.21 + version: 1.22 repository: path: github.com/prometheus/node_exporter build: binaries: - name: node_exporter - flags: -a -tags 'netgo osusergo static_build' ldflags: | -X github.com/prometheus/common/version.Version={{.Version}} -X github.com/prometheus/common/version.Revision={{.Revision}} diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go index fcbf651b22..75d2a795b2 100644 --- a/collector/cpu_linux.go +++ b/collector/cpu_linux.go @@ -21,6 +21,7 @@ import ( "os" "path/filepath" "regexp" + "slices" "strconv" "sync" @@ -31,7 +32,6 @@ import ( "github.com/prometheus/procfs" "github.com/prometheus/procfs/sysfs" "golang.org/x/exp/maps" - "golang.org/x/exp/slices" ) type cpuCollector struct { diff --git a/go.mod b/go.mod index b34318008a..d11c69e311 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/prometheus/node_exporter -go 1.20 +go 1.21 require ( github.com/alecthomas/kingpin/v2 v2.4.0 github.com/beevik/ntp v1.3.1 github.com/coreos/go-systemd/v22 v22.5.0 - github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1 + github.com/dennwc/btrfs v0.0.0-20240418142341-0167142bde7a github.com/ema/qdisc v1.0.0 github.com/go-kit/log v0.2.1 github.com/godbus/dbus/v5 v5.1.0 @@ -23,13 +23,13 @@ require ( github.com/opencontainers/selinux v1.11.0 github.com/prometheus-community/go-runit v0.1.0 github.com/prometheus/client_golang v1.19.0 - github.com/prometheus/client_model v0.6.0 - github.com/prometheus/common v0.48.0 + github.com/prometheus/client_model v0.6.1 + github.com/prometheus/common v0.53.0 github.com/prometheus/exporter-toolkit v0.11.0 - github.com/prometheus/procfs v0.13.0 + github.com/prometheus/procfs v0.14.0 github.com/safchain/ethtool v0.3.0 - golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 - golang.org/x/sys v0.18.0 + golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f + golang.org/x/sys v0.19.0 howett.net/plist v1.0.1 ) @@ -52,8 +52,8 @@ require ( go.uber.org/multierr v1.6.0 // indirect golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect - golang.org/x/sync v0.6.0 // indirect + golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/go.sum b/go.sum index 5960e09622..5e0f6a48b2 100644 --- a/go.sum +++ b/go.sum @@ -9,13 +9,14 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cilium/ebpf v0.12.3 h1:8ht6F9MquybnY97at+VDZb3eQQr8ev79RueWeVaEcG4= +github.com/cilium/ebpf v0.12.3/go.mod h1:TctK1ivibvI3znr66ljgi4hqOT8EYQjz1KWBfb1UVgM= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1 h1:ue4Es4Xzz255hWQ7NAWzZxuXG+YOV7URzzusLLSe0zU= -github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1/go.mod h1:MYsOV9Dgsec3FFSOjywi0QK5r6TeBbdWxdrMGtiYXHA= +github.com/dennwc/btrfs v0.0.0-20240418142341-0167142bde7a h1:KfFsGLJFVdCXlySUkV2FmxNtmiztpJb6tV+XYBmmv8E= +github.com/dennwc/btrfs v0.0.0-20240418142341-0167142bde7a/go.mod h1:MYsOV9Dgsec3FFSOjywi0QK5r6TeBbdWxdrMGtiYXHA= github.com/dennwc/ioctl v1.0.0 h1:DsWAAjIxRqNcLn9x6mwfuf2pet3iB7aK90K4tF16rLg= github.com/dennwc/ioctl v1.0.0/go.mod h1:ellh2YB5ldny99SBU/VX7Nq0xiZbHphf1DrtHxxjMk0= github.com/ema/qdisc v1.0.0 h1:EHLG08FVRbWLg8uRICa3xzC9Zm0m7HyMHfXobWFnXYg= @@ -48,7 +49,9 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX github.com/jsimonetti/rtnetlink v1.4.1 h1:JfD4jthWBqZMEffc5RjgmlzpYttAVw1sdnmiNaPO3hE= github.com/jsimonetti/rtnetlink v1.4.1/go.mod h1:xJjT7t59UIZ62GLZbv6PLLo8VFrostJMPBAheR6OM8w= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lufia/iostat v1.2.1 h1:tnCdZBIglgxD47RyD55kfWQcJMGzO+1QBziSQfesf2k= github.com/lufia/iostat v1.2.1/go.mod h1:rEPNA0xXgjHQjuI5Cy05sLlS2oRcSlWHRLrvh/AQ+Pg= github.com/mattn/go-xmlrpc v0.0.3 h1:Y6WEMLEsqs3RviBrAa1/7qmbGB7DVD3brZIbqMbQdGY= @@ -73,15 +76,16 @@ github.com/prometheus-community/go-runit v0.1.0 h1:uTWEj/Fn2RoLdfg/etSqwzgYNOYPr github.com/prometheus-community/go-runit v0.1.0/go.mod h1:AvJ9Jo3gAFu2lbM4+qfjdpq30FfiLDJZKbQ015u08IQ= github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= -github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= -github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= +github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= -github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= -github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= +github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s= +github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0= github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs= github.com/siebenmann/go-kstat v0.0.0-20210513183136-173c9b0a9973 h1:GfSdC6wKfTGcgCS7BtzF5694Amne1pGCSTY252WhlEY= @@ -90,6 +94,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= @@ -99,20 +104,20 @@ go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9i golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= +golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= @@ -127,10 +132,12 @@ google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGm google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM= howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= diff --git a/node_exporter.go b/node_exporter.go index cc24f7dfba..c7285f6fdf 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -31,6 +31,7 @@ import ( "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" promcollectors "github.com/prometheus/client_golang/prometheus/collectors" + versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/version" "github.com/prometheus/exporter-toolkit/web" @@ -119,7 +120,7 @@ func (h *handler) innerHandler(filters ...string) (http.Handler, error) { } r := prometheus.NewRegistry() - r.MustRegister(version.NewCollector("node_exporter")) + r.MustRegister(versioncollector.NewCollector("node_exporter")) if err := r.Register(nc); err != nil { return nil, fmt.Errorf("couldn't register node collector: %s", err) } From d33336691453ee76d1065786a94a83db7f2b0fe8 Mon Sep 17 00:00:00 2001 From: Chris Cleeland Date: Mon, 22 Apr 2024 15:34:00 -0500 Subject: [PATCH 46/48] Fix watchdog_test lint and test failures on macos. (#3003) Ensure identical build flags embedded in both files. Signed-off-by: Chris Cleeland --- collector/watchdog_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collector/watchdog_test.go b/collector/watchdog_test.go index 7cf9418574..e59382b4c9 100644 --- a/collector/watchdog_test.go +++ b/collector/watchdog_test.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build !nowatchdog -// +build !nowatchdog +//go:build linux && !nowatchdog +// +build linux,!nowatchdog package collector From cadb1d1190ad95c66b951758f01ff4c94e55e6ce Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Wed, 24 Apr 2024 15:14:02 +0200 Subject: [PATCH 47/48] Release v1.8.0 (#3002) * [CHANGE] exec_bsd: Fix labels for `vm.stats.sys.v_syscall` sysctl #2895 * [CHANGE] diskstats: Ignore zram devices on linux systems #2898 * [CHANGE] textfile: Avoid inconsistent help-texts #2962 * [CHANGE] os: Removed caching of modtime/filename of os-release file #2987 * [FEATURE] xfrm: Add new collector #2866 * [FEATURE] watchdog: Add new collector #2880 * [ENHANCEMENT] cpu_vulnerabilities: Add mitigation information label #2806 * [ENHANCEMENT] nfsd: Handle new `wdeleg_getattr` attribute #2810 * [ENHANCEMENT] netstat: Add TCPOFOQueue to default netstat metrics #2867 * [ENHANCEMENT] filesystem: surface device errors #2923 * [ENHANCEMENT] os: Add support end parsing #2982 * [ENHANCEMENT] zfs: Log mib when sysctl read fails on FreeBSD #2975 * [ENHANCEMENT] fibre_channel: update procfs to take into account optional attributes #2933 * [BUGFIX] cpu: Fix debug log in cpu collector #2857 * [BUGFIX] hwmon: Fix hwmon nil ptr #2873 * [BUGFIX] hwmon: Fix hwmon error capture #2915 * [BUGFIX] zfs: Revert "Add ZFS freebsd per dataset stats #2925 * [BUGFIX] ethtool: Sanitize ethtool metric name keys #2940 * [BUGFIX] fix: data race of NetClassCollector metrics initialization #2995 Signed-off-by: Ben Kochie --- CHANGELOG.md | 22 ++++++++++++++++++++++ VERSION | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 096c0b1024..d2cb6c0951 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,28 @@ * [ENHANCEMENT] * [BUGFIX] +## 1.8.0 / 2024-04-24 + +* [CHANGE] exec_bsd: Fix labels for `vm.stats.sys.v_syscall` sysctl #2895 +* [CHANGE] diskstats: Ignore zram devices on linux systems #2898 +* [CHANGE] textfile: Avoid inconsistent help-texts #2962 +* [CHANGE] os: Removed caching of modtime/filename of os-release file #2987 +* [FEATURE] xfrm: Add new collector #2866 +* [FEATURE] watchdog: Add new collector #2880 +* [ENHANCEMENT] cpu_vulnerabilities: Add mitigation information label #2806 +* [ENHANCEMENT] nfsd: Handle new `wdeleg_getattr` attribute #2810 +* [ENHANCEMENT] netstat: Add TCPOFOQueue to default netstat metrics #2867 +* [ENHANCEMENT] filesystem: surface device errors #2923 +* [ENHANCEMENT] os: Add support end parsing #2982 +* [ENHANCEMENT] zfs: Log mib when sysctl read fails on FreeBSD #2975 +* [ENHANCEMENT] fibre_channel: update procfs to take into account optional attributes #2933 +* [BUGFIX] cpu: Fix debug log in cpu collector #2857 +* [BUGFIX] hwmon: Fix hwmon nil ptr #2873 +* [BUGFIX] hwmon: Fix hwmon error capture #2915 +* [BUGFIX] zfs: Revert "Add ZFS freebsd per dataset stats #2925 +* [BUGFIX] ethtool: Sanitize ethtool metric name keys #2940 +* [BUGFIX] fix: data race of NetClassCollector metrics initialization #2995 + ## 1.7.0 / 2023-11-11 * [FEATURE] Add ZFS freebsd per dataset stats #2753 diff --git a/VERSION b/VERSION index bd8bf882d0..27f9cd322b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.7.0 +1.8.0 From 9572e7a07b46f637f8754c67f9c7bf3a0a59f6fb Mon Sep 17 00:00:00 2001 From: Sam Leiken Date: Mon, 29 Apr 2024 10:38:29 -0700 Subject: [PATCH 48/48] Add logging for ethtool device include/exclude and metrics include flags (#2979) Signed-off-by: Sam Leiken --- collector/ethtool_linux.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/collector/ethtool_linux.go b/collector/ethtool_linux.go index 7412c27c37..45c35851d6 100644 --- a/collector/ethtool_linux.go +++ b/collector/ethtool_linux.go @@ -96,6 +96,16 @@ func makeEthtoolCollector(logger log.Logger) (*ethtoolCollector, error) { return nil, fmt.Errorf("failed to initialize ethtool library: %w", err) } + if *ethtoolDeviceInclude != "" { + level.Info(logger).Log("msg", "Parsed flag --collector.ethtool.device-include", "flag", *ethtoolDeviceInclude) + } + if *ethtoolDeviceExclude != "" { + level.Info(logger).Log("msg", "Parsed flag --collector.ethtool.device-exclude", "flag", *ethtoolDeviceExclude) + } + if *ethtoolIncludedMetrics != "" { + level.Info(logger).Log("msg", "Parsed flag --collector.ethtool.metrics-include", "flag", *ethtoolIncludedMetrics) + } + // Pre-populate some common ethtool metrics. return ðtoolCollector{ fs: fs,