[main] Adding `prometheus-node-exporter` and `prometheus-process-exporter`. (#2063)

This commit is contained in:
Pawel Winogrodzki 2022-02-02 10:15:54 -08:00 committed by GitHub
parent 6a6794f54c
commit a82a2ecbee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 876 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@ -21,6 +21,12 @@
"ceph"
]
},
"Debian": {
"license": "[MIT](https://opensource.org/licenses/MIT)",
"specs": [
"prometheus-process-exporter"
]
},
"Fedora": {
"license": "[Fedora MIT License Declaration](https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#License_of_Fedora_SPEC_Files)",
"specs": [
@ -1695,6 +1701,7 @@
"procmail",
"prometheus",
"prometheus-jmx-exporter",
"prometheus-node-exporter",
"prometheus-simpleclient-java",
"protobuf-java",
"ps_mem",

View File

@ -0,0 +1,156 @@
From 93651c6d7963d8651cc092021a3f60e8f96d78ab Mon Sep 17 00:00:00 2001
From: Daniel Hodges <hodges.daniel.scott@gmail.com>
Date: Sun, 31 Oct 2021 20:00:31 -0400
Subject: [PATCH] Refactor perf collector to better handle failures and warn on
open file limits
Origin: https://github.com/prometheus/node_exporter/pull/2190
Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
---
collector/perf_linux.go | 46 ++++++++++++++++++++---------------------
go.mod | 2 +-
go.sum | 6 +++---
3 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/collector/perf_linux.go b/collector/perf_linux.go
index 768835230..dbe578a6e 100644
--- a/collector/perf_linux.go
+++ b/collector/perf_linux.go
@@ -161,8 +161,8 @@ func (c *perfTracepointCollector) update(ch chan<- prometheus.Metric) error {
// updateCPU is used to update metrics per CPU profiler.
func (c *perfTracepointCollector) updateCPU(cpu int, ch chan<- prometheus.Metric) error {
profiler := c.profilers[cpu]
- p, err := profiler.Profile()
- if err != nil {
+ p := &perf.GroupProfileValue{}
+ if err := profiler.Profile(p); err != nil {
level.Error(c.logger).Log("msg", "Failed to collect tracepoint profile", "err", err)
return err
}
@@ -286,8 +286,12 @@ func NewPerfCollector(logger log.Logger) (Collector, error) {
for _, cpu := range cpus {
// Use -1 to profile all processes on the CPU, see:
// man perf_event_open
- hwProf, err := perf.NewHardwareProfiler(-1, cpu)
- if err != nil {
+ hwProf, err := perf.NewHardwareProfiler(
+ -1,
+ cpu,
+ perf.AllHardwareProfilers,
+ )
+ if err != nil && !hwProf.HasProfilers() {
return nil, err
}
if err := hwProf.Start(); err != nil {
@@ -296,8 +300,8 @@ func NewPerfCollector(logger log.Logger) (Collector, error) {
collector.perfHwProfilers[cpu] = &hwProf
collector.hwProfilerCPUMap[&hwProf] = cpu
- swProf, err := perf.NewSoftwareProfiler(-1, cpu)
- if err != nil {
+ swProf, err := perf.NewSoftwareProfiler(-1, cpu, perf.AllSoftwareProfilers)
+ if err != nil && !swProf.HasProfilers() {
return nil, err
}
if err := swProf.Start(); err != nil {
@@ -306,8 +310,13 @@ func NewPerfCollector(logger log.Logger) (Collector, error) {
collector.perfSwProfilers[cpu] = &swProf
collector.swProfilerCPUMap[&swProf] = cpu
- cacheProf, err := perf.NewCacheProfiler(-1, cpu)
- if err != nil {
+ cacheProfilers := perf.L1DataReadHitProfiler & perf.L1DataReadMissProfiler & perf.L1DataWriteHitProfiler & perf.L1InstrReadMissProfiler & perf.InstrTLBReadHitProfiler & perf.InstrTLBReadMissProfiler & perf.LLReadHitProfiler & perf.LLReadMissProfiler & perf.LLWriteHitProfiler & perf.LLWriteMissProfiler & perf.BPUReadHitProfiler & perf.BPUReadMissProfiler
+ cacheProf, err := perf.NewCacheProfiler(
+ -1,
+ cpu,
+ cacheProfilers,
+ )
+ if err != nil && !cacheProf.HasProfilers() {
return nil, err
}
if err := cacheProf.Start(); err != nil {
@@ -585,13 +594,10 @@ func (c *perfCollector) Update(ch chan<- prometheus.Metric) error {
func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
for _, profiler := range c.perfHwProfilers {
- hwProfile, err := (*profiler).Profile()
- if err != nil {
+ hwProfile := &perf.HardwareProfile{}
+ if err := (*profiler).Profile(hwProfile); err != nil {
return err
}
- if hwProfile == nil {
- continue
- }
cpuid := strconv.Itoa(c.hwProfilerCPUMap[profiler])
@@ -657,13 +663,10 @@ func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
for _, profiler := range c.perfSwProfilers {
- swProfile, err := (*profiler).Profile()
- if err != nil {
+ swProfile := &perf.SoftwareProfile{}
+ if err := (*profiler).Profile(swProfile); err != nil {
return err
}
- if swProfile == nil {
- continue
- }
cpuid := strconv.Itoa(c.swProfilerCPUMap[profiler])
@@ -713,13 +716,10 @@ func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
func (c *perfCollector) updateCacheStats(ch chan<- prometheus.Metric) error {
for _, profiler := range c.perfCacheProfilers {
- cacheProfile, err := (*profiler).Profile()
- if err != nil {
+ cacheProfile := &perf.CacheProfile{}
+ if err := (*profiler).Profile(cacheProfile); err != nil {
return err
}
- if cacheProfile == nil {
- continue
- }
cpuid := strconv.Itoa(c.cacheProfilerCPUMap[profiler])
diff --git a/go.mod b/go.mod
index eabe17802..1ac152633 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@ require (
github.com/go-kit/log v0.2.0
github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968
github.com/hashicorp/go-envparse v0.0.0-20200406174449-d9cfd743a15e
- github.com/hodgesds/perf-utils v0.4.0
+ github.com/hodgesds/perf-utils v0.5.1
github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973
github.com/jsimonetti/rtnetlink v0.0.0-20211022192332-93da33804786
github.com/lufia/iostat v1.2.0
diff --git a/go.sum b/go.sum
index 84ae5c12d..440a0e5e9 100644
--- a/go.sum
+++ b/go.sum
@@ -144,8 +144,8 @@ github.com/hashicorp/go-envparse v0.0.0-20200406174449-d9cfd743a15e h1:v1d9+AJMP
github.com/hashicorp/go-envparse v0.0.0-20200406174449-d9cfd743a15e/go.mod h1:/NlxCzN2D4C4L2uDE6ux/h6jM+n98VFQM14nnCIfHJU=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hodgesds/perf-utils v0.4.0 h1:onWrAGy6RYr7938qNXtSsTr54K4BLx8Hh3EXAr+xy+U=
-github.com/hodgesds/perf-utils v0.4.0/go.mod h1:wpXb8IDP3gn1iCsHuql0e9fyARRjRPvxN7lRPDihOds=
+github.com/hodgesds/perf-utils v0.5.1 h1:Dlk4yYRQAzLnqiFqvwKj9+a1XysINFuHmRfcIduuXxo=
+github.com/hodgesds/perf-utils v0.5.1/go.mod h1:LAklqfDadNKpkxoAJNHpD5tkY0rkZEVdnCEWN5k4QJY=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 h1:hk4LPqXIY/c9XzRbe7dA6qQxaT6Axcbny0L/G5a4owQ=
github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973/go.mod h1:PoK3ejP3LJkGTzKqRlpvCIFas3ncU02v8zzWDW+g0FY=
@@ -416,7 +416,7 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 h1:kwrAHlwJ0DUBZwQ238v+Uod/3eZ8B2K5rYsUHBQvzmI=
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

View File

@ -0,0 +1,22 @@
Description: Change default paths to match Debian packaging
Forwarded: not-needed
Author: Martina Ferrari <tina@debian.org>
Last-Update: 2019-10-29
---
collector/textfile.go | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/collector/textfile.go b/collector/textfile.go
index 469235dc..12353ffd 100644
--- a/collector/textfile.go
+++ b/collector/textfile.go
@@ -34,7 +34,7 @@ import (
)
var (
- textFileDirectory = kingpin.Flag("collector.textfile.directory", "Directory to read text files with metrics from.").Default("").String()
+ textFileDirectory = kingpin.Flag("collector.textfile.directory", "Directory to read text files with metrics from.").Default("/var/lib/prometheus/node-exporter").String()
mtimeDesc = prometheus.NewDesc(
"node_textfile_mtime_seconds",
"Unixtime mtime of textfiles successfully read.",

View File

@ -0,0 +1,244 @@
# Set the command-line arguments to pass to the server.
# Due to shell scaping, to pass backslashes for regexes, you need to double
# them (\\d for \d). If running under systemd, you need to double them again
# (\\\\d to mean \d), and escape newlines too.
ARGS=''
# prometheus-node-exporter supports the following options:
#
# --collector.arp
# Enable the arp collector (default: enabled).
# --collector.bcache
# Enable the bcache collector (default: enabled).
# --collector.bcache.priorityStats
# Expose expensive priority stats.
# --collector.bonding
# Enable the bonding collector (default: enabled).
# --collector.btrfs
# Enable the btrfs collector (default: enabled).
# --collector.buddyinfo
# Enable the buddyinfo collector (default: disabled).
# --collector.conntrack
# Enable the conntrack collector (default: enabled).
# --collector.cpu
# Enable the cpu collector (default: enabled).
# --collector.cpu.guest
# Enables metric node_cpu_guest_seconds_total.
# --collector.cpu.info
# Enables metric cpu_info.
# --collector.cpu.info.bugs-include=COLLECTOR.CPU.INFO.BUGS-INCLUDE
# Filter the `bugs` field in cpuInfo with a value that must be a regular
# expression.
# --collector.cpu.info.flags-include=COLLECTOR.CPU.INFO.FLAGS-INCLUDE
# Filter the `flags` field in cpuInfo with a value that must be a regular
# expression.
# --collector.cpufreq
# Enable the cpufreq collector (default: enabled).
# --collector.disable-defaults
# Set all collectors to disabled by default.
# --collector.diskstats
# Enable the diskstats collector (default: enabled).
# --collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$"
# Regexp of devices to ignore for diskstats.
# --collector.dmi
# Enable the dmi collector (default: enabled).
# --collector.drbd
# Enable the drbd collector (default: disabled).
# --collector.drm
# Enable the drm collector (default: disabled).
# --collector.edac
# Enable the edac collector (default: enabled).
# --collector.entropy
# Enable the entropy collector (default: enabled).
# --collector.ethtool
# Enable the ethtool collector (default: disabled).
# --collector.ethtool.device-exclude=COLLECTOR.ETHTOOL.DEVICE-EXCLUDE
# Regexp of ethtool devices to exclude (mutually exclusive to device-include).
# --collector.ethtool.device-include=COLLECTOR.ETHTOOL.DEVICE-INCLUDE
# Regexp of ethtool devices to include (mutually exclusive to device-exclude).
# --collector.ethtool.metrics-include=".*"
# Regexp of ethtool stats to include.
# --collector.fibrechannel
# Enable the fibrechannel collector (default: enabled).
# --collector.filefd
# Enable the filefd collector (default: enabled).
# --collector.filesystem
# Enable the filesystem collector (default: enabled).
# --collector.filesystem.fs-types-exclude="^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
# Regexp of filesystem types to exclude for filesystem collector.
# --collector.filesystem.mount-points-exclude="^/(dev|proc|run|sys|mnt|media|var/lib/docker/.+)($|/)"
# Regexp of mount points to exclude for filesystem collector.
# --collector.hwmon
# Enable the hwmon collector (default: enabled).
# --collector.infiniband
# Enable the infiniband collector (default: enabled).
# --collector.interrupts
# Enable the interrupts collector (default: disabled).
# --collector.ipvs
# Enable the ipvs collector (default: enabled).
# --collector.ipvs.backend-labels="local_address,local_port,remote_address,remote_port,proto,local_mark"
# Comma separated list for IPVS backend stats labels.
# --collector.ksmd
# Enable the ksmd collector (default: disabled).
# --collector.lnstat
# Enable the lnstat collector (default: disabled).
# --collector.loadavg
# Enable the loadavg collector (default: enabled).
# --collector.logind
# Enable the logind collector (default: disabled).
# --collector.mdadm
# Enable the mdadm collector (default: enabled).
# --collector.meminfo
# Enable the meminfo collector (default: enabled).
# --collector.meminfo_numa
# Enable the meminfo_numa collector (default: disabled).
# --collector.mountstats
# Enable the mountstats collector (default: disabled).
# --collector.netclass
# Enable the netclass collector (default: enabled).
# --collector.netclass.ignored-devices="^$"
# Regexp of net devices to ignore for netclass collector.
# --collector.netclass.ignore-invalid-speed
# Ignore devices where the speed is invalid. This will be the default behavior in 2.x.
# --collector.netdev
# Enable the netdev collector (default: enabled).
# --collector.netdev.address-info
# Collect address-info for every device.
# --collector.netdev.device-exclude="^lo$"
# Regexp of net devices to exclude (mutually exclusive to device-include).
# --collector.netdev.device-include=COLLECTOR.NETDEV.DEVICE-INCLUDE
# Regexp of net devices to include (mutually exclusive to device-exclude).
# --collector.netstat
# Enable the netstat collector (default: enabled).
# --collector.netstat.fields="^(.*_(InErrors|InErrs)|Ip_Forwarding|Ip(6|Ext)_(InOctets|OutOctets)|Icmp6?_(InMsgs|OutMsgs)|TcpExt_(Listen.*|Syncookies.*|TCPSynRetrans|TCPTimeouts)|Tcp_(ActiveOpens|InSegs|OutSegs|OutRsts|PassiveOpens|RetransSegs|CurrEstab)|Udp6?_(InDatagrams|OutDatagrams|NoPorts|RcvbufErrors|SndbufErrors))$"
# Regexp of fields to return for netstat collector.
# --collector.network_route
# Enable the network_route collector (default: disabled).
# --collector.nfs
# Enable the nfs collector (default: enabled).
# --collector.nfsd
# Enable the nfsd collector (default: enabled).
# --collector.ntp
# Enable the ntp collector (default: disabled).
# --collector.ntp.ip-ttl=1
# IP TTL to use while sending NTP query.
# --collector.ntp.local-offset-tolerance=1ms
# Offset between local clock and local ntpd time to tolerate.
# --collector.ntp.max-distance=3.46608s
# Max accumulated distance to the root.
# --collector.ntp.protocol-version=4
# NTP protocol version.
# --collector.ntp.server-is-local
# Certify that collector.ntp.server address is not a public ntp server.
# --collector.ntp.server="127.0.0.1"
# NTP server to use for ntp collector.
# --collector.nvme
# Enable the nvme collector (default: enabled).
# --collector.os
# Enable the os collector (default: enabled).
# --collector.perf
# Enable the perf collector (default: disabled).
# --collector.perf.cpus=""
# List of CPUs from which perf metrics should be collected.
# --collector.perf.tracepoint=COLLECTOR.PERF.TRACEPOINT...
# Perf tracepoint that should be collected.
# --collector.powersupply.ignored-supplies="^$"
# Regexp of power supplies to ignore for powersupplyclass collector.
# --collector.powersupplyclass
# Enable the powersupplyclass collector (default: enabled).
# --collector.pressure
# Enable the pressure collector (default: enabled).
# --collector.processes
# Enable the processes collector (default: disabled).
# --collector.qdisc
# Enable the qdisc collector (default: disabled).
# --collector.qdisc.fixtures=""
# Test fixtures to use for qdisc collector end-to-end testing.
# --collector.rapl
# Enable the rapl collector (default: enabled).
# --collector.runit
# Enable the runit collector (default: disabled).
# --collector.runit.servicedir="/etc/service"
# Path to runit service directory.
# --collector.schedstat
# Enable the schedstat collector (default: enabled).
# --collector.sockstat
# Enable the sockstat collector (default: enabled).
# --collector.softnet
# Enable the softnet collector (default: enabled).
# --collector.stat
# Enable the stat collector (default: enabled).
# --collector.supervisord
# Enable the supervisord collector (default: disabled).
# --collector.supervisord.url="http://localhost:9001/RPC2"
# XML RPC endpoint.
# --collector.systemd
# Enable the systemd collector (default: enabled).
# --collector.systemd.enable-restarts-metrics
# Enables service unit metric service_restart_total.
# --collector.systemd.enable-start-time-metrics
# Enables service unit metric unit_start_time_seconds.
# --collector.systemd.enable-task-metrics
# Enables service unit tasks metrics unit_tasks_current and unit_tasks_max.
# --collector.systemd.unit-exclude=".+\\.(automount|device|mount|scope|slice|target)"
# Regexp of systemd units to exclude. Units must both match include and not
# match exclude to be included.
# --collector.systemd.unit-include=".+"
# Regexp of systemd units to include. Units must both match include and not
# match exclude to be included.
# --collector.tapestats
# Enable the tapestats collector (default: enabled).
# --collector.tapestats.ignored-devices="^$"
# Regexp of devices to ignore for tapestats.
# --collector.tcpstat
# Enable the tcpstat collector (default: disabled).
# --collector.textfile
# Enable the textfile collector (default: enabled).
# --collector.textfile.directory="/var/lib/prometheus/node-exporter"
# Directory to read text files with metrics from.
# --collector.thermal_zone
# Enable the thermal_zone collector (default: enabled).
# --collector.time
# Enable the time collector (default: enabled).
# --collector.timex
# Enable the timex collector (default: enabled).
# --collector.udp_queues
# Enable the udp_queues collector (default: enabled).
# --collector.uname
# Enable the uname collector (default: enabled).
# --collector.vmstat
# Enable the vmstat collector (default: enabled).
# --collector.vmstat.fields="^(oom_kill|pgpg|pswp|pg.*fault).*"
# Regexp of fields to return for vmstat collector.
# --collector.wifi
# Enable the wifi collector (default: disabled).
# --collector.wifi.fixtures=""
# Test fixtures to use for wifi collector metrics.
# --collector.xfs
# Enable the xfs collector (default: enabled).
# --collector.zfs
# Enable the zfs collector (default: enabled).
# --collector.zoneinfo
# Enable the zoneinfo collector (default: disabled).
# --log.format=logfmt
# Output format of log messages. One of: [logfmt, json].
# --log.level=info
# Only log messages with the given severity or above. One of: [debug, info,
# warn, error].
# --path.procfs="/proc"
# Procfs mountpoint.
# --path.rootfs="/"
# Rootfs mountpoint.
# --path.sysfs="/sys"
# Sysfs mountpoint.
# --web.config=""
# [EXPERIMENTAL] Path to config yaml file that can enable TLS or
# authentication.
# --web.disable-exporter-metrics
# Exclude metrics about the exporter itself (promhttp_*, process_*, go_*).
# --web.listen-address=":9100"
# Address on which to expose metrics and web interface.
# --web.max-requests=40
# Maximum number of parallel scrape requests. Use 0 to disable.
# --web.telemetry-path="/metrics"
# Path under which to expose metrics.

View File

@ -0,0 +1,9 @@
/var/log/prometheus/prometheus-node-exporter.log {
weekly
rotate 10
copytruncate
compress
delaycompress
notifempty
missingok
}

View File

@ -0,0 +1,17 @@
[Unit]
Description=Prometheus exporter for machine metrics
Documentation=https://github.com/prometheus/node_exporter
Requires=network-online.target
After=network-online.target
[Service]
Restart=on-failure
User=prometheus
EnvironmentFile=/etc/default/prometheus-node-exporter
ExecStart=/usr/bin/prometheus-node-exporter $ARGS
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,10 @@
{
"Signatures": {
"prometheus-node-exporter-1.3.1-vendor.tar.gz": "e4236b8506ba36c182b6ffba09fde5056969e5407b9fdf4e9a15f8bfad3ae5e8",
"prometheus-node-exporter-1.3.1.tar.gz": "66856b6b8953e094c46d7dd5aabd32801375cf4d13d9fe388e320cbaeaff573a",
"prometheus-node-exporter.conf": "af398945dffd2cf49225accf3d6ec0a0161d61906328b82a2f473deda073667a",
"prometheus-node-exporter.logrotate": "ee082283a512e75bbfa365e7e60eba0903ac8082962c96108e53ccfe8afc7b2b",
"prometheus-node-exporter.service": "351a6bf987a56993deca6e57493fcc235c3abef56ed2749153fdba4d2fa0faf6",
"prometheus-node-exporter.sysusers": "bbbfc96aed1bf0a4268f3d21c1f8982c222ccd4e817074599495f24c999d6557"
}
}

View File

@ -0,0 +1,139 @@
%global build_date $(date +"%%Y%%m%%d-%%T")
%global debug_package %{nil}
%global go_version %(go version | sed -E "s/go version go(\\S+).*/\\1/")
Summary: Exporter for machine metrics
Name: prometheus-node-exporter
Version: 1.3.1
Release: 6%{?dist}
# Upstream license specification: Apache-2.0
License: ASL 2.0 AND MIT
Vendor: Microsoft Corporation
Distribution: Mariner
URL: https://github.com/prometheus/node_exporter
Source0: https://github.com/prometheus/node_exporter/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# Below is a manually created tarball, no download link.
# We're using vendored Go modules from this tarball, since network is disabled during build time.
# How to re-build this file:
# 1. wget https://github.com/prometheus/node_exporter/archive/refs/tags/v%{version}.tar.gz -O %%{name}-%%{version}.tar.gz
# 2. tar -xf %%{name}-%%{version}.tar.gz
# 3. cd %%{name}-%%{version}
# 4. Apply patches from the spec (may change go dependencies).
# 5. go mod vendor
# 6. tar --sort=name \
# --mtime="2021-04-26 00:00Z" \
# --owner=0 --group=0 --numeric-owner \
# --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
# -cf %%{name}-%%{version}-vendor.tar.gz vendor
#
Source1: %{name}-%{version}-vendor.tar.gz
Source2: %{name}.sysusers
Source3: %{name}.service
Source4: %{name}.conf
Source5: %{name}.logrotate
# Replace defaults paths for config files
Patch0: defaults-paths.patch
# https://github.com/prometheus/node_exporter/pull/2190
Patch1: 0001-Refactor-perf-collector.patch
BuildRequires: golang
BuildRequires: systemd-rpm-macros
Requires(pre): shadow-utils
%description
Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written
in Go with pluggable metric collectors.
%prep
%autosetup -p1 -n node_exporter-%{version}
rm -rf vendor
tar -xf %{SOURCE1} --no-same-owner
%build
export BUILDTAGS="netgo osusergo static_build"
LDFLAGS="-X github.com/prometheus/common/version.Version=%{version} \
-X github.com/prometheus/common/version.Revision=%{release} \
-X github.com/prometheus/common/version.Branch=tarball \
-X github.com/prometheus/common/version.BuildDate=%{build_date} \
-X github.com/ncabatoff/process-exporter/version.GoVersion=%{go_version}"
go build -ldflags "$LDFLAGS" -mod=vendor -v -a -tags "$BUILDTAGS" -o bin/node_exporter ./collector
%install
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp bin/* %{buildroot}%{_bindir}/
mv %{buildroot}%{_bindir}/node_exporter %{buildroot}%{_bindir}/%{name}
ln -s %{name} %{buildroot}%{_bindir}/node_exporter
install -Dpm0644 %{SOURCE2} %{buildroot}%{_sysusersdir}/%{name}.conf
install -Dpm0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service
install -Dpm0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/default/%{name}
install -Dpm0644 example-rules.yml %{buildroot}%{_datadir}/prometheus/node-exporter/example-rules.yml
install -Dpm0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
mkdir -vp %{buildroot}%{_sharedstatedir}/prometheus/node-exporter
%check
make test
%pre
# Steps extracted from Fedora's /usr/lib/rpm/sysusers.generate-pre.sh script.
# The script and the RPM macro 'sysusers_create_compat' calling it are not available
# in Mariner's 'systemd-rpm-macros' package.
# Input file for the script was %%{SOURCE2}.
getent group 'prometheus' >/dev/null || groupadd -r 'prometheus'
getent passwd 'prometheus' >/dev/null || useradd -r -g 'prometheus' -d '%{_sharedstatedir}/prometheus' -s '%{_sbindir}/nologin' -c 'Prometheus user account' 'prometheus'
%post
%systemd_post %{name}.service
%preun
%systemd_preun %{name}.service
%postun
%systemd_postun_with_restart %{name}.service
%files
%license LICENSE NOTICE
%doc docs examples CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md
%doc MAINTAINERS.md SECURITY.md README.md
%config(noreplace) %{_sysconfdir}/default/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_bindir}/*
%{_sysusersdir}/%{name}.conf
%{_unitdir}/%{name}.service
%{_datadir}/prometheus/node-exporter/example-rules.yml
%dir %attr(0755,prometheus,prometheus) %{_sharedstatedir}/prometheus
%dir %attr(0755,prometheus,prometheus) %{_sharedstatedir}/prometheus/node-exporter
%changelog
* Mon Jan 31 2022 Pawel Winogrodzki <pawelwi@microsoft.com> - 1.3.1-6
- Initial CBL-Mariner import from Fedora 36 (license: MIT).
- License verified.
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> 1.3.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Sun Jan 16 2022 Robert-André Mauchin <zebob.m@gmail.com> 1.3.1-4
- Add logrotate file
* Sat Jan 15 2022 Robert-André Mauchin <zebob.m@gmail.com> 1.3.1-3
- Add LDFLAGS
* Fri Jan 14 2022 Robert-André Mauchin <zebob.m@gmail.com> 1.3.1-2
- Fix home directory permissions
* Fri Jan 14 2022 Robert-André Mauchin <zebob.m@gmail.com> 1.3.1-1
- Update to 1.3.1 Close: rhbz#2024811 Close: rhbz#2039257
* Thu Aug 12 2021 Robert-André Mauchin <zebob.m@gmail.com> 1.2.2-1
- Update to 1.2.2 Close: rhbz#1945422
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Sun Mar 28 18:14:35 CEST 2021 Robert-André Mauchin <zebob.m@gmail.com> - 1.1.1-2
- Fix binary location
* Wed Feb 17 22:48:22 CET 2021 Robert-André Mauchin <zebob.m@gmail.com> - 1.1.1-1
- Initial package

View File

@ -0,0 +1,2 @@
#Type Name ID GECOS Home directory Shell
u prometheus - "Prometheus user account" /var/lib/prometheus /sbin/nologin

View File

@ -0,0 +1,20 @@
Description: Fix TestReadFixture on non 4K page size arches
TestReadFixture checks fixtures/14804/stat RSS which is a number of page
and compares it to hardcoded expected value 0x7b1000 (= 1969 * 4096).
Instead of using a 4k expected value, use system's pagesize like it's
done in proc_stat.go .
Author: Frédéric Bonnard <frediz@debian.org>
Forwarded: no
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/proc/read_test.go
+++ b/proc/read_test.go
@@ -83,7 +83,7 @@
CtxSwitchNonvoluntary: 6,
},
Memory: Memory{
- ResidentBytes: 0x7b1000,
+ ResidentBytes: uint64(0x7b1 * os.Getpagesize()),
VirtualBytes: 0x1061000,
VmSwapBytes: 0x2800,
},

View File

@ -0,0 +1,48 @@
Description: Disable once-to-stdout-delay command flag
This flag would require vendoring / patching in another insignificant package,
so instead we simply disable it for now.
Author: Daniel Swarbrick <daniel.swarbrick@cloud.ionos.com>
Forwarded: not-needed
---
cmd/process-exporter/main.go | 15 ---------------
1 file changed, 15 deletions(-)
--- a/cmd/process-exporter/main.go
+++ b/cmd/process-exporter/main.go
@@ -9,9 +9,7 @@ import (
"os"
"regexp"
"strings"
- "time"
- "github.com/ncabatoff/fakescraper"
common "github.com/ncabatoff/process-exporter"
"github.com/ncabatoff/process-exporter/collector"
"github.com/ncabatoff/process-exporter/config"
@@ -150,8 +148,6 @@ func main() {
"Address on which to expose metrics and web interface.")
metricsPath = flag.String("web.telemetry-path", "/metrics",
"Path under which to expose metrics.")
- onceToStdoutDelay = flag.Duration("once-to-stdout-delay", 0,
- "Don't bind, just wait this much time, print the metrics once to stdout, and exit")
procNames = flag.String("procnames", "",
"comma-separated list of process names to monitor")
procfsPath = flag.String("procfs", "/proc",
@@ -248,17 +244,6 @@ func main() {
prometheus.MustRegister(pc)
- if *onceToStdoutDelay != 0 {
- // We throw away the first result because that first collection primes the pump, and
- // otherwise we won't see our counter metrics. This is specific to the implementation
- // of NamedProcessCollector.Collect().
- fscraper := fakescraper.NewFakeScraper()
- fscraper.Scrape()
- time.Sleep(*onceToStdoutDelay)
- fmt.Print(fscraper.Scrape())
- return
- }
-
http.Handle(*metricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

View File

@ -0,0 +1,35 @@
# Set the command-line arguments to pass to the server.
# Due to shell escaping, to pass backslashes for regexes, you need to double
# them (\\d for \d). If running under systemd, you need to double them again
# (\\\\d to mean \d), and escape newlines too.
ARGS=""
# prometheus-process-exporter supports the following options:
#
# -children
# If a proc is tracked, track with it any children that aren't part of their
# own group (default true).
# -config.path string
# Path to YAML config file.
# -debug
# Log debugging information to stdout.
# -gather-smaps
# Gather metrics from smaps file, which contains proportional resident
# memory size (default true).
# -namemapping string
# Comma-separated list, alternating process name and capturing regex to
# apply to cmdline.
# -procfs string
# Path to read proc data from (default "/proc").
# -procnames string
# Comma-separated list of process names to monitor.
# -recheck
# Recheck process names on each scrape.
# -threads
# Report on per-threadname metrics as well (default true).
# -web.config.file string
# Path to YAML web config file.
# -web.listen-address string
# Address on which to expose metrics and web interface. (default ":9256").
# -web.telemetry-path string
# Path under which to expose metrics. (default "/metrics").

View File

@ -0,0 +1,10 @@
/var/log/prometheus/prometheus-process-exporter.log {
weekly
rotate 10
copytruncate
compress
delaycompress
notifempty
missingok
}

View File

@ -0,0 +1,13 @@
[Unit]
Description=Prometheus exporter that mines /proc to report on selected processes
Documentation=https://github.com/ncabatoff/process-exporter man:prometheus-process-exporter(1)
After=network.target
[Service]
Restart=on-failure
User=prometheus
EnvironmentFile=/etc/default/prometheus-process-exporter
ExecStart=/usr/bin/prometheus-process-exporter $ARGS
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,9 @@
{
"Signatures": {
"prometheus-process-exporter-0.7.10-vendor.tar.gz": "79736beba1ac3f216763b3672ed1f769becb40dc8e0e5c3283b40d162d0601c8",
"prometheus-process-exporter-0.7.10.tar.gz": "197a950879f90d36e3979ab412c60ec35eec5942451a0105e070a670474d730a",
"prometheus-process-exporter.conf": "ef9dc718b103fee1bcb31c721478164318aba1692eaabdb3ea2df49e43caa7cd",
"prometheus-process-exporter.logrotate": "3a0a2225dacc04968b74b67ae9dc5c273a4d9bdaa358396b322b7093e873f612",
"prometheus-process-exporter.service": "12e5011db5c1b66926a66e7506bd039b6d7ca7ebc72e685cedf5783299adf6bd"
}
}

View File

@ -0,0 +1,102 @@
%global build_date $(date +"%%Y%%m%%d-%%T")
%global debug_package %{nil}
%global go_version %(go version | sed -E "s/go version go(\\S+).*/\\1/")
Summary: Prometheus exporter exposing process metrics from procfs
Name: prometheus-process-exporter
Version: 0.7.10
Release: 1%{?dist}
License: MIT
Vendor: Microsoft Corporation
Distribution: Mariner
URL: https://github.com/ncabatoff/process-exporter
Source0: https://github.com/ncabatoff/process-exporter/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# Below is a manually created tarball, no download link.
# We're using vendored Go modules from this tarball, since network is disabled during build time.
# How to re-build this file:
# 1. wget https://github.com/ncabatoff/process-exporter/archive/refs/tags/v%%{version}.tar.gz -O %%{name}-%%{version}.tar.gz
# 2. tar -xf %%{name}-%%{version}.tar.gz
# 3. cd %%{name}-%%{version}
# 4. go mod vendor
# 5. tar --sort=name \
# --mtime="2021-04-26 00:00Z" \
# --owner=0 --group=0 --numeric-owner \
# --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
# -cf %%{name}-%%{version}-vendor.tar.gz vendor
#
Source1: %{name}-%{version}-vendor.tar.gz
Source2: %{name}.service
Source3: %{name}.logrotate
Source4: %{name}.conf
Patch0: 01-fix-RSS-test-on-non4K-pagesize-systems.patch
Patch1: 03-disable-fakescraper.patch
BuildRequires: golang
BuildRequires: systemd-rpm-macros
Requires(pre): shadow-utils
%description
Prometheus exporter that exposes process metrics from procfs.
Some apps are impractical to instrument directly, either because you don't
control the code or they're written in a language that isn't easy to
instrument with Prometheus. This exporter solves that issue by mining
process metrics from procfs.
%prep
%autosetup -p1 -n process-exporter-%{version}
rm -rf vendor
tar -xf %{SOURCE1} --no-same-owner
%build
LDFLAGS="-X github.com/ncabatoff/process-exporter/version.Version=%{version} \
-X github.com/ncabatoff/process-exporter/version.Revision=%{release} \
-X github.com/ncabatoff/process-exporter/version.Branch=tarball \
-X github.com/ncabatoff/process-exporter/version.BuildDate=%{build_date} \
-X github.com/ncabatoff/process-exporter/version.GoVersion=%{go_version}"
# Modified "build" target from Makefile.
CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -mod=vendor -v -a -tags netgo -o process-exporter ./cmd/process-exporter
%install
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp process-exporter %{buildroot}%{_bindir}/%{name}
ln -s %{name} %{buildroot}%{_bindir}/process-exporter
install -Dpm0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
install -Dpm0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -Dpm0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/default/%{name}
mkdir -vp %{buildroot}%{_sharedstatedir}/prometheus
%check
make test integ
%pre
# Same user/group creation steps as for "prometheus-node-exporter".
getent group 'prometheus' >/dev/null || groupadd -r 'prometheus'
getent passwd 'prometheus' >/dev/null || useradd -r -g 'prometheus' -d '%{_sharedstatedir}/prometheus' -s '%{_sbindir}/nologin' -c 'Prometheus user account' 'prometheus'
%post
%systemd_post %{name}.service
%preun
%systemd_preun %{name}.service
%postun
%systemd_postun_with_restart %{name}.service
%files
%license LICENSE
%config(noreplace) %{_sysconfdir}/default/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_bindir}/*process-exporter
%{_unitdir}/%{name}.service
%dir %attr(0755,prometheus,prometheus) %{_sharedstatedir}/prometheus
%changelog
* Tue Feb 01 2022 Pawel Winogrodzki <pawelwi@microsoft.com> - 0.7.10-1
- Initial CBL-Mariner import from Debian source package (license: MIT).
- License verified.

View File

@ -21839,6 +21839,26 @@
}
}
},
{
"component": {
"type": "other",
"other": {
"name": "prometheus-node-exporter",
"version": "1.3.1",
"downloadUrl": "https://github.com/prometheus/node_exporter/archive/refs/tags/v1.3.1.tar.gz"
}
}
},
{
"component": {
"type": "other",
"other": {
"name": "prometheus-process-exporter",
"version": "0.7.10",
"downloadUrl": "https://github.com/ncabatoff/process-exporter/archive/refs/tags/v0.7.10.tar.gz"
}
}
},
{
"component": {
"type": "other",

View File

@ -7,17 +7,18 @@ from pyrpm.spec import Spec
import re
VALID_SOURCE_ATTRIBUTIONS = {
"Microsoft": r'\n-\s+(Original version for CBL-Mariner|Initial CBL-Mariner import from Azure)( \(license: MIT\))?(\.|\n|$)',
"CentOS": r'\n-\s+Initial CBL-Mariner import from CentOS \d+ \(license: MIT\)(\.|\n|$)',
"Ceph source": r'\n-\s+Initial CBL-Mariner import from Ceph source \(license: LGPLv2.1\)(\.|\n|$)',
"Netplan source": r'\n-\s+Initial CBL-Mariner import from Netplan source \(license: GPLv3\)(\.|\n|$)',
"Fedora": r'\n-\s+Initial CBL-Mariner import from Fedora \d+ \(license: MIT\)(\.|\n|$)',
"Microsoft": r'\n-\s+(Original version for CBL-Mariner|Initial CBL-Mariner import from Azure)( \(license: MIT\))?(\.|\n|$)',
"CentOS": r'\n-\s+Initial CBL-Mariner import from CentOS \d+ \(license: MIT\)(\.|\n|$)',
"Ceph source": r'\n-\s+Initial CBL-Mariner import from Ceph source \(license: LGPLv2.1\)(\.|\n|$)',
"Debian": r'\n-\s+Initial CBL-Mariner import from Debian source package \(license: MIT\)(\.|\n|$)',
"Netplan source": r'\n-\s+Initial CBL-Mariner import from Netplan source \(license: GPLv3\)(\.|\n|$)',
"Fedora": r'\n-\s+Initial CBL-Mariner import from Fedora \d+ \(license: MIT\)(\.|\n|$)',
"Fedora (Copyright Remi Collet)": r'\n-\s+Initial CBL-Mariner import from Fedora \d+ \(license: CC-BY-SA\)(\.|\n|$)',
"Magnus Edenhill Open Source": r'\n-\s+Initial CBL-Mariner import from Magnus Edenhill Open Source \(license: BSD\)(\.|\n|$)',
"NVIDIA": r'\n-\s+Initial CBL-Mariner import from NVIDIA \(license: ASL 2\.0\)(\.|\n|$)',
"OpenMamba": r'\n-\s+Initial CBL-Mariner import from OpenMamba(\.|\n|$)',
"OpenSUSE": r'\n-\s+Initial CBL-Mariner import from openSUSE \w+ \(license: same as "License" tag\)(\.|\n|$)',
"Photon": r'\n-\s+Initial CBL-Mariner import from Photon \(license: Apache2\)(\.|\n|$)'
"Magnus Edenhill Open Source": r'\n-\s+Initial CBL-Mariner import from Magnus Edenhill Open Source \(license: BSD\)(\.|\n|$)',
"NVIDIA": r'\n-\s+Initial CBL-Mariner import from NVIDIA \(license: ASL 2\.0\)(\.|\n|$)',
"OpenMamba": r'\n-\s+Initial CBL-Mariner import from OpenMamba(\.|\n|$)',
"OpenSUSE": r'\n-\s+Initial CBL-Mariner import from openSUSE \w+ \(license: same as "License" tag\)(\.|\n|$)',
"Photon": r'\n-\s+Initial CBL-Mariner import from Photon \(license: Apache2\)(\.|\n|$)'
}
KNOWN_SOURCE_ORIGINS = VALID_SOURCE_ATTRIBUTIONS.keys()