From 21df1cc74ed206c555802b4c9bbae92af978f1ee Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Fri, 7 Jun 2019 14:26:54 +0200 Subject: [PATCH] move prometheus nginx to new perfdata --- .../mode/connections.pm | 24 +++++++++++-------- .../nginxingresscontroller/mode/requests.pm | 18 ++++++++------ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/centreon-plugins/cloud/prometheus/direct/nginxingresscontroller/mode/connections.pm b/centreon-plugins/cloud/prometheus/direct/nginxingresscontroller/mode/connections.pm index ddb9185d8..2099045a6 100644 --- a/centreon-plugins/cloud/prometheus/direct/nginxingresscontroller/mode/connections.pm +++ b/centreon-plugins/cloud/prometheus/direct/nginxingresscontroller/mode/connections.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'reading', set => { + { label => 'reading', nlabel => 'connections.reading.count', set => { key_values => [ { name => 'reading' } ], output_template => 'Reading: %d', perfdatas => [ @@ -43,7 +43,7 @@ sub set_counters { ], } }, - { label => 'waiting', set => { + { label => 'waiting', nlabel => 'connections.waiting.count', set => { key_values => [ { name => 'waiting' } ], output_template => 'Waiting: %d', perfdatas => [ @@ -52,7 +52,7 @@ sub set_counters { ], } }, - { label => 'writing', set => { + { label => 'writing', nlabel => 'connections.writing.count', set => { key_values => [ { name => 'writing' } ], output_template => 'Writing: %d', perfdatas => [ @@ -61,7 +61,7 @@ sub set_counters { ], } }, - { label => 'active', set => { + { label => 'active', nlabel => 'connections.active.count', set => { key_values => [ { name => 'active' } ], output_template => 'Active: %d', perfdatas => [ @@ -70,7 +70,7 @@ sub set_counters { ], } }, - { label => 'accepted', set => { + { label => 'accepted', nlabel => 'connections.accepted.persecond', set => { key_values => [ { name => 'accepted', diff => 1 } ], output_template => 'Accepted: %.2f/s', per_second => 1, @@ -80,7 +80,7 @@ sub set_counters { ], } }, - { label => 'handled', set => { + { label => 'handled', nlabel => 'connections.handled.persecond', set => { key_values => [ { name => 'handled', diff => 1 } ], output_template => 'Handled: %.2f/s', per_second => 1, @@ -141,10 +141,14 @@ sub manage_selection { $self->{global} = {}; - my $results = $options{custom}->query(queries => [ 'label_replace({__name__=~"' . $self->{metrics}->{connections} . '",' . - $self->{extra_filter} . '}, "__name__", "connections", "", "")', - 'label_replace({__name__=~"' . $self->{metrics}->{connections_total} . '",' . - $self->{extra_filter} . '}, "__name__", "connections_total", "", "")' ]); + my $results = $options{custom}->query( + queries => [ + 'label_replace({__name__=~"' . $self->{metrics}->{connections} . '",' . + $self->{extra_filter} . '}, "__name__", "connections", "", "")', + 'label_replace({__name__=~"' . $self->{metrics}->{connections_total} . '",' . + $self->{extra_filter} . '}, "__name__", "connections_total", "", "")' + ] + ); foreach my $result (@{$results}) { $self->{global}->{$result->{metric}->{state}} = ${$result->{value}}[1]; diff --git a/centreon-plugins/cloud/prometheus/direct/nginxingresscontroller/mode/requests.pm b/centreon-plugins/cloud/prometheus/direct/nginxingresscontroller/mode/requests.pm index 8203ecd08..b1d6b084d 100644 --- a/centreon-plugins/cloud/prometheus/direct/nginxingresscontroller/mode/requests.pm +++ b/centreon-plugins/cloud/prometheus/direct/nginxingresscontroller/mode/requests.pm @@ -36,7 +36,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'requests', set => { + { label => 'requests', nlabel => 'requests.total.persecond', set => { key_values => [ { name => 'requests', diff => 1 } ], output_template => 'Requests: %.2f/s', per_second => 1, @@ -48,7 +48,7 @@ sub set_counters { }, ]; $self->{maps_counters}->{namespaces} = [ - { label => 'requests-2xx', set => { + { label => 'requests-2xx', nlabel => 'namespace.requests.2xx.persecond', set => { key_values => [ { name => 'requests_2xx', diff => 1 } ], output_template => 'Requests 2xx: %.2f/s', per_second => 1, @@ -58,7 +58,7 @@ sub set_counters { ], } }, - { label => 'requests-3xx', set => { + { label => 'requests-3xx', nlabel => 'namespace.requests.2xx.persecond', set => { key_values => [ { name => 'requests_3xx', diff => 1 } ], output_template => 'Requests 3xx: %.2f/s', per_second => 1, @@ -68,7 +68,7 @@ sub set_counters { ], } }, - { label => 'requests-4xx', set => { + { label => 'requests-4xx', nlabel => 'namespace.requests.4xx.persecond', set => { key_values => [ { name => 'requests_4xx', diff => 1 } ], output_template => 'Requests 4xx: %.2f/s', per_second => 1, @@ -78,7 +78,7 @@ sub set_counters { ], } }, - { label => 'requests-5xx', set => { + { label => 'requests-5xx', nlabel => 'namespace.requests.5xx.persecond', set => { key_values => [ { name => 'requests_5xx', diff => 1 } ], output_template => 'Requests 5xx: %.2f/s', per_second => 1, @@ -139,8 +139,12 @@ sub manage_selection { $self->{global} = {}; - my $results = $options{custom}->query(queries => [ 'label_replace({__name__=~"' . $self->{metrics}->{requests_total} . '",' . - $self->{extra_filter} . '}, "__name__", "requests_total", "", "")' ]); + my $results = $options{custom}->query( + queries => [ + 'label_replace({__name__=~"' . $self->{metrics}->{requests_total} . '",' . + $self->{extra_filter} . '}, "__name__", "requests_total", "", "")' + ] + ); foreach my $result (@{$results}) { $self->{global}->{requests} = ${$result->{value}}[1];