diff --git a/library/Graphite/Graphing/MetricsQuery.php b/library/Graphite/Graphing/MetricsQuery.php index 87e6e67..6a2839d 100644 --- a/library/Graphite/Graphing/MetricsQuery.php +++ b/library/Graphite/Graphing/MetricsQuery.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Graphite\Graphing; +use GuzzleHttp\Exception\ServerException; use Icinga\Data\Fetchable; use Icinga\Data\Filter\Filter; use Icinga\Data\Filterable; @@ -175,7 +176,13 @@ public function fetchColumn() $url = Url::fromPath('metrics/expand', [ 'query' => $this->base->resolve($filter, '*') ]); - $res = Json::decode($client->request($url)); + try { + $res = Json::decode($client->request($url)); + } catch (ServerException $e) { + IPT::recordf('Fetched 0 metric(s) from %s: %s', (string) $client->completeUrl($url), $e->getMessage()); + + return []; + } natsort($res->results); IPT::recordf('Fetched %s metric(s) from %s', count($res->results), (string) $client->completeUrl($url));