mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
influxdb(auth): fixed issue with using basic auth and influxdb, fixes #2455
This commit is contained in:
parent
776ca86a60
commit
0ed4744a33
@ -42,9 +42,10 @@ func NewReverseProxy(ds *m.DataSource, proxyPath string) *httputil.ReverseProxy
|
||||
} else if ds.Type == m.DS_INFLUXDB {
|
||||
req.URL.Path = util.JoinUrlFragments(target.Path, proxyPath)
|
||||
reqQueryVals.Add("db", ds.Database)
|
||||
reqQueryVals.Add("u", ds.User)
|
||||
reqQueryVals.Add("p", ds.Password)
|
||||
req.URL.RawQuery = reqQueryVals.Encode()
|
||||
if !ds.BasicAuth {
|
||||
req.Header.Add("Authorization", util.GetBasicAuthHeader(ds.User, ds.Password))
|
||||
}
|
||||
} else {
|
||||
req.URL.Path = util.JoinUrlFragments(target.Path, proxyPath)
|
||||
}
|
||||
|
@ -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) {
|
||||
return this._influxRequest('GET', '/query', {q: query, epoch: 'ms'});
|
||||
};
|
||||
@ -145,9 +126,7 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
|
||||
|
||||
InfluxDatasource.prototype._influxRequest = function(method, url, data) {
|
||||
var self = this;
|
||||
var deferred = $q.defer();
|
||||
|
||||
retry(deferred, function() {
|
||||
var currentUrl = self.urls.shift();
|
||||
self.urls.push(currentUrl);
|
||||
|
||||
@ -179,12 +158,18 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
|
||||
options.headers.Authorization = self.basicAuth;
|
||||
}
|
||||
|
||||
return $http(options).success(function (data) {
|
||||
deferred.resolve(data);
|
||||
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 };
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 10);
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
function getTimeFilter(options) {
|
||||
|
Loading…
Reference in New Issue
Block a user