InfluxDB: SQL Support (#72167)
* Add influxdbSqlSupport feature toggle * Add SQL option to the config page * Add SQL backend * Add metadata support in config page * Implement unified querying * Fix healthcheck query * fsql tests * secure grpc by default * code cleanup * Query handing for sql mode * Implement a placeholder sql editor * Fix query language dropdown * go mod updates * make lint-go * more make lint-go * remove unused runQuery * switch statements with default case * linting again
This commit is contained in:
@@ -14,10 +14,12 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/datasource"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
||||
|
||||
"github.com/grafana/grafana/pkg/tsdb/influxdb/flux"
|
||||
"github.com/grafana/grafana/pkg/tsdb/influxdb/fsql"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/httpclient"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb/influxdb/flux"
|
||||
"github.com/grafana/grafana/pkg/tsdb/influxdb/models"
|
||||
)
|
||||
|
||||
@@ -57,22 +59,27 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading settings: %w", err)
|
||||
}
|
||||
|
||||
httpMode := jsonData.HTTPMode
|
||||
if httpMode == "" {
|
||||
httpMode = "GET"
|
||||
}
|
||||
|
||||
maxSeries := jsonData.MaxSeries
|
||||
if maxSeries == 0 {
|
||||
maxSeries = 1000
|
||||
}
|
||||
|
||||
version := jsonData.Version
|
||||
if version == "" {
|
||||
version = influxVersionInfluxQL
|
||||
}
|
||||
|
||||
database := jsonData.DbName
|
||||
if database == "" {
|
||||
database = settings.Database
|
||||
}
|
||||
|
||||
model := &models.DatasourceInfo{
|
||||
HTTPClient: client,
|
||||
URL: settings.URL,
|
||||
@@ -82,7 +89,9 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
|
||||
TimeInterval: jsonData.TimeInterval,
|
||||
DefaultBucket: jsonData.DefaultBucket,
|
||||
Organization: jsonData.Organization,
|
||||
Metadata: jsonData.Metadata,
|
||||
MaxSeries: maxSeries,
|
||||
SecureGrpc: true,
|
||||
Token: settings.DecryptedSecureJSONData["token"],
|
||||
}
|
||||
return model, nil
|
||||
@@ -98,9 +107,12 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
|
||||
return nil, err
|
||||
}
|
||||
version := dsInfo.Version
|
||||
if version == "Flux" {
|
||||
if version == influxVersionFlux {
|
||||
return flux.Query(ctx, dsInfo, *req)
|
||||
}
|
||||
if version == influxVersionSQL {
|
||||
return fsql.Query(ctx, dsInfo, *req)
|
||||
}
|
||||
|
||||
logger.Debug("Making a non-Flux type query")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user