From d7c8f4e578387e31e09551ea1e709bf678bd2fa5 Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Mon, 4 Feb 2019 17:36:23 +0100 Subject: [PATCH] change some default behaviour for nodeexporter and cadvisor modes --- cloud/prometheus/exporters/cadvisor/mode/cpu.pm | 6 +++--- cloud/prometheus/exporters/nodeexporter/mode/cpu.pm | 4 ++-- cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm | 4 ++-- cloud/prometheus/exporters/nodeexporter/mode/memory.pm | 5 ++++- cloud/prometheus/exporters/nodeexporter/mode/storage.pm | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cloud/prometheus/exporters/cadvisor/mode/cpu.pm b/cloud/prometheus/exporters/cadvisor/mode/cpu.pm index ef551a817..04d6a7c00 100644 --- a/cloud/prometheus/exporters/cadvisor/mode/cpu.pm +++ b/cloud/prometheus/exporters/cadvisor/mode/cpu.pm @@ -108,7 +108,7 @@ sub check_options { } $self->{prom_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; - $self->{prom_step} = defined($self->{option_results}->{step}) ? $self->{option_results}->{step} : "1m"; + $self->{prom_step} = defined($self->{option_results}->{step}) ? $self->{option_results}->{step} : "5m"; } sub manage_selection { @@ -120,11 +120,11 @@ sub manage_selection { 'cpu="total",' . $self->{option_results}->{container} . ',' . $self->{option_results}->{pod} . - $self->{extra_filter} . '}[1m])) * 100, "__name__", "usage", "", "")', + $self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100, "__name__", "usage", "", "")', 'label_replace((irate({__name__=~"' . $self->{metrics}->{throttled} . '",' . $self->{option_results}->{container} . ',' . $self->{option_results}->{pod} . - $self->{extra_filter} . '}[1m])) * 100, "__name__", "throttled", "", "")' ], + $self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100, "__name__", "throttled", "", "")' ], timeframe => $self->{prom_timeframe}, step => $self->{prom_step}); foreach my $result (@{$results}) { diff --git a/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm b/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm index 20d5d5700..22c05afd4 100644 --- a/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm +++ b/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm @@ -131,7 +131,7 @@ sub check_options { } $self->{prom_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; - $self->{prom_step} = defined($self->{option_results}->{step}) ? $self->{option_results}->{step} : "1m"; + $self->{prom_step} = defined($self->{option_results}->{step}) ? $self->{option_results}->{step} : "5m"; } sub manage_selection { @@ -143,7 +143,7 @@ sub manage_selection { 'mode="idle",' . $self->{option_results}->{instance} . ',' . $self->{option_results}->{cpu} . - $self->{extra_filter} . '}[1m])) * 100' ], + $self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100' ], timeframe => $self->{prom_timeframe}, step => $self->{prom_step}); foreach my $result (@{$results}) { diff --git a/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm b/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm index 3c025d14c..978479e5f 100644 --- a/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm +++ b/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm @@ -258,7 +258,7 @@ sub check_options { } $self->{prom_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; - $self->{prom_step} = defined($self->{option_results}->{step}) ? $self->{option_results}->{step} : "1m"; + $self->{prom_step} = defined($self->{option_results}->{step}) ? $self->{option_results}->{step} : "5m"; } sub manage_selection { @@ -270,7 +270,7 @@ sub manage_selection { $self->{option_results}->{instance} . ',' . $self->{option_results}->{cpu} . ',' . $self->{option_results}->{type} . - $self->{extra_filter} . '}[1m])) * 100' ], + $self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100' ], timeframe => $self->{prom_timeframe}, step => $self->{prom_step}); foreach my $result (@{$results}) { diff --git a/cloud/prometheus/exporters/nodeexporter/mode/memory.pm b/cloud/prometheus/exporters/nodeexporter/mode/memory.pm index a8d24b0b2..22eeefce7 100644 --- a/cloud/prometheus/exporters/nodeexporter/mode/memory.pm +++ b/cloud/prometheus/exporters/nodeexporter/mode/memory.pm @@ -154,7 +154,7 @@ sub check_options { $self->{metrics} = { 'total' => "^node_memory_MemTotal.*", - 'available' => "^node_memory_MemAvailable.*", + 'available' => "^node_memory_MemFree.*", 'cached' => "^node_memory_Cached.*", 'buffer' => "^node_memory_Buffers.*", }; @@ -249,6 +249,9 @@ Overload default metrics name (Can be multiple, metric can be 'total', 'availabl Example : --metric-overload='metric,^my_metric_name$' +By default, 'node_memory_MemFree' node's metric will be used for 'available' metric as it is +more commonly used for now. The best being to use 'node_memory_MemAvailable' in the future. + =back =cut diff --git a/cloud/prometheus/exporters/nodeexporter/mode/storage.pm b/cloud/prometheus/exporters/nodeexporter/mode/storage.pm index 1e0d061a2..a70b19a3d 100644 --- a/cloud/prometheus/exporters/nodeexporter/mode/storage.pm +++ b/cloud/prometheus/exporters/nodeexporter/mode/storage.pm @@ -153,7 +153,7 @@ sub new { { "instance:s" => { name => 'instance', default => 'instance=~".*"' }, "mountpoint:s" => { name => 'mountpoint', default => 'mountpoint=~".*"' }, - "fstype:s" => { name => 'fstype', default => 'fstype=~"overlay"' }, + "fstype:s" => { name => 'fstype', default => 'fstype!~"linuxfs|rootfs|tmpfs"' }, "units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' }, "extra-filter:s@" => { name => 'extra_filter' }, @@ -241,7 +241,7 @@ Filter on a specific mountpoint (Must be a PromQL filter, Default: 'mountpoint=~ =item B<--fstype> -Filter on a specific fstype (Must be a PromQL filter, Default: 'fstype=~"overlay"') +Filter on a specific fstype (Must be a PromQL filter, Default: 'fstype!~"linuxfs|rootfs|tmpfs"') =item B<--units>