mirror of
https://github.com/grafana/grafana.git
synced 2026-08-10 05:08:16 -05:00
Add a setting to allow DB queries
This commit is contained in:
@@ -166,7 +166,9 @@ 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(!proxy.ds.JsonData.Get("allowDatabaseQuery").MustBool(false)) {
|
||||
return errors.New("Datasource is not configured to allow this database");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ export default class InfluxDatasource {
|
||||
basicAuth: any;
|
||||
withCredentials: any;
|
||||
interval: any;
|
||||
allowDatabaseQuery: boolean;
|
||||
supportAnnotations: boolean;
|
||||
supportMetrics: boolean;
|
||||
responseParser: any;
|
||||
@@ -35,6 +36,7 @@ export default class InfluxDatasource {
|
||||
this.basicAuth = instanceSettings.basicAuth;
|
||||
this.withCredentials = instanceSettings.withCredentials;
|
||||
this.interval = (instanceSettings.jsonData || {}).timeInterval;
|
||||
this.allowDatabaseQuery = (instanceSettings.jsonData || {}).allowDatabaseQuery === true;
|
||||
this.supportAnnotations = true;
|
||||
this.supportMetrics = true;
|
||||
this.responseParser = new ResponseParser();
|
||||
@@ -214,6 +216,9 @@ export default class InfluxDatasource {
|
||||
|
||||
if (options && options.database) {
|
||||
params.db = options.database;
|
||||
if (params.db !== this.database && !this.allowDatabaseQuery) {
|
||||
return this.$q.reject( { message: 'This datasource does not allow changing database' } );
|
||||
}
|
||||
} else if (this.database) {
|
||||
params.db = this.database;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form"
|
||||
label="Allow Database Queries"
|
||||
label-class="gf-form-label width-14"
|
||||
checked="ctrl.current.jsonData.allowDatabaseQuery"
|
||||
tooltip="Support changing the database from a query"></gf-form-switch>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label">Min time interval</span>
|
||||
<span class="gf-form-label width-14">Min time interval</span>
|
||||
<input type="text" class="gf-form-input width-6" ng-model="ctrl.current.jsonData.timeInterval" spellcheck='false' placeholder="10s"></input>
|
||||
<info-popover mode="right-absolute">
|
||||
A lower limit for the auto group by time interval. Recommended to be set to write frequency,
|
||||
|
||||
Reference in New Issue
Block a user