|
|
@ -114,25 +114,6 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function retry(deferred, callback, delay) { |
|
|
|
|
|
|
|
return callback().then(undefined, function(reason) { |
|
|
|
|
|
|
|
if (reason.status !== 0 || reason.status >= 300) { |
|
|
|
|
|
|
|
if (reason.data && reason.data.error) { |
|
|
|
|
|
|
|
reason.message = 'InfluxDB Error Response: ' + reason.data.error; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
reason.message = 'InfluxDB Error: ' + reason.message; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
deferred.reject(reason); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
setTimeout(function() { |
|
|
|
|
|
|
|
return retry(deferred, callback, Math.min(delay * 2, 30000)); |
|
|
|
|
|
|
|
}, delay); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InfluxDatasource.prototype._seriesQuery = function(query) { |
|
|
|
InfluxDatasource.prototype._seriesQuery = function(query) { |
|
|
|
return this._influxRequest('GET', '/query', {q: query, epoch: 'ms'}); |
|
|
|
return this._influxRequest('GET', '/query', {q: query, epoch: 'ms'}); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -145,46 +126,50 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) { |
|
|
|
|
|
|
|
|
|
|
|
InfluxDatasource.prototype._influxRequest = function(method, url, data) { |
|
|
|
InfluxDatasource.prototype._influxRequest = function(method, url, data) { |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
var deferred = $q.defer(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
retry(deferred, function() { |
|
|
|
|
|
|
|
var currentUrl = self.urls.shift(); |
|
|
|
|
|
|
|
self.urls.push(currentUrl); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var params = { |
|
|
|
var currentUrl = self.urls.shift(); |
|
|
|
u: self.username, |
|
|
|
self.urls.push(currentUrl); |
|
|
|
p: self.password, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (self.database) { |
|
|
|
var params = { |
|
|
|
params.db = self.database; |
|
|
|
u: self.username, |
|
|
|
} |
|
|
|
p: self.password, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (method === 'GET') { |
|
|
|
if (self.database) { |
|
|
|
_.extend(params, data); |
|
|
|
params.db = self.database; |
|
|
|
data = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var options = { |
|
|
|
if (method === 'GET') { |
|
|
|
method: method, |
|
|
|
_.extend(params, data); |
|
|
|
url: currentUrl + url, |
|
|
|
data = null; |
|
|
|
params: params, |
|
|
|
} |
|
|
|
data: data, |
|
|
|
|
|
|
|
precision: "ms", |
|
|
|
|
|
|
|
inspect: { type: 'influxdb' }, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.headers = options.headers || {}; |
|
|
|
|
|
|
|
if (self.basicAuth) { |
|
|
|
|
|
|
|
options.headers.Authorization = self.basicAuth; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $http(options).success(function (data) { |
|
|
|
var options = { |
|
|
|
deferred.resolve(data); |
|
|
|
method: method, |
|
|
|
}); |
|
|
|
url: currentUrl + url, |
|
|
|
}, 10); |
|
|
|
params: params, |
|
|
|
|
|
|
|
data: data, |
|
|
|
|
|
|
|
precision: "ms", |
|
|
|
|
|
|
|
inspect: { type: 'influxdb' }, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.headers = options.headers || {}; |
|
|
|
|
|
|
|
if (self.basicAuth) { |
|
|
|
|
|
|
|
options.headers.Authorization = self.basicAuth; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return deferred.promise; |
|
|
|
return $http(options).then(function(result) { |
|
|
|
|
|
|
|
return result.data; |
|
|
|
|
|
|
|
}, function(reason) { |
|
|
|
|
|
|
|
if (reason.status !== 0 || reason.status >= 300) { |
|
|
|
|
|
|
|
if (reason.data && reason.data.error) { |
|
|
|
|
|
|
|
throw { message: 'InfluxDB Error Response: ' + reason.data.error }; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
throw { messsage: 'InfluxDB Error: ' + reason.message }; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function getTimeFilter(options) { |
|
|
|
function getTimeFilter(options) { |
|
|
|