import { i18n } from '@osd/i18n' ; import { MetricAggType } from './metric_agg_type' ; import { parentPipelineAggHelper } from './lib/parent_pipeline_agg_helper' ; import { makeNestedLabel } from './lib/make_nested_label' ; import { METRIC_TYPES } from './metric_agg_types' ; import { AggConfigSerialized , BaseAggParams } from '../types' ; export interface AggParamsDerivative extends BaseAggParams { buckets_path : string ; customMetric ? : AggConfigSerialized ; metricAgg ? : string ; } const derivativeLabel = i18n . translate ( 'data.search.aggs.metrics.derivativeLabel' , { defaultMessage : 'derivative' , } ) ; const derivativeTitle = i18n . translate ( 'data.search.aggs.metrics.derivativeTitle' , { defaultMessage : 'Derivative' , } ) ; export const getDerivativeMetricAgg = ( ) => { const { subtype , params , getSerializedFormat } = parentPipelineAggHelper ; return new MetricAggType ( { name : METRIC_TYPES . DERIVATIVE , title : derivativeTitle , makeLabel ( agg ) { return makeNestedLabel ( agg , derivativeLabel ) ; } , subtype , params : [ ... params ( ) ] , getSerializedFormat , } ) ; } ;