diff --git a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/containerstatus.pm b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/containerstatus.pm index 9afad05f3..e33818ae4 100644 --- a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/containerstatus.pm +++ b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/containerstatus.pm @@ -100,6 +100,7 @@ sub new { "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /running/ || %{state} !~ /ready/' }, "extra-filter:s@" => { name => 'extra_filter' }, "metric-overload:s@" => { name => 'metric_overload' }, + "filter-counters:s" => { name => 'filter_counters' }, }); return $self; @@ -236,10 +237,25 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'status') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - ready: ^kube_pod_container_status_ready$ + - running: ^kube_pod_container_status_running$ + - terminated: ^kube_pod_container_status_terminated$ + - terminated_reason: ^kube_pod_container_status_terminated_reason$ + - waiting: ^kube_pod_container_status_waiting$ + - waiting_reason: ^kube_pod_container_status_waiting_reason$ + - restarts: ^kube_pod_container_status_restarts_total$ + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='status' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/daemonsetstatus.pm b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/daemonsetstatus.pm index 6a18dd615..bd3c20c44 100644 --- a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/daemonsetstatus.pm +++ b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/daemonsetstatus.pm @@ -231,10 +231,20 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'status') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - desired: ^kube_daemonset_status_desired_number_scheduled$ + - current: ^kube_daemonset_status_current_number_scheduled$ + - available: ^kube_daemonset_status_number_available$ + - unavailable: ^kube_daemonset_status_number_unavailable$ + - up_to_date: ^kube_daemonset_updated_number_scheduled$ + - ready: ^kube_daemonset_status_number_ready$ + - misscheduled: ^kube_daemonset_status_number_misscheduled$ + =back =cut diff --git a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/deploymentstatus.pm b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/deploymentstatus.pm index f7693d04d..27b17c37a 100644 --- a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/deploymentstatus.pm +++ b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/deploymentstatus.pm @@ -214,10 +214,18 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'status') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - desired: ^kube_deployment_spec_replicas$ + - current: ^kube_deployment_status_replicas$ + - available: ^kube_deployment_status_replicas_available$ + - unavailable: ^kube_deployment_status_replicas_unavailable$ + - up_to_date: ^kube_deployment_status_replicas_updated$ + =back =cut diff --git a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/namespacestatus.pm b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/namespacestatus.pm index a29b3ca5d..def61001d 100644 --- a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/namespacestatus.pm +++ b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/namespacestatus.pm @@ -205,10 +205,19 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'status') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - status: ^kube_namespace_status_phase$ + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='status' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/nodestatus.pm b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/nodestatus.pm index 8ec144f4c..974b2379f 100644 --- a/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/nodestatus.pm +++ b/centreon-plugins/cloud/prometheus/direct/kubernetes/mode/nodestatus.pm @@ -258,10 +258,22 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'status') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - status: ^kube_node_status_condition$ + - unschedulable: ^kube_node_spec_unschedulable$ + - capacity: ^kube_node_status_capacity_pods$ + - allocatable: ^kube_node_status_allocatable_pods$ + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='status' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/cpu.pm b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/cpu.pm index 04d6a7c00..36a3ebbbc 100644 --- a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/cpu.pm +++ b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/cpu.pm @@ -71,10 +71,12 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { + "cpu-attribute:s" => { name => 'cpu_attribute', default => 'cpu="total"' }, "container:s" => { name => 'container', default => 'container_name!~".*POD.*"' }, "pod:s" => { name => 'pod', default => 'pod_name=~".*"' }, "extra-filter:s@" => { name => 'extra_filter' }, "metric-overload:s@" => { name => 'metric_overload' }, + "filter-counters:s" => { name => 'filter_counters' }, }); return $self; @@ -117,7 +119,7 @@ sub manage_selection { $self->{containers} = {}; my $results = $options{custom}->query_range(queries => [ 'label_replace((irate({__name__=~"' . $self->{metrics}->{usage} . '",' . - 'cpu="total",' . + $self->{option_results}->{cpu_attribute} . ',' . $self->{option_results}->{container} . ',' . $self->{option_results}->{pod} . $self->{extra_filter} . '}[' . $self->{prom_step} . '])) * 100, "__name__", "usage", "", "")', @@ -152,6 +154,10 @@ Check containers CPU usage and throttled. =over 8 +=item B<--cpu-attribute> + +Set the cpu attribute to match element (Must be a PromQL filter, Default: 'cpu="total"') + =item B<--container> Filter on a specific container (Must be a PromQL filter, Default: 'container_name!~".*POD.*"') @@ -178,10 +184,20 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'usage', 'throttled') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - throttled: ^container_cpu_cfs_throttled_seconds_total.* + - usage: ^container_cpu_usage_seconds_total.* + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='throttled' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/load.pm b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/load.pm index fe0c1f347..dc61230cf 100644 --- a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/load.pm +++ b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/load.pm @@ -159,10 +159,14 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'load') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - load: ^container_cpu_load_average_10s$ + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/memory.pm b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/memory.pm index 06b90a376..37db624a6 100644 --- a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/memory.pm +++ b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/memory.pm @@ -175,6 +175,7 @@ sub new { "extra-filter:s@" => { name => 'extra_filter' }, "units:s" => { name => 'units', default => '%' }, "metric-overload:s@" => { name => 'metric_overload' }, + "filter-counters:s" => { name => 'filter_counters' }, }); return $self; @@ -298,11 +299,24 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'limits', -'usage', 'working', 'cache', 'rss', 'swap'.) +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - limits: ^container_spec_memory_limit_bytes.* + - usage: ^container_memory_usage_bytes.* + - working: ^container_memory_working_set_bytes.* + - cache: ^container_memory_cache.* + - rss: ^container_memory_rss.* + - swap: ^container_memory_swap.* + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='usage' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/storage.pm b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/storage.pm index 14b96e8ee..8262ce412 100644 --- a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/storage.pm +++ b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/storage.pm @@ -270,10 +270,15 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'used', 'limit') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - used: ^container_fs_usage_bytes.* + - limit: ^container_fs_limit_bytes.* + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/taskstate.pm b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/taskstate.pm index 304654ebd..a25b682ae 100644 --- a/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/taskstate.pm +++ b/centreon-plugins/cloud/prometheus/exporters/cadvisor/mode/taskstate.pm @@ -203,10 +203,14 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'tasks_state') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - tasks_state: ^container_tasks_state$ + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm index 22c05afd4..e19e697f3 100644 --- a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm +++ b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm @@ -99,6 +99,7 @@ sub new { "cpu:s" => { name => 'cpu', default => 'cpu=~".*"' }, "extra-filter:s@" => { name => 'extra_filter' }, "metric-overload:s@" => { name => 'metric_overload' }, + "filter-counters:s" => { name => 'filter_counters' }, }); return $self; @@ -200,10 +201,19 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'cpu') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - cpu: ^node_cpu.* + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='node' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm index 978479e5f..e9780c20e 100644 --- a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm +++ b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm @@ -226,6 +226,7 @@ sub new { "type:s" => { name => 'type', default => 'mode=~".*"' }, "extra-filter:s@" => { name => 'extra_filter' }, "metric-overload:s@" => { name => 'metric_overload' }, + "filter-counters:s" => { name => 'filter_counters' }, }); return $self; @@ -340,10 +341,19 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'cpu') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - cpu: ^node_cpu.* + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='wait' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/load.pm b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/load.pm index 347c3a401..aa5d96278 100644 --- a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/load.pm +++ b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/load.pm @@ -83,6 +83,7 @@ sub new { "instance:s" => { name => 'instance', default => 'instance=~".*"' }, "extra-filter:s@" => { name => 'extra_filter' }, "metric-overload:s@" => { name => 'metric_overload' }, + "filter-counters:s" => { name => 'filter_counters' }, }); return $self; @@ -175,10 +176,21 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'load1', 'load5', 'load15') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - load1: ^node_load1$ + - load5: ^node_load5$ + - load15: ^node_load15$ + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='load15' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/memory.pm b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/memory.pm index 22eeefce7..a430673d2 100644 --- a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/memory.pm +++ b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/memory.pm @@ -143,6 +143,7 @@ sub new { "units:s" => { name => 'units', default => '%' }, "extra-filter:s@" => { name => 'extra_filter' }, "metric-overload:s@" => { name => 'metric_overload' }, + "filter-counters:s" => { name => 'filter_counters' }, }); return $self; @@ -245,13 +246,25 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'total', 'available', 'cached', 'buffer') +Overload default metrics name (Can be multiple) 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. +Default : + + - total: ^node_memory_MemTotal.* + - available: ^node_memory_MemFree.* + - cached: ^node_memory_Cached.* + - buffer: ^node_memory_Buffers.* + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='usage' + =back =cut diff --git a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/storage.pm b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/storage.pm index a70b19a3d..5dd77765a 100644 --- a/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/storage.pm +++ b/centreon-plugins/cloud/prometheus/exporters/nodeexporter/mode/storage.pm @@ -267,10 +267,15 @@ Example : --extra-filter='name=~".*pretty.*"' =item B<--metric-overload> -Overload default metrics name (Can be multiple, metric can be 'free', 'size') +Overload default metrics name (Can be multiple) Example : --metric-overload='metric,^my_metric_name$' +Default : + + - free: ^node_filesystem_free.* + - size: ^node_filesystem_size.* + =back =cut diff --git a/centreon-plugins/cloud/prometheus/restapi/custom/api.pm b/centreon-plugins/cloud/prometheus/restapi/custom/api.pm index 9f47d8424..df5a2216f 100644 --- a/centreon-plugins/cloud/prometheus/restapi/custom/api.pm +++ b/centreon-plugins/cloud/prometheus/restapi/custom/api.pm @@ -161,8 +161,6 @@ sub query_range { my $uri = URI::Encode->new({encode_reserved => 1}); foreach my $query (@{$options{queries}}) { - $self->{output}->output_add(long_msg => sprintf("Query range: '/query_range?query=%s&start=%s&end=%s&step=%s'", - $query, $start_time, $end_time, $options{step}), debug => 1); my $result = $self->get_endpoint(url_path => '/query_range?query=' . $uri->encode($query) . '&start=' . $start_time . '&end=' . $end_time . '&step=' . $options{step}); push @{$data}, @{$result->{result}}; @@ -178,7 +176,6 @@ sub query { my $uri = URI::Encode->new({encode_reserved => 1}); foreach my $query (@{$options{queries}}) { - $self->{output}->output_add(long_msg => sprintf("Query: '/query?query=%s'", $query), debug => 1); my $result = $self->get_endpoint(url_path => '/query?query=' . $uri->encode($query)); push @{$data}, @{$result->{result}}; } @@ -190,6 +187,10 @@ sub get_endpoint { my ($self, %options) = @_; $self->settings; + + $self->{output}->output_add(long_msg => "Query URL: '" . $self->{proto} . "://" . $self->{hostname} . + $self->{url_path} . $options{url_path} . "'", debug => 1); + my $response = $self->{http}->request(url_path => $self->{url_path} . $options{url_path}); my $content;