Elasticsearch: use semver strings to identify ES version (#33646)

* 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>
This commit is contained in:
Giordano Ricci
2021-05-11 09:44:00 +01:00
committed by GitHub
parent 1a504ce673
commit e98a8bd11b
26 changed files with 363 additions and 242 deletions

View File

@@ -21,6 +21,7 @@ import {
MetricAggregationType,
} from './aggregations';
import { useFields } from '../../../hooks/useFields';
import { satisfies } from 'semver';
const toOption = (metric: MetricAggregation) => ({
label: metricAggregationConfig[metric.type].label,
@@ -39,7 +40,7 @@ const isBasicAggregation = (metric: MetricAggregation) => !metricAggregationConf
const getTypeOptions = (
previousMetrics: MetricAggregation[],
esVersion: number
esVersion: string
): Array<SelectableValue<MetricAggregationType>> => {
// we'll include Pipeline Aggregations only if at least one previous metric is a "Basic" one
const includePipelineAggregations = previousMetrics.some(isBasicAggregation);
@@ -47,10 +48,7 @@ const getTypeOptions = (
return (
Object.entries(metricAggregationConfig)
// Only showing metrics type supported by the configured version of ES
.filter(([_, { minVersion = 0, maxVersion = esVersion }]) => {
// TODO: Double check this
return esVersion >= minVersion && esVersion <= maxVersion;
})
.filter(([_, { versionRange = '*' }]) => satisfies(esVersion, versionRange))
// Filtering out Pipeline Aggregations if there's no basic metric selected before
.filter(([_, config]) => includePipelineAggregations || !config.isPipelineAgg)
.map(([key, { label }]) => ({

View File

@@ -112,7 +112,7 @@ export const metricAggregationConfig: MetricsConfiguration = {
label: 'Moving Average',
requiresField: true,
isPipelineAgg: true,
minVersion: 2,
versionRange: '>=2.0.0',
supportsMissing: false,
supportsMultipleBucketPaths: false,
hasSettings: true,
@@ -135,14 +135,14 @@ export const metricAggregationConfig: MetricsConfiguration = {
supportsMissing: false,
hasMeta: false,
hasSettings: true,
minVersion: 70,
versionRange: '>=7.0.0',
defaults: {},
},
derivative: {
label: 'Derivative',
requiresField: true,
isPipelineAgg: true,
minVersion: 2,
versionRange: '>=2.0.0',
supportsMissing: false,
supportsMultipleBucketPaths: false,
hasSettings: true,
@@ -154,7 +154,7 @@ export const metricAggregationConfig: MetricsConfiguration = {
label: 'Serial Difference',
requiresField: true,
isPipelineAgg: true,
minVersion: 2,
versionRange: '>=2.0.0',
supportsMissing: false,
supportsMultipleBucketPaths: false,
hasSettings: true,
@@ -170,7 +170,7 @@ export const metricAggregationConfig: MetricsConfiguration = {
label: 'Cumulative Sum',
requiresField: true,
isPipelineAgg: true,
minVersion: 2,
versionRange: '>=2.0.0',
supportsMissing: false,
supportsMultipleBucketPaths: false,
hasSettings: true,
@@ -184,7 +184,7 @@ export const metricAggregationConfig: MetricsConfiguration = {
isPipelineAgg: true,
supportsMissing: false,
supportsMultipleBucketPaths: true,
minVersion: 2,
versionRange: '>=2.0.0',
hasSettings: true,
supportsInlineScript: false,
hasMeta: false,