Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0ed4744a
Commit
0ed4744a
authored
Aug 07, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
influxdb(auth): fixed issue with using basic auth and influxdb, fixes #2455
parent
776ca86a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
55 deletions
+41
-55
pkg/api/dataproxy.go
+3
-2
public/app/plugins/datasource/influxdb/datasource.js
+38
-53
No files found.
pkg/api/dataproxy.go
View file @
0ed4744a
...
...
@@ -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
)
}
...
...
public/app/plugins/datasource/influxdb/datasource.js
View file @
0ed4744a
...
...
@@ -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,46 +126,50 @@ 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
);
var
params
=
{
u
:
self
.
username
,
p
:
self
.
password
,
};
var
currentUrl
=
self
.
urls
.
shift
();
self
.
urls
.
push
(
currentUrl
);
if
(
self
.
database
)
{
params
.
db
=
self
.
database
;
}
var
params
=
{
u
:
self
.
username
,
p
:
self
.
password
,
};
if
(
method
===
'GET'
)
{
_
.
extend
(
params
,
data
);
data
=
null
;
}
if
(
self
.
database
)
{
params
.
db
=
self
.
database
;
}
var
options
=
{
method
:
method
,
url
:
currentUrl
+
url
,
params
:
params
,
data
:
data
,
precision
:
"ms"
,
inspect
:
{
type
:
'influxdb'
},
};
options
.
headers
=
options
.
headers
||
{};
if
(
self
.
basicAuth
)
{
options
.
headers
.
Authorization
=
self
.
basicAuth
;
}
if
(
method
===
'GET'
)
{
_
.
extend
(
params
,
data
);
data
=
null
;
}
return
$http
(
options
).
success
(
function
(
data
)
{
deferred
.
resolve
(
data
);
});
},
10
);
var
options
=
{
method
:
method
,
url
:
currentUrl
+
url
,
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment