From 0d384b89492c26fbe4dcaf393321c33d837c503d Mon Sep 17 00:00:00 2001 From: Filippo Giunchedi Date: Thu, 17 Aug 2017 12:18:10 -0400 Subject: [PATCH] fix: Sanitize metric name before sending via graphite (#7173) Fixes #7167 --- includes/graphite.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/graphite.inc.php b/includes/graphite.inc.php index 0d9a71be58..8c142e46f3 100644 --- a/includes/graphite.inc.php +++ b/includes/graphite.inc.php @@ -36,6 +36,8 @@ function graphite_update($device, $measurement, $tags, $fields) foreach ($fields as $k => $v) { $metric = implode(".", array_filter(array($graphite_prefix, $hostname, $measurement, $ms_name, $k))); + // Further sanitize the full metric before sending, whitespace isn't allowed + $metric = preg_replace('/\s+/', '_', $metric); $line = implode(" ", array($metric, $v, $timestamp)); d_echo("Sending $line\n"); fwrite($graphite, $line . "\n");