mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
InfluxDB: different config UI for 1x vs 2x (#25723)
This commit is contained in:
@@ -43,36 +43,18 @@ func init() {
|
||||
tsdb.RegisterTsdbQueryEndpoint("influxdb", NewInfluxDBExecutor)
|
||||
}
|
||||
|
||||
func AllFlux(queries *tsdb.TsdbQuery) (bool, error) {
|
||||
var hasFlux bool
|
||||
var allFlux bool
|
||||
for i, q := range queries.Queries {
|
||||
qType := q.Model.Get("queryType").MustString("")
|
||||
if qType == "Flux" {
|
||||
hasFlux = true
|
||||
if i == 0 && hasFlux {
|
||||
allFlux = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
if allFlux && qType != "Flux" {
|
||||
return true, fmt.Errorf("when using flux, all queries must be a flux query")
|
||||
}
|
||||
}
|
||||
return allFlux, nil
|
||||
}
|
||||
|
||||
func (e *InfluxDBExecutor) Query(ctx context.Context, dsInfo *models.DataSource, tsdbQuery *tsdb.TsdbQuery) (*tsdb.Response, error) {
|
||||
result := &tsdb.Response{}
|
||||
allFlux, err := AllFlux(tsdbQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if allFlux {
|
||||
glog.Info("query", "q", tsdbQuery.Queries)
|
||||
|
||||
version := dsInfo.JsonData.Get("version").MustString("")
|
||||
if version == "Flux" {
|
||||
return flux.Query(ctx, dsInfo, tsdbQuery)
|
||||
}
|
||||
|
||||
// NOTE: the following path is currently only called from alerting queries
|
||||
// In dashboards, the request runs through proxy and are managed in the frontend
|
||||
|
||||
query, err := e.getQuery(dsInfo, tsdbQuery.Queries, tsdbQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -120,6 +102,7 @@ func (e *InfluxDBExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
|
||||
return nil, response.Err
|
||||
}
|
||||
|
||||
result := &tsdb.Response{}
|
||||
result.Results = make(map[string]*tsdb.QueryResult)
|
||||
result.Results["A"] = e.ResponseParser.Parse(&response, query)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user