move prometheus nginx to new perfdata

This commit is contained in:
Colin Gagnaire 2019-06-07 14:26:54 +02:00
parent a5fd7fb3a7
commit a946b5ec81
2 changed files with 25 additions and 17 deletions

View File

@ -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];

View File

@ -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];