Commit graph

34 commits

Author SHA1 Message Date
Benoît Knecht 690efa61e8 collector/diskstats: Ignore udev when directory unreadable
Log a single error message when the udev data directory (`/run/udev/data` by
default) is unreadable, and then don't try to get device properties out of it.

Also lower the log level from error to debug when we can't parse the udev files
properly, since these messages would be sent every time the node exporter gets
scraped.

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
2022-07-06 12:30:50 +02:00
Benoît Knecht 9ec7d6ba3c collector/diskstats: Only get device properties from udev
When parsing udev data, skip lines that don't start with `E:`.

Lines prefixed with `E:` represent device properties, as documented in
udevadm(8).

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
2022-07-06 12:30:50 +02:00
Benoît Knecht 833216dc9e collector: Make udev data path optional
Instead of hard-coding the path to `/run/udev/data`, intoduce a
`--path.udev.data` flag that defaults to that value.

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
2022-07-06 12:30:50 +02:00
Benoît Knecht 75ceda8bb2 collector/diskstats: Don't use functions from Go 1.18
Since we need to support Go 1.17, don't use `strings.Cut()` which was
introduced in Go 1.18.

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
2022-07-06 12:30:50 +02:00
Benoît Knecht a997b6096d collector/diskstats: Add labels and metrics from udev
Add labels to the `node_disk_info` metric extracted from udev, such as `model`,
`path`, `revision`, `serial` and `wwn`.

Also add a few metrics related to filesystem and device mapper, which are also
extracted from udev information.

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
2022-07-06 12:30:50 +02:00
Ben Kochie 02f5005ac8
Add diskstat include/exclude flag to all platforms
Refactor diskstats collector include/exclude to work on all platforms.
* Fix up default ignored devices.

Signed-off-by: Ben Kochie <superq@gmail.com>
2022-06-28 08:30:01 +02:00
rushilenekar20 8fcc6320a2
Add diskstats include and exclude device flags
Use standard include/exclude pattern for device include/exclude in the
diskstats collector.

Signed-off-by: Ben Kochie <superq@gmail.com>
Co-authored-by: rushilenekar20 <rushilenekar20@gmail.com>
2022-06-28 07:48:21 +02:00
W. Andrew Denton 402a00932d Add a reference to the Linux kernel's documentation for block stat.
Signed-off-by: W. Andrew Denton <git@flying-snail.net>
2022-03-22 11:36:00 +01:00
W. Andrew Denton 84ce3a0103 diskstats_linux: always scale reads and writes by 512 bytes, not by device units.
Signed-off-by: W. Andrew Denton <git@flying-snail.net>
2022-03-22 11:36:00 +01:00
Julien Pivotto 68a6c78c0d
Update go to 1.17 (#2159)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-10-03 13:35:24 +02:00
ventifus 0aec407666
Refactor diskstats (#2141)
* Refactor diskstats_linux to use procfs.
* Add `node_disk_info` metric.

Signed-off-by: W. Andrew Denton <git@flying-snail.net>
Co-authored-by: W. Andrew Denton <git@flying-snail.net>
2021-09-28 10:14:12 +02:00
Ben Kochie 3bc9a93c20
Add ErrorLog plumbing to promhttp
Fix the error logging of the promhttp handler by connecting it to the
promlog setup.
* Switch to go-kit/log.
* Cleanup CHANGELOG.

Fixes: https://github.com/prometheus/node_exporter/issues/1886

Signed-off-by: Ben Kochie <superq@gmail.com>
2021-06-03 10:47:41 +02:00
Ben Kochie dfa53f835a
Use Go 1.13 error features
* Use `errors.Is()` for unwrapping errors.
* Use `%w` error verb in internal error formatting.

Signed-off-by: Ben Kochie <superq@gmail.com>
2020-06-16 14:47:03 +02:00
Ben Ye 2477c5c67d switch to go-kit/log (#1575)
Signed-off-by: yeya24 <yb532204897@gmail.com>
2019-12-31 17:19:37 +01:00
Holger Hoffstätte 3c2c4e7b3c Add new counters for flush requests in Linux 5.5 (#1548)
* Add diskstat flush request counters for Linux 5.5+
* Update tests for diskstat flush request counters with Linux 5.5+

Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
2019-11-25 13:16:15 -06:00
Ralf Horstmann 3867ad5ab0 Add diskstats collector for OpenBSD (#1250)
* Add diskstats collector for OpenBSD

Tested on i386 and amd64, OpenBSD 6.4 and -current.

* Refactor diskstats collectors

This moves common descriptors from Linux, Darwin, OpenBSD
diskstats collectors into diskstats_common.go

Signed-off-by: Ralf Horstmann <ralf+github@ackstorm.de>
2019-02-06 11:36:22 +01:00
Paul Gier 38163f234f collector/diskstats: don't fail if there are extra stats, just ignore… (#1125)
* collector/diskstats: don't fail if there are extra stats, just ignore them

Signed-off-by: Paul Gier <pgier@redhat.com>
2018-10-30 18:45:00 +01:00
Paul Gier e8d8199072 Update diskstats for linux kernel 4.19 (#1109)
The format of /proc/diskstats is changing in linux-4.19 to include some
additional fields.  See: https://www.kernel.org/doc/Documentation/iostats.txt

* collector/diskstats: use constants for some hard coded strings
* collector/diskstats: update diskstats for linux-4.19
* collector/diskstats: remove kernel doc url from individual metrics

Signed-off-by: Paul Gier <pgier@redhat.com>
2018-10-15 17:24:28 +02:00
Marco Tulio R Braga 05e55bddad Fix typo on description of read_time_seconds_total (#1057)
Fix typo on unit description of metric `*read_time_seconds_total` from milliseconds to seconds.

Signed-off-by: Marco Tulio R Braga <marco.tulio@mtulio.eng.br>
2018-09-02 09:46:45 +02:00
Brian Brazil a98067a294 Make metrics better follow guidelines (#787)
* Improve stat linux metric names.

cpu is no longer used.

* node_cpu -> node_cpu_seconds_total for Linux

* Improve filesystem metric names with units

* Improve units and names of linux disk stats

Remove sector metrics, the bytes metrics cover those already.

* Infiniband counters should end in _total

* Improve timex metric names, convert to more normal units.

See
3c073991eb/kernel/time/ntp.c (L909)
for what stabil means, looks like a moving average of some form.

* Update test fixture

* For meminfo metrics that had "kB" units, add _bytes

* Interrupts counter should have _total
2018-01-17 17:55:55 +01:00
Calle Pettersson 859a825bb8 Replace --collectors.enabled with per-collector flags (#640)
* Move NodeCollector into package collector

* Refactor collector enabling

* Update README with new collector enabled flags

* Fix out-of-date inline flag reference syntax

* Use new flags in end-to-end tests

* Add flag to disable all default collectors

* Track if a flag has been set explicitly

* Add --collectors.disable-defaults to README

* Revert disable-defaults flag

* Shorten flags

* Fixup timex collector registration

* Fix end-to-end tests

* Change procfs and sysfs path flags

* Fix review comments
2017-09-28 15:06:26 +02:00
Calle Pettersson dfe07eaae8 Switch to kingpin flags (#639)
* Switch to kingpin flags

* Fix logrus vendoring

* Fix flags in main tests

* Fix vendoring versions
2017-08-12 15:07:24 +02:00
Tobias Schmidt 084e585c2a Fix scanner usage without error handling 2017-02-28 16:04:25 -04:00
Tobias Schmidt 195b4d596c Merge pull request #480 from prometheus/grobie/gosimple
Simplify go code
2017-02-28 13:59:01 -04:00
Tobias Schmidt 694294baf5 Remove unnecessary conversions 2017-02-28 13:57:49 -04:00
Tobias Schmidt c703435790 Fix all open go lint and vet issues 2017-02-28 13:05:38 -04:00
Johannes 'fish' Ziemke 8e50b80d12 Convert remaining collectors to use ConstMetrics 2017-01-03 14:11:10 +01:00
Daniel a7a8d088da Ignore partitions on NVME devices by default
The convention of the linux driver is nvme($device)n($namespace)p($partition). On *bsd it seems to be different, using "ns" instead of "n" as the namespace separator.
2016-07-09 13:23:01 +02:00
Carlos Amedee 8578a3281a fix a small typo in an error message. 2016-02-09 23:22:29 -05:00
Peter Fern 09e610ad37 Calculate Linux disk bytes read/written based on sector size (512B)
Logical sector size appears to be fixed at 512B for the foreseeable
future in the kernel, so for now we just hard-code it.
2015-12-27 22:00:02 +11:00
Nick Owens eb79937340 switch to github.com/prometheus/common/log for logging 2015-10-30 13:20:06 -07:00
Matthias Rampke 2d0d72b97d Add license headers to all code files. 2015-09-26 17:44:39 +02:00
Matthias Rampke 20b551ab2b Add flag to change the location of the procfs.
Remove all hardcoded references to `/proc`. For all collectors that do
not use `github.com/prometheus/procfs` yet, provide a wrapper to
generate the full paths.

Reformulate help strings, errors and comments to remove absolute
references to `/proc`.

This is a breaking change: the `-collector.ipvs.procfs` flag is removed
in favor of the general flag. Since it only affected that collector it
was only useful for development, so this should not cause many issues.
2015-09-26 15:32:10 +02:00
Siavash Safi 66e0171159 Rename linux collectors for build constraints. 2015-07-14 13:58:45 +04:30
Renamed from collector/diskstats.go (Browse further)