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 <d.baeza@tvt-datos.es>
Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
TheGreatDoc
2020-05-15 04:57:18 +02:00
committed by GitHub
parent ec57d3b669
commit eac6c08ab8

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();