From 506f9399c1bff7b1ea5944d2d1f7afe30491283d Mon Sep 17 00:00:00 2001 From: Ester Marti Date: Thu, 22 Apr 2021 12:03:24 +0200 Subject: [PATCH] Elasticsearch: add first version of rate aggregation --- .../SettingsEditor/index.tsx | 40 ++++++++++++++++++- .../MetricAggregationsEditor/aggregations.ts | 13 +++++- .../MetricAggregationsEditor/utils.ts | 11 +++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx b/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx index 3c5a65f7170..89a320a33b1 100644 --- a/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx +++ b/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx @@ -1,4 +1,4 @@ -import { InlineField, Input, InlineSwitch } from '@grafana/ui'; +import { InlineField, Input, InlineSwitch, Select } from '@grafana/ui'; import React, { FunctionComponent, ComponentProps, useState } from 'react'; import { extendedStats } from '../../../../query_def'; import { useDispatch } from '../../../../hooks/useStatelessReducer'; @@ -33,6 +33,22 @@ export const SettingsEditor: FunctionComponent = ({ metric, previousMetri const description = useDescription(metric); const query = useQuery(); + const rateAggUnitOptions = [ + { value: 'seconds', label: 'Seconds' }, + { value: 'minute', label: 'Minute' }, + { value: 'hour', label: 'Hour' }, + { value: 'day', label: 'Day' }, + { value: 'week', label: 'Week' }, + { value: 'month', label: 'Month' }, + { value: 'quarter', label: 'Quarter' }, + { value: 'Year', label: 'Year' }, + ]; + + const rateAggModeOptions = [ + { value: 'sum', label: 'Sum' }, + { value: 'value_count', label: 'Value count' }, + ]; + return (