From 8ddcd6708051cdd630fe0186d20e25b0c75fe07e Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Tue, 1 May 2018 12:42:58 +0900 Subject: [PATCH 1/3] add query timeout option for Prometheus --- .../datasource/prometheus/datasource.ts | 8 ++++++ .../prometheus/partials/config.html | 28 +++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index df1fc6053fb..a52f3aefa2e 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -27,6 +27,7 @@ export class PrometheusDatasource { withCredentials: any; metricsNameCache: any; interval: string; + queryTimeout: string; httpMethod: string; resultTransformer: ResultTransformer; @@ -42,6 +43,7 @@ export class PrometheusDatasource { this.basicAuth = instanceSettings.basicAuth; this.withCredentials = instanceSettings.withCredentials; this.interval = instanceSettings.jsonData.timeInterval || '15s'; + this.queryTimeout = instanceSettings.jsonData.queryTimeout; this.httpMethod = instanceSettings.jsonData.httpMethod || 'GET'; this.resultTransformer = new ResultTransformer(templateSrv); } @@ -231,6 +233,9 @@ export class PrometheusDatasource { end: end, step: query.step, }; + if (this.queryTimeout) { + data['timeout'] = this.queryTimeout; + } return this._request(url, data, { requestId: query.requestId }); } @@ -240,6 +245,9 @@ export class PrometheusDatasource { query: query.expr, time: time, }; + if (this.queryTimeout) { + data['timeout'] = this.queryTimeout; + } return this._request(url, data, { requestId: query.requestId }); } diff --git a/public/app/plugins/datasource/prometheus/partials/config.html b/public/app/plugins/datasource/prometheus/partials/config.html index 2cd6adcbc4d..a7a85e696b0 100644 --- a/public/app/plugins/datasource/prometheus/partials/config.html +++ b/public/app/plugins/datasource/prometheus/partials/config.html @@ -2,15 +2,25 @@
-
-
- Scrape interval - - - Set this to your global scrape interval defined in your Prometheus config file. This will be used as a lower limit for - the Prometheus step query parameter. - -
+
+
+ Scrape interval + + + Set this to your global scrape interval defined in your Prometheus config file. This will be used as a lower limit for the + Prometheus step query parameter. + +
+
+ +
+
+ Query timeout + + + Set the Prometheus query timeout. + +
From 12ace5ab65ee0bc4d667ed88a36bd75d380a1af2 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Tue, 15 May 2018 14:04:30 +0900 Subject: [PATCH 2/3] move queryTimeout option to common setting --- .../plugins/partials/ds_http_settings.html | 9 ++++++ .../prometheus/partials/config.html | 28 ++++++------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/public/app/features/plugins/partials/ds_http_settings.html b/public/app/features/plugins/partials/ds_http_settings.html index b9f5683129c..9e6930f2c7a 100644 --- a/public/app/features/plugins/partials/ds_http_settings.html +++ b/public/app/features/plugins/partials/ds_http_settings.html @@ -156,4 +156,13 @@
+
+
+ Query timeout + + + Set the Query timeout. + +
+
diff --git a/public/app/plugins/datasource/prometheus/partials/config.html b/public/app/plugins/datasource/prometheus/partials/config.html index a7a85e696b0..2cd6adcbc4d 100644 --- a/public/app/plugins/datasource/prometheus/partials/config.html +++ b/public/app/plugins/datasource/prometheus/partials/config.html @@ -2,25 +2,15 @@
-
-
- Scrape interval - - - Set this to your global scrape interval defined in your Prometheus config file. This will be used as a lower limit for the - Prometheus step query parameter. - -
-
- -
-
- Query timeout - - - Set the Prometheus query timeout. - -
+
+
+ Scrape interval + + + Set this to your global scrape interval defined in your Prometheus config file. This will be used as a lower limit for + the Prometheus step query parameter. + +
From 067ceb178edcf915121c7657a9d52d8df3fdde05 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Mon, 21 May 2018 21:44:21 +0900 Subject: [PATCH 3/3] Revert "move queryTimeout option to common setting" This reverts commit 3ba59a1d66a2a3c07ccd04a48c403f0772fbef31. --- .../plugins/partials/ds_http_settings.html | 9 ------ .../prometheus/partials/config.html | 28 +++++++++++++------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/public/app/features/plugins/partials/ds_http_settings.html b/public/app/features/plugins/partials/ds_http_settings.html index 9e6930f2c7a..b9f5683129c 100644 --- a/public/app/features/plugins/partials/ds_http_settings.html +++ b/public/app/features/plugins/partials/ds_http_settings.html @@ -156,13 +156,4 @@
-
-
- Query timeout - - - Set the Query timeout. - -
-
diff --git a/public/app/plugins/datasource/prometheus/partials/config.html b/public/app/plugins/datasource/prometheus/partials/config.html index 2cd6adcbc4d..a7a85e696b0 100644 --- a/public/app/plugins/datasource/prometheus/partials/config.html +++ b/public/app/plugins/datasource/prometheus/partials/config.html @@ -2,15 +2,25 @@
-
-
- Scrape interval - - - Set this to your global scrape interval defined in your Prometheus config file. This will be used as a lower limit for - the Prometheus step query parameter. - -
+
+
+ Scrape interval + + + Set this to your global scrape interval defined in your Prometheus config file. This will be used as a lower limit for the + Prometheus step query parameter. + +
+
+ +
+
+ Query timeout + + + Set the Prometheus query timeout. + +