From 4cc80efee60d9bfacae20cce60e808465efbe14d Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Thu, 5 Apr 2018 18:11:35 +0200 Subject: [PATCH] graphite: use a query when testing data source Using a query (POST /render) request instead of GET /metrics/find to better mimic an actual request for rendering a panel in a dashboard. The POST /render request will add at least a custom http header which can be problematic when using direct access mode since it will trigger a CORS prerequest check. By doing this kind of query when testing the data source possible CORS issues can be detected there instead of later when trying to use the data source in a dashboard. --- public/app/plugins/datasource/graphite/datasource.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/graphite/datasource.ts b/public/app/plugins/datasource/graphite/datasource.ts index 335cb400834..c4bd4178965 100644 --- a/public/app/plugins/datasource/graphite/datasource.ts +++ b/public/app/plugins/datasource/graphite/datasource.ts @@ -453,7 +453,13 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv }; this.testDatasource = function() { - return this.metricFindQuery('*').then(function() { + let query = { + panelId: 3, + rangeRaw: { from: 'now-1h', to: 'now' }, + targets: [{ target: 'constantLine(100)' }], + maxDataPoints: 300, + }; + return this.query(query).then(function() { return { status: 'success', message: 'Data source is working' }; }); };