Greatly reduce the metrics vmstat returns by default.

Vmstat has over 100 fields, most of which are highly
detailed debug information. Trim this down to only
essential fields by default, configurable by flag.

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
Brian Brazil 2018-03-29 16:34:52 +01:00
parent c8c144587e
commit 499c342fed
4 changed files with 156 additions and 4 deletions

View File

@ -2739,6 +2739,7 @@ node_scrape_collector_success{collector="qdisc"} 1
node_scrape_collector_success{collector="sockstat"} 1
node_scrape_collector_success{collector="stat"} 1
node_scrape_collector_success{collector="textfile"} 1
node_scrape_collector_success{collector="vmstat"} 1
node_scrape_collector_success{collector="wifi"} 1
node_scrape_collector_success{collector="xfs"} 1
node_scrape_collector_success{collector="zfs"} 1
@ -2789,6 +2790,24 @@ node_sockstat_sockets_used 229
# 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
# HELP node_vmstat_pgfault /proc/vmstat information field pgfault.
# TYPE node_vmstat_pgfault untyped
node_vmstat_pgfault 2.320168809e+09
# HELP node_vmstat_pgmajfault /proc/vmstat information field pgmajfault.
# TYPE node_vmstat_pgmajfault untyped
node_vmstat_pgmajfault 507162
# HELP node_vmstat_pgpgin /proc/vmstat information field pgpgin.
# TYPE node_vmstat_pgpgin untyped
node_vmstat_pgpgin 7.344136e+06
# HELP node_vmstat_pgpgout /proc/vmstat information field pgpgout.
# TYPE node_vmstat_pgpgout untyped
node_vmstat_pgpgout 1.541180581e+09
# HELP node_vmstat_pswpin /proc/vmstat information field pswpin.
# TYPE node_vmstat_pswpin untyped
node_vmstat_pswpin 1476
# HELP node_vmstat_pswpout /proc/vmstat information field pswpout.
# TYPE node_vmstat_pswpout untyped
node_vmstat_pswpout 35045
# 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

View File

@ -0,0 +1,119 @@
nr_free_pages 977769
nr_alloc_batch 4158
nr_inactive_anon 125031
nr_active_anon 622512
nr_inactive_file 92317
nr_active_file 324014
nr_unevictable 12
nr_mlock 12
nr_anon_pages 713633
nr_mapped 118021
nr_file_pages 450840
nr_dirty 21
nr_writeback 0
nr_slab_reclaimable 85763
nr_slab_unreclaimable 431112
nr_page_table_pages 12504
nr_kernel_stack 1156
nr_overhead 4956
nr_unstable 0
nr_bounce 0
nr_vmscan_write 35050
nr_vmscan_immediate_reclaim 27
nr_writeback_temp 0
nr_isolated_anon 0
nr_isolated_file 0
nr_shmem 20623
nr_dirtied 11127183
nr_written 11122061
nr_pages_scanned 0
numa_hit 2601972389
numa_miss 0
numa_foreign 0
numa_interleave 32353
numa_local 2601972389
numa_other 0
workingset_refault 157066
workingset_activate 104270
workingset_nodereclaim 0
nr_anon_transparent_hugepages 556
nr_free_cma 0
nr_dirty_threshold 270390
nr_dirty_background_threshold 135030
pgpgin 7344136
pgpgout 1541180581
pswpin 1476
pswpout 35045
pgalloc_dma 12
pgalloc_dma32 611781566
pgalloc_normal 2287227526
pgalloc_movable 0
pgfree 2938719870
pgactivate 152952989
pgdeactivate 898450
pgfault 2320168809
pgmajfault 507162
pgrefill_dma 0
pgrefill_dma32 186367
pgrefill_normal 603970
pgrefill_movable 0
pgsteal_kswapd_dma 0
pgsteal_kswapd_dma32 78783
pgsteal_kswapd_normal 254128
pgsteal_kswapd_movable 0
pgsteal_direct_dma 0
pgsteal_direct_dma32 44
pgsteal_direct_normal 6484
pgsteal_direct_movable 0
pgscan_kswapd_dma 0
pgscan_kswapd_dma32 107656
pgscan_kswapd_normal 358784
pgscan_kswapd_movable 0
pgscan_direct_dma 0
pgscan_direct_dma32 67
pgscan_direct_normal 6796
pgscan_direct_movable 0
pgscan_direct_throttle 0
zone_reclaim_failed 0
pginodesteal 412258
slabs_scanned 14355346
kswapd_inodesteal 288891
kswapd_low_wmark_hit_quickly 109
kswapd_high_wmark_hit_quickly 45
pageoutrun 247
allocstall 83165
pgrotated 35014
drop_pagecache 0
drop_slab 0
numa_pte_updates 0
numa_huge_pte_updates 0
numa_hint_faults 0
numa_hint_faults_local 0
numa_pages_migrated 0
pgmigrate_success 37070309
pgmigrate_fail 36815
compact_migrate_scanned 830267783
compact_free_scanned 12336622550
compact_isolated 82707414
compact_stall 210959
compact_fail 164840
compact_success 46119
htlb_buddy_alloc_success 0
htlb_buddy_alloc_fail 0
unevictable_pgs_culled 2188
unevictable_pgs_scanned 0
unevictable_pgs_rescued 3962
unevictable_pgs_mlocked 3994
unevictable_pgs_munlocked 3968
unevictable_pgs_cleared 14
unevictable_pgs_stranded 14
thp_fault_alloc 142261
thp_fault_fallback 98119
thp_collapse_alloc 88421
thp_collapse_alloc_failed 20954
thp_split 69984
thp_zero_page_alloc 9
thp_zero_page_alloc_failed 20
balloon_inflate 0
balloon_deflate 0
balloon_migrate 0

View File

@ -19,17 +19,25 @@ import (
"bufio"
"fmt"
"os"
"regexp"
"strconv"
"strings"
"github.com/prometheus/client_golang/prometheus"
"gopkg.in/alecthomas/kingpin.v2"
)
const (
vmStatSubsystem = "vmstat"
)
type vmStatCollector struct{}
var (
vmStatFields = kingpin.Flag("collector.vmstat.fields", "Regexp of fields to return for vmstat collector.").Default("^(pgpg|pswp|pg.*fault|oom_kill).*").String()
)
type vmStatCollector struct {
fieldPattern *regexp.Regexp
}
func init() {
registerCollector("vmstat", defaultEnabled, NewvmStatCollector)
@ -37,7 +45,10 @@ func init() {
// NewvmStatCollector returns a new Collector exposing vmstat stats.
func NewvmStatCollector() (Collector, error) {
return &vmStatCollector{}, nil
pattern := regexp.MustCompile(*vmStatFields)
return &vmStatCollector{
fieldPattern: pattern,
}, nil
}
func (c *vmStatCollector) Update(ch chan<- prometheus.Metric) error {
@ -54,6 +65,9 @@ func (c *vmStatCollector) Update(ch chan<- prometheus.Metric) error {
if err != nil {
return err
}
if !c.fieldPattern.MatchString(parts[0]) {
continue
}
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(

View File

@ -32,6 +32,7 @@ enabled_collectors=$(cat << COLLECTORS
stat
textfile
bonding
vmstat
wifi
xfs
zfs
@ -42,7 +43,6 @@ disabled_collectors=$(cat << COLLECTORS
time
timex
uname
vmstat
COLLECTORS
)
cd "$(dirname $0)"
@ -148,4 +148,4 @@ get "127.0.0.1:${port}/metrics" | grep -E -v "${skip_re}" > "${tmpdir}/e2e-outpu
diff -u \
"${fixture}" \
"${tmpdir}/e2e-output.txt"
"${tmpdir}/e2e-output.txt"