Skip to content

Commit

Permalink
Merge branch 'master' into gpu-clk
Browse files Browse the repository at this point in the history
  • Loading branch information
zxhdaze authored Sep 22, 2024
2 parents 0bae946 + a5543cc commit 6d66518
Show file tree
Hide file tree
Showing 142 changed files with 965 additions and 790 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ executors:
# should also be updated.
golang:
docker:
- image: cimg/go:1.22
- image: cimg/go:1.23
arm:
machine:
image: ubuntu-2204:current
docker:
- image: cimg/go:1.23
resource_class: arm.medium

jobs:
Expand All @@ -25,7 +25,7 @@ jobs:
test-arm:
executor: arm
steps:
- checkout
- prometheus/setup_environment
- run: uname -a
- run: make test-e2e
test_mixins:
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
machine:
image: ubuntu-2204:current
environment:
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.22-base
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.23-base
REPO_PATH: github.com/prometheus/node_exporter
steps:
- prometheus/setup_environment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
Expand Down
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ linters-settings:
exclude-functions:
# Used in HTTP handlers, any error is handled by the server itself.
- (net/http.ResponseWriter).Write
# Never check for logger errors.
- (github.com/go-kit/log.Logger).Log
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
Expand Down
2 changes: 1 addition & 1 deletion .promu-cgo.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
go:
# Whenever the Go version is updated here, .circle/config.yml and
# .promu.yml should also be updated.
version: 1.22
version: 1.23
cgo: true
repository:
path: github.com/prometheus/node_exporter
Expand Down
2 changes: 1 addition & 1 deletion .promu.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
go:
# Whenever the Go version is updated here, .circle/config.yml and
# .promu-cgo.yml should also be updated.
version: 1.22
version: 1.23
repository:
path: github.com/prometheus/node_exporter
build:
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,21 @@ mv /path/to/directory/role.prom.$$ /path/to/directory/role.prom

The `node_exporter` will expose all metrics from enabled collectors by default. This is the recommended way to collect metrics to avoid errors when comparing metrics of different families.

For advanced use the `node_exporter` can be passed an optional list of collectors to filter metrics. The `collect[]` parameter may be used multiple times. In Prometheus configuration you can use this syntax under the [scrape config](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#<scrape_config>).
For advanced use the `node_exporter` can be passed an optional list of collectors to filter metrics. The parameters `collect[]` and `exclude[]` can be used multiple times (but cannot be combined). In Prometheus configuration you can use this syntax under the [scrape config](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#<scrape_config>).

Collect only `cpu` and `meminfo` collector metrics:
```
params:
collect[]:
- foo
- bar
- cpu
- meminfo
```

Collect all enabled collector metrics but exclude `netdev`:
```
params:
exclude[]:
- netdev
```

This can be useful for having different Prometheus servers collect specific metrics from nodes.
Expand Down
8 changes: 4 additions & 4 deletions collector/arp_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package collector
import (
"errors"
"fmt"
"log/slog"
"net"

"github.com/alecthomas/kingpin/v2"
"github.com/go-kit/log"
"github.com/jsimonetti/rtnetlink"
"github.com/jsimonetti/rtnetlink/v2"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs"
"golang.org/x/sys/unix"
Expand All @@ -39,15 +39,15 @@ type arpCollector struct {
fs procfs.FS
deviceFilter deviceFilter
entries *prometheus.Desc
logger log.Logger
logger *slog.Logger
}

func init() {
registerCollector("arp", defaultEnabled, NewARPCollector)
}

// NewARPCollector returns a new Collector exposing ARP stats.
func NewARPCollector(logger log.Logger) (Collector, error) {
func NewARPCollector(logger *slog.Logger) (Collector, error) {
fs, err := procfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %w", err)
Expand Down
6 changes: 3 additions & 3 deletions collector/bcache_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package collector

import (
"fmt"
"log/slog"

"github.com/alecthomas/kingpin/v2"
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/bcache"
)
Expand All @@ -36,12 +36,12 @@ func init() {
// A bcacheCollector is a Collector which gathers metrics from Linux bcache.
type bcacheCollector struct {
fs bcache.FS
logger log.Logger
logger *slog.Logger
}

// NewBcacheCollector returns a newly allocated bcacheCollector.
// It exposes a number of Linux bcache statistics.
func NewBcacheCollector(logger log.Logger) (Collector, error) {
func NewBcacheCollector(logger *slog.Logger) (Collector, error) {
fs, err := bcache.NewFS(*sysPath)
if err != nil {
return nil, fmt.Errorf("failed to open sysfs: %w", err)
Expand Down
9 changes: 4 additions & 5 deletions collector/bonding_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ package collector
import (
"errors"
"fmt"
"log/slog"
"os"
"path/filepath"
"strings"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
)

type bondingCollector struct {
slaves, active typedDesc
logger log.Logger
logger *slog.Logger
}

func init() {
Expand All @@ -39,7 +38,7 @@ func init() {

// NewBondingCollector returns a newly allocated bondingCollector.
// It exposes the number of configured and active slave of linux bonding interfaces.
func NewBondingCollector(logger log.Logger) (Collector, error) {
func NewBondingCollector(logger *slog.Logger) (Collector, error) {
return &bondingCollector{
slaves: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(namespace, "bonding", "slaves"),
Expand All @@ -61,7 +60,7 @@ func (c *bondingCollector) Update(ch chan<- prometheus.Metric) error {
bondingStats, err := readBondingStats(statusfile)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
level.Debug(c.logger).Log("msg", "Not collecting bonding, file does not exist", "file", statusfile)
c.logger.Debug("Not collecting bonding, file does not exist", "file", statusfile)
return ErrNoData
}
return err
Expand Down
6 changes: 3 additions & 3 deletions collector/boot_time_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
package collector

import (
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/sys/unix"
"log/slog"
)

type bootTimeCollector struct {
logger log.Logger
logger *slog.Logger
}

func init() {
registerCollector("boottime", defaultEnabled, newBootTimeCollector)
}

// newBootTimeCollector returns a new Collector exposing system boot time on BSD systems.
func newBootTimeCollector(logger log.Logger) (Collector, error) {
func newBootTimeCollector(logger *slog.Logger) (Collector, error) {
return &bootTimeCollector{
logger: logger,
}, nil
Expand Down
6 changes: 3 additions & 3 deletions collector/boot_time_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
package collector

import (
"github.com/go-kit/log"
"github.com/illumos/go-kstat"
"github.com/prometheus/client_golang/prometheus"
"log/slog"
)

type bootTimeCollector struct {
boottime typedDesc
logger log.Logger
logger *slog.Logger
}

func init() {
registerCollector("boottime", defaultEnabled, newBootTimeCollector)
}

func newBootTimeCollector(logger log.Logger) (Collector, error) {
func newBootTimeCollector(logger *slog.Logger) (Collector, error) {
return &bootTimeCollector{
boottime: typedDesc{
prometheus.NewDesc(
Expand Down
23 changes: 11 additions & 12 deletions collector/btrfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@ package collector

import (
"fmt"
"log/slog"
"path"
"strings"
"syscall"

dennwc "github.com/dennwc/btrfs"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/btrfs"
)

// A btrfsCollector is a Collector which gathers metrics from Btrfs filesystems.
type btrfsCollector struct {
fs btrfs.FS
logger log.Logger
logger *slog.Logger
}

func init() {
registerCollector("btrfs", defaultEnabled, NewBtrfsCollector)
}

// NewBtrfsCollector returns a new Collector exposing Btrfs statistics.
func NewBtrfsCollector(logger log.Logger) (Collector, error) {
func NewBtrfsCollector(logger *slog.Logger) (Collector, error) {
fs, err := btrfs.NewFS(*sysPath)
if err != nil {
return nil, fmt.Errorf("failed to open sysfs: %w", err)
Expand All @@ -62,8 +61,8 @@ func (c *btrfsCollector) Update(ch chan<- prometheus.Metric) error {

ioctlStatsMap, err := c.getIoctlStats()
if err != nil {
level.Debug(c.logger).Log(
"msg", "Error querying btrfs device stats with ioctl",
c.logger.Debug(
"Error querying btrfs device stats with ioctl",
"err", err)
ioctlStatsMap = make(map[string]*btrfsIoctlFsStats)
}
Expand Down Expand Up @@ -129,8 +128,8 @@ func (c *btrfsCollector) getIoctlStats() (map[string]*btrfsIoctlFsStats, error)
if err != nil {
// Failed to open this mount point, maybe we didn't have permission
// maybe we'll find another mount point for this FS later.
level.Debug(c.logger).Log(
"msg", "Error inspecting btrfs mountpoint",
c.logger.Debug(
"Error inspecting btrfs mountpoint",
"mountPoint", mountPath,
"err", err)
continue
Expand All @@ -141,8 +140,8 @@ func (c *btrfsCollector) getIoctlStats() (map[string]*btrfsIoctlFsStats, error)
if err != nil {
// Failed to get the FS info for some reason,
// perhaps it'll work with a different mount point
level.Debug(c.logger).Log(
"msg", "Error querying btrfs filesystem",
c.logger.Debug(
"Error querying btrfs filesystem",
"mountPoint", mountPath,
"err", err)
continue
Expand All @@ -156,8 +155,8 @@ func (c *btrfsCollector) getIoctlStats() (map[string]*btrfsIoctlFsStats, error)

deviceStats, err := c.getIoctlDeviceStats(fs, &fsInfo)
if err != nil {
level.Debug(c.logger).Log(
"msg", "Error querying btrfs device stats",
c.logger.Debug(
"Error querying btrfs device stats",
"mountPoint", mountPath,
"err", err)
continue
Expand Down
9 changes: 4 additions & 5 deletions collector/buddyinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ package collector

import (
"fmt"
"log/slog"
"strconv"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs"
)
Expand All @@ -33,15 +32,15 @@ const (
type buddyinfoCollector struct {
fs procfs.FS
desc *prometheus.Desc
logger log.Logger
logger *slog.Logger
}

func init() {
registerCollector("buddyinfo", defaultDisabled, NewBuddyinfoCollector)
}

// NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats.
func NewBuddyinfoCollector(logger log.Logger) (Collector, error) {
func NewBuddyinfoCollector(logger *slog.Logger) (Collector, error) {
desc := prometheus.NewDesc(
prometheus.BuildFQName(namespace, buddyInfoSubsystem, "blocks"),
"Count of free blocks according to size.",
Expand All @@ -62,7 +61,7 @@ func (c *buddyinfoCollector) Update(ch chan<- prometheus.Metric) error {
return fmt.Errorf("couldn't get buddyinfo: %w", err)
}

level.Debug(c.logger).Log("msg", "Set node_buddy", "buddyInfo", buddyInfo)
c.logger.Debug("Set node_buddy", "buddyInfo", buddyInfo)
for _, entry := range buddyInfo {
for size, value := range entry.Sizes {
ch <- prometheus.MustNewConstMetric(
Expand Down
6 changes: 3 additions & 3 deletions collector/cgroups_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package collector

import (
"fmt"
"log/slog"

"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs"
)
Expand All @@ -30,15 +30,15 @@ type cgroupSummaryCollector struct {
fs procfs.FS
cgroups *prometheus.Desc
enabled *prometheus.Desc
logger log.Logger
logger *slog.Logger
}

func init() {
registerCollector(cgroupsCollectorSubsystem, defaultDisabled, NewCgroupSummaryCollector)
}

// NewCgroupSummaryCollector returns a new Collector exposing a summary of cgroups.
func NewCgroupSummaryCollector(logger log.Logger) (Collector, error) {
func NewCgroupSummaryCollector(logger *slog.Logger) (Collector, error) {
fs, err := procfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %w", err)
Expand Down
Loading

0 comments on commit 6d66518

Please sign in to comment.