mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
Expose PromConsole.Graph.buildQueryUrl, refactor dispatch to use (#2461)
Expose buildQueryUrl, refactor dispatch to use buildQueryUrl will allow users to execute queries over the range of an existing graph. This will be helpful to select data series they wish to annotate the graph with, for example.
This commit is contained in:
parent
7e14533b32
commit
0a7fb56b16
|
@ -523,6 +523,14 @@ PromConsole.Graph.prototype._clearGraph = function() {
|
||||||
|
|
||||||
PromConsole.Graph.prototype._xhrs = [];
|
PromConsole.Graph.prototype._xhrs = [];
|
||||||
|
|
||||||
|
PromConsole.Graph.prototype.buildQueryUrl = function(expr) {
|
||||||
|
var p = this.params;
|
||||||
|
return PATH_PREFIX + "/api/v1/query_range?query=" +
|
||||||
|
encodeURIComponent(expr) +
|
||||||
|
"&step=" + p.duration / this.graphTd.offsetWidth +
|
||||||
|
"&start=" + (p.endTime - p.duration) + "&end=" + p.endTime;
|
||||||
|
};
|
||||||
|
|
||||||
PromConsole.Graph.prototype.dispatch = function() {
|
PromConsole.Graph.prototype.dispatch = function() {
|
||||||
for (var j = 0; j < this._xhrs.length; j++) {
|
for (var j = 0; j < this._xhrs.length; j++) {
|
||||||
this._xhrs[j].abort();
|
this._xhrs[j].abort();
|
||||||
|
@ -532,9 +540,7 @@ PromConsole.Graph.prototype.dispatch = function() {
|
||||||
var pending_requests = this.params.expr.length;
|
var pending_requests = this.params.expr.length;
|
||||||
for (var i = 0; i < this.params.expr.length; ++i) {
|
for (var i = 0; i < this.params.expr.length; ++i) {
|
||||||
var endTime = this.params.endTime;
|
var endTime = this.params.endTime;
|
||||||
var url = PATH_PREFIX + "/api/v1/query_range?query=" + encodeURIComponent(this.params.expr[i]) +
|
var url = this.buildQueryUrl(this.params.expr[i]);
|
||||||
"&step=" + this.params.duration / this.graphTd.offsetWidth +
|
|
||||||
"&start=" + (endTime - this.params.duration) + "&end=" + endTime;
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('get', url, true);
|
xhr.open('get', url, true);
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
|
|
Loading…
Reference in a new issue