fix: Sanitize metric name before sending via graphite (#7173)

Fixes #7167
This commit is contained in:
Filippo Giunchedi
2017-08-17 12:18:10 -04:00
committed by Neil Lathwood
parent ad6e82b3c7
commit 0d384b8949

View File

@ -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");