Skip to content

Commit ac81fcb

Browse files
authored
Handle carbonapi expand failures (#348)
go-carbon releases up to v0.19.1 can return HTTP 500 instead of 404 for missing carbonserver find results. carbonapi cannot apply notFoundStatusCode normalization in that case, so metrics/expand surfaces the backend failure. Treat those template-probing failures like an empty match set so unrelated templates can still render.
1 parent ff73cfd commit ac81fcb

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

library/Graphite/Graphing/MetricsQuery.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Icinga\Module\Graphite\Graphing;
77

8+
use GuzzleHttp\Exception\ServerException;
89
use Icinga\Data\Fetchable;
910
use Icinga\Data\Filter\Filter;
1011
use Icinga\Data\Filterable;
@@ -175,7 +176,13 @@ public function fetchColumn()
175176
$url = Url::fromPath('metrics/expand', [
176177
'query' => $this->base->resolve($filter, '*')
177178
]);
178-
$res = Json::decode($client->request($url));
179+
try {
180+
$res = Json::decode($client->request($url));
181+
} catch (ServerException $e) {
182+
IPT::recordf('Fetched 0 metric(s) from %s: %s', (string) $client->completeUrl($url), $e->getMessage());
183+
184+
return [];
185+
}
179186
natsort($res->results);
180187

181188
IPT::recordf('Fetched %s metric(s) from %s', count($res->results), (string) $client->completeUrl($url));

0 commit comments

Comments
 (0)