Fix "improper label name" in Prometheus datastore (#11602)

* base64 encode tags with forward slashes "/" in it

* Use of Str::contains and ternary statement

* Like this

* Update Prometheus.php

Co-authored-by: Daniel Baeza <[email protected]>
Co-authored-by: Tony Murray <[email protected]>
This commit is contained in:
TheGreatDoc
2020-05-14 21:57:18 -05:00
committed by GitHub
co-authored by Daniel Baeza Tony Murray
parent ec57d3b669
commit eac6c08ab8
+2 -1
View File
@@ -30,6 +30,7 @@ use GuzzleHttp\Exception\GuzzleException;
use LibreNMS\Config;
use LibreNMS\Data\Measure\Measurement;
use Log;
use Illuminate\Support\Str;
class Prometheus extends BaseDatastore
{
@@ -87,7 +88,7 @@ class Prometheus extends BaseDatastore
foreach ($tags as $t => $v) {
if ($v !== null) {
$promtags .= "/$t/$v";
$promtags .= (Str::contains($v, "/") ? "/$t@base64/". base64_encode($v) : "/$t/$v");
}
}
$options = $this->getDefaultOptions();