mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Elasticsearch: use proper semver strings to identify ES version * Update BE & tests * refactor BE tests * refactor isValidOption check * update test * Update pkg/tsdb/elasticsearch/client/client.go Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> * Update pkg/tsdb/elasticsearch/client/search_request_test.go Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> * Remove leftover FIXME comment * Add new test cases for new version format * Docs: add documentation about version dropdown * Update docs/sources/datasources/elasticsearch.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/elasticsearch.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/elasticsearch.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update provisioning documentation Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package elasticsearch
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
es "github.com/grafana/grafana/pkg/tsdb/elasticsearch/client"
|
|
"github.com/grafana/grafana/pkg/tsdb/interval"
|
|
)
|
|
|
|
// ElasticsearchExecutor represents a handler for handling elasticsearch datasource request
|
|
type Executor struct {
|
|
intervalCalculator interval.Calculator
|
|
}
|
|
|
|
// NewExecutor creates a new Executor.
|
|
//nolint: staticcheck // plugins.DataPlugin deprecated
|
|
func NewExecutor(*models.DataSource) (plugins.DataPlugin, error) {
|
|
return &Executor{
|
|
intervalCalculator: interval.NewCalculator(),
|
|
}, nil
|
|
}
|
|
|
|
// Query handles an elasticsearch datasource request
|
|
//nolint: staticcheck // plugins.DataResponse deprecated
|
|
func (e *Executor) DataQuery(ctx context.Context, dsInfo *models.DataSource,
|
|
tsdbQuery plugins.DataQuery) (plugins.DataResponse, error) {
|
|
if len(tsdbQuery.Queries) == 0 {
|
|
return plugins.DataResponse{}, fmt.Errorf("query contains no queries")
|
|
}
|
|
|
|
client, err := es.NewClient(ctx, dsInfo, *tsdbQuery.TimeRange)
|
|
|
|
if err != nil {
|
|
return plugins.DataResponse{}, err
|
|
}
|
|
|
|
if tsdbQuery.Debug {
|
|
client.EnableDebug()
|
|
}
|
|
|
|
query := newTimeSeriesQuery(client, tsdbQuery, e.intervalCalculator)
|
|
return query.execute()
|
|
}
|