mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Fix script fields in query editor (#31681)
* Elasticsearch: Fix script fields in query editor * properly name bucke_script deries
This commit is contained in:
@@ -9,10 +9,12 @@ import {
|
||||
isMetricAggregationWithSettings,
|
||||
isPipelineAggregation,
|
||||
isPipelineAggregationWithMultipleBucketPaths,
|
||||
MetricAggregation,
|
||||
MetricAggregationWithInlineScript,
|
||||
} from './components/QueryEditor/MetricAggregationsEditor/aggregations';
|
||||
import { defaultBucketAgg, defaultMetricAgg, findMetricById, highlightTags } from './query_def';
|
||||
import { ElasticsearchQuery } from './types';
|
||||
import { convertOrderByToMetricId } from './utils';
|
||||
import { convertOrderByToMetricId, getScriptValue } from './utils';
|
||||
|
||||
export class ElasticQueryBuilder {
|
||||
timeField: string;
|
||||
@@ -204,8 +206,9 @@ export class ElasticQueryBuilder {
|
||||
target.metrics = target.metrics || [defaultMetricAgg()];
|
||||
target.bucketAggs = target.bucketAggs || [defaultBucketAgg()];
|
||||
target.timeField = this.timeField;
|
||||
let metric: MetricAggregation;
|
||||
|
||||
let i, j, pv, nestedAggs, metric;
|
||||
let i, j, pv, nestedAggs;
|
||||
const query = {
|
||||
size: 0,
|
||||
query: {
|
||||
@@ -340,7 +343,9 @@ export class ElasticQueryBuilder {
|
||||
if (isMetricAggregationWithSettings(metric)) {
|
||||
Object.entries(metric.settings || {})
|
||||
.filter(([_, v]) => v !== null)
|
||||
.forEach(([k, v]) => (metricAgg[k] = v));
|
||||
.forEach(([k, v]) => {
|
||||
metricAgg[k] = k === 'script' ? getScriptValue(metric as MetricAggregationWithInlineScript) : v;
|
||||
});
|
||||
}
|
||||
|
||||
aggField[metric.type] = metricAgg;
|
||||
|
||||
Reference in New Issue
Block a user