[pve-devel] applied: [PATCH manager v2 1/2] fix #1683: do not send non-numeric values to graphite
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Mar 5 14:31:51 CET 2018
applied both patches, thanks!
On 3/5/18 9:58 AM, Dominik Csapak wrote:
> the graphite daemons which accept the data (carbon), only
> accepts numeric values, and logs all invalid lines
>
> since that were about 5 values per vm/ct this generated lot of noise
> in the carbon log
>
> so we check with a regex if a value is numeric, and
> additionally we have a blacklist of keys which seem to be numeric but
> are either boolean (e.g. template) or a state (e.g. pid)
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> changes from v1:
> * improve number regex (thanks thomas :) )
> * add blacklist for non-numeric values
> * add explaining comment for all other values
> PVE/Status/Graphite.pm | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/PVE/Status/Graphite.pm b/PVE/Status/Graphite.pm
> index 849930f0..64ca89c0 100644
> --- a/PVE/Status/Graphite.pm
> +++ b/PVE/Status/Graphite.pm
> @@ -36,6 +36,14 @@ sub options {
> };
> }
>
> +# we do not want boolean/state information to export to graphite
> +my $key_blacklist = {
> + 'template' => 1,
> + 'pid' => 1,
> + 'agent' => 1,
> + 'serial' => 1,
> +};
> +
> # Plugin implementation
> sub update_node_status {
> my ($class, $plugin_config, $node, $data, $ctime) = @_;
> @@ -93,9 +101,12 @@ sub write_graphite {
> if ( defined $value ) {
> if ( ref $value eq 'HASH' ) {
> write_graphite($carbon_socket, $value, $ctime, $path);
> - }else {
> - $carbon_socket->send( "$path $value $ctime\n" );
> - }
> + } elsif ($value =~ m/^[+-]?[0-9]*\.?[0-9]+$/ &&
> + !$key_blacklist->{$key}) {
> + $carbon_socket->send( "$path $value $ctime\n" );
> + } else {
> + # do not send blacklisted or non-numeric values
> + }
> }
> $path = $oldpath;
> }
>
More information about the pve-devel
mailing list