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
9413ce5e
Unverified
Commit
9413ce5e
authored
Apr 13, 2018
by
Daniel Lee
Committed by
GitHub
Apr 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8096 from ryantxu/influx-db-query2
let the influxdb API set a database
parents
511b34eb
a04c4ba4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
31 deletions
+39
-31
pkg/api/pluginproxy/ds_proxy.go
+0
-6
public/app/plugins/datasource/influxdb/datasource.ts
+25
-25
public/app/plugins/datasource/influxdb/partials/config.html
+14
-0
No files found.
pkg/api/pluginproxy/ds_proxy.go
View file @
9413ce5e
...
...
@@ -189,12 +189,6 @@ func (proxy *DataSourceProxy) getDirector() func(req *http.Request) {
}
func
(
proxy
*
DataSourceProxy
)
validateRequest
()
error
{
if
proxy
.
ds
.
Type
==
m
.
DS_INFLUXDB
{
if
proxy
.
ctx
.
Query
(
"db"
)
!=
proxy
.
ds
.
Database
{
return
errors
.
New
(
"Datasource is not configured to allow this database"
)
}
}
if
!
checkWhiteList
(
proxy
.
ctx
,
proxy
.
targetUrl
.
Host
)
{
return
errors
.
New
(
"Target url is not a valid target"
)
}
...
...
public/app/plugins/datasource/influxdb/datasource.ts
View file @
9413ce5e
...
...
@@ -82,7 +82,7 @@ export default class InfluxDatasource {
// replace templated variables
allQueries
=
this
.
templateSrv
.
replace
(
allQueries
,
scopedVars
);
return
this
.
_seriesQuery
(
allQueries
).
then
((
data
):
any
=>
{
return
this
.
_seriesQuery
(
allQueries
,
options
).
then
((
data
):
any
=>
{
if
(
!
data
||
!
data
.
results
)
{
return
[];
}
...
...
@@ -135,7 +135,7 @@ export default class InfluxDatasource {
var
query
=
options
.
annotation
.
query
.
replace
(
'$timeFilter'
,
timeFilter
);
query
=
this
.
templateSrv
.
replace
(
query
,
null
,
'regex'
);
return
this
.
_seriesQuery
(
query
).
then
(
data
=>
{
return
this
.
_seriesQuery
(
query
,
options
).
then
(
data
=>
{
if
(
!
data
||
!
data
.
results
||
!
data
.
results
[
0
])
{
throw
{
message
:
'No results in response from InfluxDB'
};
}
...
...
@@ -164,30 +164,30 @@ export default class InfluxDatasource {
return
false
;
}
metricFindQuery
(
query
)
{
metricFindQuery
(
query
:
string
,
options
?:
any
)
{
var
interpolated
=
this
.
templateSrv
.
replace
(
query
,
null
,
'regex'
);
return
this
.
_seriesQuery
(
interpolated
).
then
(
_
.
curry
(
this
.
responseParser
.
parse
)(
query
));
return
this
.
_seriesQuery
(
interpolated
,
options
).
then
(
_
.
curry
(
this
.
responseParser
.
parse
)(
query
));
}
getTagKeys
(
options
)
{
var
queryBuilder
=
new
InfluxQueryBuilder
({
measurement
:
''
,
tags
:
[]
},
this
.
database
);
var
query
=
queryBuilder
.
buildExploreQuery
(
'TAG_KEYS'
);
return
this
.
metricFindQuery
(
query
);
return
this
.
metricFindQuery
(
query
,
options
);
}
getTagValues
(
options
)
{
var
queryBuilder
=
new
InfluxQueryBuilder
({
measurement
:
''
,
tags
:
[]
},
this
.
database
);
var
query
=
queryBuilder
.
buildExploreQuery
(
'TAG_VALUES'
,
options
.
key
);
return
this
.
metricFindQuery
(
query
);
return
this
.
metricFindQuery
(
query
,
options
);
}
_seriesQuery
(
query
)
{
_seriesQuery
(
query
:
string
,
options
?:
any
)
{
if
(
!
query
)
{
return
this
.
$q
.
when
({
results
:
[]
});
}
return
this
.
_influxRequest
(
'GET'
,
'/query'
,
{
q
:
query
,
epoch
:
'ms'
});
return
this
.
_influxRequest
(
'GET'
,
'/query'
,
{
q
:
query
,
epoch
:
'ms'
}
,
options
);
}
serializeParams
(
params
)
{
...
...
@@ -225,21 +225,21 @@ export default class InfluxDatasource {
});
}
_influxRequest
(
method
,
url
,
data
)
{
var
self
=
this
;
_influxRequest
(
method
:
string
,
url
:
string
,
data
:
any
,
options
?:
any
)
{
const
currentUrl
=
this
.
urls
.
shift
();
this
.
urls
.
push
(
currentUrl
);
var
currentUrl
=
self
.
urls
.
shift
();
self
.
urls
.
push
(
currentUrl
);
let
params
:
any
=
{};
var
params
:
any
=
{};
if
(
self
.
username
)
{
params
.
u
=
self
.
username
;
params
.
p
=
self
.
password
;
if
(
this
.
username
)
{
params
.
u
=
this
.
username
;
params
.
p
=
this
.
password
;
}
if
(
self
.
database
)
{
params
.
db
=
self
.
database
;
if
(
options
&&
options
.
database
)
{
params
.
db
=
options
.
database
;
}
else
if
(
this
.
database
)
{
params
.
db
=
this
.
database
;
}
if
(
method
===
'GET'
)
{
...
...
@@ -247,7 +247,7 @@ export default class InfluxDatasource {
data
=
null
;
}
var
options
:
any
=
{
let
req
:
any
=
{
method
:
method
,
url
:
currentUrl
+
url
,
params
:
params
,
...
...
@@ -257,15 +257,15 @@ export default class InfluxDatasource {
paramSerializer
:
this
.
serializeParams
,
};
options
.
headers
=
options
.
headers
||
{};
req
.
headers
=
req
.
headers
||
{};
if
(
this
.
basicAuth
||
this
.
withCredentials
)
{
options
.
withCredentials
=
true
;
req
.
withCredentials
=
true
;
}
if
(
self
.
basicAuth
)
{
options
.
headers
.
Authorization
=
self
.
basicAuth
;
if
(
this
.
basicAuth
)
{
req
.
headers
.
Authorization
=
this
.
basicAuth
;
}
return
this
.
backendSrv
.
datasourceRequest
(
options
).
then
(
return
this
.
backendSrv
.
datasourceRequest
(
req
).
then
(
result
=>
{
return
result
.
data
;
},
...
...
public/app/plugins/datasource/influxdb/partials/config.html
View file @
9413ce5e
...
...
@@ -23,6 +23,20 @@
</div>
</div>
<div
class=
"gf-form-group"
>
<div
class=
"grafana-info-box"
>
<h5>
Database Access
</h5>
<p>
Setting the database for this datasource does not deny access to other databases. The InfluxDB query syntax allows
switching the database in the query. For example:
<code>
SHOW MEASUREMENTS ON _internal
</code>
or
<code>
SELECT * FROM "_internal".."database" LIMIT 10
</code>
<br/><br/>
To support data isolation and security, make sure appropriate permissions are configured in InfluxDB.
</p>
</div>
</div>
<div
class=
"gf-form-group"
>
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form"
>
...
...
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