InfluxDB: different config UI for 1x vs 2x (#25723)

This commit is contained in:
Ryan McKinley
2020-06-22 13:03:34 -07:00
committed by GitHub
parent 0797fe88a1
commit 8d1ed33e20
13 changed files with 1277 additions and 889 deletions

View File

@@ -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)