diff --git a/docs/sources/developers/kinds/composable/elasticsearchdataquery/schema-reference.md b/docs/sources/developers/kinds/composable/elasticsearchdataquery/schema-reference.md new file mode 100644 index 00000000000..5688055d5c3 --- /dev/null +++ b/docs/sources/developers/kinds/composable/elasticsearchdataquery/schema-reference.md @@ -0,0 +1,34 @@ +--- +keywords: + - grafana + - schema +title: ElasticsearchDataQuery kind +--- +> Both documentation generation and kinds schemas are in active development and subject to change without prior notice. + +# ElasticsearchDataQuery kind + +## Maturity: merged +## Version: 0.0 + +## Properties + +| Property | Type | Required | Description | +|--------------|-------------------------------------------|----------|-------------| +| `alias` | string | No | | +| `bucketAggs` | [BucketAggregation](#bucketaggregation)[] | No | | +| `metrics` | [MetricAggregation](#metricaggregation)[] | No | | +| `query` | string | No | | +| `timeField` | string | No | | + +## BucketAggregation + +| Property | Type | Required | Description | +|----------|------|----------|-------------| + +## MetricAggregation + +| Property | Type | Required | Description | +|----------|------|----------|-------------| + + diff --git a/pkg/kindsys/report.json b/pkg/kindsys/report.json index e5cd4f7ba01..1e3fe9c0ddb 100644 --- a/pkg/kindsys/report.json +++ b/pkg/kindsys/report.json @@ -426,7 +426,9 @@ }, "elasticsearchdataquery": { "category": "composable", - "codeowners": [], + "codeowners": [ + "grafana/observability-logs" + ], "currentVersion": [ 0, 0 @@ -434,13 +436,13 @@ "grafanaMaturityCount": 0, "lineageIsGroup": false, "links": { - "docs": "n/a", - "go": "n/a", - "schema": "n/a", - "ts": "n/a" + "docs": "https://grafana.com/docs/grafana/next/developers/kinds/composable/elasticsearchdataquery/schema-reference", + "go": "https://github.com/grafana/grafana/tree/main/pkg/tsdb/elasticsearch/kinds/dataquery/types_dataquery_gen.go", + "schema": "https://github.com/grafana/grafana/tree/main/public/app/plugins/datasource/elasticsearch/dataquery.cue", + "ts": "https://github.com/grafana/grafana/tree/main/public/app/plugins/datasource/elasticsearch/dataquery.gen.ts" }, "machineName": "elasticsearchdataquery", - "maturity": "planned", + "maturity": "merged", "name": "ElasticsearchDataQuery", "pluralMachineName": "elasticsearchdataquerys", "pluralName": "ElasticsearchDataQuerys", @@ -2002,13 +2004,14 @@ "name": "merged", "items": [ "alertgroupspanelcfg", + "elasticsearchdataquery", "playlist", "preferences", "publicdashboard", "serviceaccount", "team" ], - "count": 6 + "count": 7 }, "planned": { "name": "planned", @@ -2025,7 +2028,6 @@ "dashboarddatasourcecfg", "datasource", "debugpanelcfg", - "elasticsearchdataquery", "elasticsearchdatasourcecfg", "flamegraphpanelcfg", "folder", @@ -2068,7 +2070,7 @@ "zipkindataquery", "zipkindatasourcecfg" ], - "count": 54 + "count": 53 }, "stable": { "name": "stable", diff --git a/pkg/tsdb/elasticsearch/kinds/dataquery/types_dataquery_gen.go b/pkg/tsdb/elasticsearch/kinds/dataquery/types_dataquery_gen.go new file mode 100644 index 00000000000..ddaa18901b9 --- /dev/null +++ b/pkg/tsdb/elasticsearch/kinds/dataquery/types_dataquery_gen.go @@ -0,0 +1,1290 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. +// +// Generated by: +// public/app/plugins/gen.go +// Using jennies: +// PluginGoTypesJenny +// +// Run 'make gen-cue' from repository root to regenerate. + +package dataquery + +// Defines values for AverageType. +const ( + AverageTypeAvg AverageType = "avg" +) + +// Defines values for BaseBucketAggregationType. +const ( + BaseBucketAggregationTypeDateHistogram BaseBucketAggregationType = "date_histogram" + + BaseBucketAggregationTypeFilters BaseBucketAggregationType = "filters" + + BaseBucketAggregationTypeGeohashGrid BaseBucketAggregationType = "geohash_grid" + + BaseBucketAggregationTypeHistogram BaseBucketAggregationType = "histogram" + + BaseBucketAggregationTypeNested BaseBucketAggregationType = "nested" + + BaseBucketAggregationTypeTerms BaseBucketAggregationType = "terms" +) + +// Defines values for BaseMetricAggregationType. +const ( + BaseMetricAggregationTypeAvg BaseMetricAggregationType = "avg" + + BaseMetricAggregationTypeBucketScript BaseMetricAggregationType = "bucket_script" + + BaseMetricAggregationTypeCardinality BaseMetricAggregationType = "cardinality" + + BaseMetricAggregationTypeCount BaseMetricAggregationType = "count" + + BaseMetricAggregationTypeCumulativeSum BaseMetricAggregationType = "cumulative_sum" + + BaseMetricAggregationTypeDerivative BaseMetricAggregationType = "derivative" + + BaseMetricAggregationTypeExtendedStats BaseMetricAggregationType = "extended_stats" + + BaseMetricAggregationTypeLogs BaseMetricAggregationType = "logs" + + BaseMetricAggregationTypeMax BaseMetricAggregationType = "max" + + BaseMetricAggregationTypeMin BaseMetricAggregationType = "min" + + BaseMetricAggregationTypeMovingAvg BaseMetricAggregationType = "moving_avg" + + BaseMetricAggregationTypeMovingFn BaseMetricAggregationType = "moving_fn" + + BaseMetricAggregationTypePercentiles BaseMetricAggregationType = "percentiles" + + BaseMetricAggregationTypeRate BaseMetricAggregationType = "rate" + + BaseMetricAggregationTypeRawData BaseMetricAggregationType = "raw_data" + + BaseMetricAggregationTypeRawDocument BaseMetricAggregationType = "raw_document" + + BaseMetricAggregationTypeSerialDiff BaseMetricAggregationType = "serial_diff" + + BaseMetricAggregationTypeSum BaseMetricAggregationType = "sum" + + BaseMetricAggregationTypeTopMetrics BaseMetricAggregationType = "top_metrics" +) + +// Defines values for BaseMovingAverageModelSettingsModel. +const ( + BaseMovingAverageModelSettingsModelEwma BaseMovingAverageModelSettingsModel = "ewma" + + BaseMovingAverageModelSettingsModelHolt BaseMovingAverageModelSettingsModel = "holt" + + BaseMovingAverageModelSettingsModelHoltWinters BaseMovingAverageModelSettingsModel = "holt_winters" + + BaseMovingAverageModelSettingsModelLinear BaseMovingAverageModelSettingsModel = "linear" + + BaseMovingAverageModelSettingsModelSimple BaseMovingAverageModelSettingsModel = "simple" +) + +// Defines values for BasePipelineMetricAggregationType. +const ( + BasePipelineMetricAggregationTypeAvg BasePipelineMetricAggregationType = "avg" + + BasePipelineMetricAggregationTypeBucketScript BasePipelineMetricAggregationType = "bucket_script" + + BasePipelineMetricAggregationTypeCardinality BasePipelineMetricAggregationType = "cardinality" + + BasePipelineMetricAggregationTypeCount BasePipelineMetricAggregationType = "count" + + BasePipelineMetricAggregationTypeCumulativeSum BasePipelineMetricAggregationType = "cumulative_sum" + + BasePipelineMetricAggregationTypeDerivative BasePipelineMetricAggregationType = "derivative" + + BasePipelineMetricAggregationTypeExtendedStats BasePipelineMetricAggregationType = "extended_stats" + + BasePipelineMetricAggregationTypeLogs BasePipelineMetricAggregationType = "logs" + + BasePipelineMetricAggregationTypeMax BasePipelineMetricAggregationType = "max" + + BasePipelineMetricAggregationTypeMin BasePipelineMetricAggregationType = "min" + + BasePipelineMetricAggregationTypeMovingAvg BasePipelineMetricAggregationType = "moving_avg" + + BasePipelineMetricAggregationTypeMovingFn BasePipelineMetricAggregationType = "moving_fn" + + BasePipelineMetricAggregationTypePercentiles BasePipelineMetricAggregationType = "percentiles" + + BasePipelineMetricAggregationTypeRate BasePipelineMetricAggregationType = "rate" + + BasePipelineMetricAggregationTypeRawData BasePipelineMetricAggregationType = "raw_data" + + BasePipelineMetricAggregationTypeRawDocument BasePipelineMetricAggregationType = "raw_document" + + BasePipelineMetricAggregationTypeSerialDiff BasePipelineMetricAggregationType = "serial_diff" + + BasePipelineMetricAggregationTypeSum BasePipelineMetricAggregationType = "sum" + + BasePipelineMetricAggregationTypeTopMetrics BasePipelineMetricAggregationType = "top_metrics" +) + +// Defines values for BucketAggregationType. +const ( + BucketAggregationTypeDateHistogram BucketAggregationType = "date_histogram" + + BucketAggregationTypeFilters BucketAggregationType = "filters" + + BucketAggregationTypeGeohashGrid BucketAggregationType = "geohash_grid" + + BucketAggregationTypeHistogram BucketAggregationType = "histogram" + + BucketAggregationTypeNested BucketAggregationType = "nested" + + BucketAggregationTypeTerms BucketAggregationType = "terms" +) + +// Defines values for BucketAggregationWithFieldType. +const ( + BucketAggregationWithFieldTypeDateHistogram BucketAggregationWithFieldType = "date_histogram" + + BucketAggregationWithFieldTypeFilters BucketAggregationWithFieldType = "filters" + + BucketAggregationWithFieldTypeGeohashGrid BucketAggregationWithFieldType = "geohash_grid" + + BucketAggregationWithFieldTypeHistogram BucketAggregationWithFieldType = "histogram" + + BucketAggregationWithFieldTypeNested BucketAggregationWithFieldType = "nested" + + BucketAggregationWithFieldTypeTerms BucketAggregationWithFieldType = "terms" +) + +// Defines values for BucketScriptType. +const ( + BucketScriptTypeBucketScript BucketScriptType = "bucket_script" +) + +// Defines values for CountType. +const ( + CountTypeCount CountType = "count" +) + +// Defines values for CumulativeSumType. +const ( + CumulativeSumTypeCumulativeSum CumulativeSumType = "cumulative_sum" +) + +// Defines values for DateHistogramType. +const ( + DateHistogramTypeDateHistogram DateHistogramType = "date_histogram" +) + +// Defines values for DerivativeType. +const ( + DerivativeTypeDerivative DerivativeType = "derivative" +) + +// Defines values for ExtendedStatValue. +const ( + ExtendedStatValueAvg ExtendedStatValue = "avg" + + ExtendedStatValueCount ExtendedStatValue = "count" + + ExtendedStatValueMax ExtendedStatValue = "max" + + ExtendedStatValueMin ExtendedStatValue = "min" + + ExtendedStatValueStdDeviation ExtendedStatValue = "std_deviation" + + ExtendedStatValueStdDeviationBoundsLower ExtendedStatValue = "std_deviation_bounds_lower" + + ExtendedStatValueStdDeviationBoundsUpper ExtendedStatValue = "std_deviation_bounds_upper" + + ExtendedStatValueSum ExtendedStatValue = "sum" +) + +// Defines values for ExtendedStatMetaType. +const ( + ExtendedStatMetaTypeAvg ExtendedStatMetaType = "avg" + + ExtendedStatMetaTypeCount ExtendedStatMetaType = "count" + + ExtendedStatMetaTypeMax ExtendedStatMetaType = "max" + + ExtendedStatMetaTypeMin ExtendedStatMetaType = "min" + + ExtendedStatMetaTypeStdDeviation ExtendedStatMetaType = "std_deviation" + + ExtendedStatMetaTypeStdDeviationBoundsLower ExtendedStatMetaType = "std_deviation_bounds_lower" + + ExtendedStatMetaTypeStdDeviationBoundsUpper ExtendedStatMetaType = "std_deviation_bounds_upper" + + ExtendedStatMetaTypeSum ExtendedStatMetaType = "sum" +) + +// Defines values for ExtendedStatsType. +const ( + ExtendedStatsTypeExtendedStats ExtendedStatsType = "extended_stats" +) + +// Defines values for FiltersType. +const ( + FiltersTypeFilters FiltersType = "filters" +) + +// Defines values for GeoHashGridType. +const ( + GeoHashGridTypeGeohashGrid GeoHashGridType = "geohash_grid" +) + +// Defines values for HistogramType. +const ( + HistogramTypeHistogram HistogramType = "histogram" +) + +// Defines values for LogsType. +const ( + LogsTypeLogs LogsType = "logs" +) + +// Defines values for MaxType. +const ( + MaxTypeMax MaxType = "max" +) + +// Defines values for MetricAggregationType. +const ( + MetricAggregationTypeAvg MetricAggregationType = "avg" + + MetricAggregationTypeBucketScript MetricAggregationType = "bucket_script" + + MetricAggregationTypeCardinality MetricAggregationType = "cardinality" + + MetricAggregationTypeCount MetricAggregationType = "count" + + MetricAggregationTypeCumulativeSum MetricAggregationType = "cumulative_sum" + + MetricAggregationTypeDerivative MetricAggregationType = "derivative" + + MetricAggregationTypeExtendedStats MetricAggregationType = "extended_stats" + + MetricAggregationTypeLogs MetricAggregationType = "logs" + + MetricAggregationTypeMax MetricAggregationType = "max" + + MetricAggregationTypeMin MetricAggregationType = "min" + + MetricAggregationTypeMovingAvg MetricAggregationType = "moving_avg" + + MetricAggregationTypeMovingFn MetricAggregationType = "moving_fn" + + MetricAggregationTypePercentiles MetricAggregationType = "percentiles" + + MetricAggregationTypeRate MetricAggregationType = "rate" + + MetricAggregationTypeRawData MetricAggregationType = "raw_data" + + MetricAggregationTypeRawDocument MetricAggregationType = "raw_document" + + MetricAggregationTypeSerialDiff MetricAggregationType = "serial_diff" + + MetricAggregationTypeSum MetricAggregationType = "sum" + + MetricAggregationTypeTopMetrics MetricAggregationType = "top_metrics" +) + +// Defines values for MetricAggregationWithFieldType. +const ( + MetricAggregationWithFieldTypeAvg MetricAggregationWithFieldType = "avg" + + MetricAggregationWithFieldTypeBucketScript MetricAggregationWithFieldType = "bucket_script" + + MetricAggregationWithFieldTypeCardinality MetricAggregationWithFieldType = "cardinality" + + MetricAggregationWithFieldTypeCount MetricAggregationWithFieldType = "count" + + MetricAggregationWithFieldTypeCumulativeSum MetricAggregationWithFieldType = "cumulative_sum" + + MetricAggregationWithFieldTypeDerivative MetricAggregationWithFieldType = "derivative" + + MetricAggregationWithFieldTypeExtendedStats MetricAggregationWithFieldType = "extended_stats" + + MetricAggregationWithFieldTypeLogs MetricAggregationWithFieldType = "logs" + + MetricAggregationWithFieldTypeMax MetricAggregationWithFieldType = "max" + + MetricAggregationWithFieldTypeMin MetricAggregationWithFieldType = "min" + + MetricAggregationWithFieldTypeMovingAvg MetricAggregationWithFieldType = "moving_avg" + + MetricAggregationWithFieldTypeMovingFn MetricAggregationWithFieldType = "moving_fn" + + MetricAggregationWithFieldTypePercentiles MetricAggregationWithFieldType = "percentiles" + + MetricAggregationWithFieldTypeRate MetricAggregationWithFieldType = "rate" + + MetricAggregationWithFieldTypeRawData MetricAggregationWithFieldType = "raw_data" + + MetricAggregationWithFieldTypeRawDocument MetricAggregationWithFieldType = "raw_document" + + MetricAggregationWithFieldTypeSerialDiff MetricAggregationWithFieldType = "serial_diff" + + MetricAggregationWithFieldTypeSum MetricAggregationWithFieldType = "sum" + + MetricAggregationWithFieldTypeTopMetrics MetricAggregationWithFieldType = "top_metrics" +) + +// Defines values for MetricAggregationWithInlineScriptType. +const ( + MetricAggregationWithInlineScriptTypeAvg MetricAggregationWithInlineScriptType = "avg" + + MetricAggregationWithInlineScriptTypeBucketScript MetricAggregationWithInlineScriptType = "bucket_script" + + MetricAggregationWithInlineScriptTypeCardinality MetricAggregationWithInlineScriptType = "cardinality" + + MetricAggregationWithInlineScriptTypeCount MetricAggregationWithInlineScriptType = "count" + + MetricAggregationWithInlineScriptTypeCumulativeSum MetricAggregationWithInlineScriptType = "cumulative_sum" + + MetricAggregationWithInlineScriptTypeDerivative MetricAggregationWithInlineScriptType = "derivative" + + MetricAggregationWithInlineScriptTypeExtendedStats MetricAggregationWithInlineScriptType = "extended_stats" + + MetricAggregationWithInlineScriptTypeLogs MetricAggregationWithInlineScriptType = "logs" + + MetricAggregationWithInlineScriptTypeMax MetricAggregationWithInlineScriptType = "max" + + MetricAggregationWithInlineScriptTypeMin MetricAggregationWithInlineScriptType = "min" + + MetricAggregationWithInlineScriptTypeMovingAvg MetricAggregationWithInlineScriptType = "moving_avg" + + MetricAggregationWithInlineScriptTypeMovingFn MetricAggregationWithInlineScriptType = "moving_fn" + + MetricAggregationWithInlineScriptTypePercentiles MetricAggregationWithInlineScriptType = "percentiles" + + MetricAggregationWithInlineScriptTypeRate MetricAggregationWithInlineScriptType = "rate" + + MetricAggregationWithInlineScriptTypeRawData MetricAggregationWithInlineScriptType = "raw_data" + + MetricAggregationWithInlineScriptTypeRawDocument MetricAggregationWithInlineScriptType = "raw_document" + + MetricAggregationWithInlineScriptTypeSerialDiff MetricAggregationWithInlineScriptType = "serial_diff" + + MetricAggregationWithInlineScriptTypeSum MetricAggregationWithInlineScriptType = "sum" + + MetricAggregationWithInlineScriptTypeTopMetrics MetricAggregationWithInlineScriptType = "top_metrics" +) + +// Defines values for MetricAggregationWithMissingSupportType. +const ( + MetricAggregationWithMissingSupportTypeAvg MetricAggregationWithMissingSupportType = "avg" + + MetricAggregationWithMissingSupportTypeBucketScript MetricAggregationWithMissingSupportType = "bucket_script" + + MetricAggregationWithMissingSupportTypeCardinality MetricAggregationWithMissingSupportType = "cardinality" + + MetricAggregationWithMissingSupportTypeCount MetricAggregationWithMissingSupportType = "count" + + MetricAggregationWithMissingSupportTypeCumulativeSum MetricAggregationWithMissingSupportType = "cumulative_sum" + + MetricAggregationWithMissingSupportTypeDerivative MetricAggregationWithMissingSupportType = "derivative" + + MetricAggregationWithMissingSupportTypeExtendedStats MetricAggregationWithMissingSupportType = "extended_stats" + + MetricAggregationWithMissingSupportTypeLogs MetricAggregationWithMissingSupportType = "logs" + + MetricAggregationWithMissingSupportTypeMax MetricAggregationWithMissingSupportType = "max" + + MetricAggregationWithMissingSupportTypeMin MetricAggregationWithMissingSupportType = "min" + + MetricAggregationWithMissingSupportTypeMovingAvg MetricAggregationWithMissingSupportType = "moving_avg" + + MetricAggregationWithMissingSupportTypeMovingFn MetricAggregationWithMissingSupportType = "moving_fn" + + MetricAggregationWithMissingSupportTypePercentiles MetricAggregationWithMissingSupportType = "percentiles" + + MetricAggregationWithMissingSupportTypeRate MetricAggregationWithMissingSupportType = "rate" + + MetricAggregationWithMissingSupportTypeRawData MetricAggregationWithMissingSupportType = "raw_data" + + MetricAggregationWithMissingSupportTypeRawDocument MetricAggregationWithMissingSupportType = "raw_document" + + MetricAggregationWithMissingSupportTypeSerialDiff MetricAggregationWithMissingSupportType = "serial_diff" + + MetricAggregationWithMissingSupportTypeSum MetricAggregationWithMissingSupportType = "sum" + + MetricAggregationWithMissingSupportTypeTopMetrics MetricAggregationWithMissingSupportType = "top_metrics" +) + +// Defines values for MinType. +const ( + MinTypeMin MinType = "min" +) + +// Defines values for MovingAverageType. +const ( + MovingAverageTypeMovingAvg MovingAverageType = "moving_avg" +) + +// Defines values for MovingAverageEWMAModelSettingsModel. +const ( + MovingAverageEWMAModelSettingsModelEwma MovingAverageEWMAModelSettingsModel = "ewma" +) + +// Defines values for MovingAverageHoltModelSettingsModel. +const ( + MovingAverageHoltModelSettingsModelHolt MovingAverageHoltModelSettingsModel = "holt" +) + +// Defines values for MovingAverageHoltWintersModelSettingsModel. +const ( + MovingAverageHoltWintersModelSettingsModelHoltWinters MovingAverageHoltWintersModelSettingsModel = "holt_winters" +) + +// Defines values for MovingAverageLinearModelSettingsModel. +const ( + MovingAverageLinearModelSettingsModelLinear MovingAverageLinearModelSettingsModel = "linear" +) + +// Defines values for MovingAverageModel. +const ( + MovingAverageModelEwma MovingAverageModel = "ewma" + + MovingAverageModelHolt MovingAverageModel = "holt" + + MovingAverageModelHoltWinters MovingAverageModel = "holt_winters" + + MovingAverageModelLinear MovingAverageModel = "linear" + + MovingAverageModelSimple MovingAverageModel = "simple" +) + +// Defines values for MovingAverageModelOptionValue. +const ( + MovingAverageModelOptionValueEwma MovingAverageModelOptionValue = "ewma" + + MovingAverageModelOptionValueHolt MovingAverageModelOptionValue = "holt" + + MovingAverageModelOptionValueHoltWinters MovingAverageModelOptionValue = "holt_winters" + + MovingAverageModelOptionValueLinear MovingAverageModelOptionValue = "linear" + + MovingAverageModelOptionValueSimple MovingAverageModelOptionValue = "simple" +) + +// Defines values for MovingAverageSimpleModelSettingsModel. +const ( + MovingAverageSimpleModelSettingsModelSimple MovingAverageSimpleModelSettingsModel = "simple" +) + +// Defines values for MovingFunctionType. +const ( + MovingFunctionTypeMovingFn MovingFunctionType = "moving_fn" +) + +// Defines values for NestedType. +const ( + NestedTypeNested NestedType = "nested" +) + +// Defines values for PercentilesType. +const ( + PercentilesTypePercentiles PercentilesType = "percentiles" +) + +// Defines values for PipelineMetricAggregationType. +const ( + PipelineMetricAggregationTypeBucketScript PipelineMetricAggregationType = "bucket_script" + + PipelineMetricAggregationTypeCumulativeSum PipelineMetricAggregationType = "cumulative_sum" + + PipelineMetricAggregationTypeDerivative PipelineMetricAggregationType = "derivative" + + PipelineMetricAggregationTypeMovingAvg PipelineMetricAggregationType = "moving_avg" + + PipelineMetricAggregationTypeMovingFn PipelineMetricAggregationType = "moving_fn" + + PipelineMetricAggregationTypeSerialDiff PipelineMetricAggregationType = "serial_diff" +) + +// Defines values for PipelineMetricAggregationWithMultipleBucketPathsType. +const ( + PipelineMetricAggregationWithMultipleBucketPathsTypeAvg PipelineMetricAggregationWithMultipleBucketPathsType = "avg" + + PipelineMetricAggregationWithMultipleBucketPathsTypeBucketScript PipelineMetricAggregationWithMultipleBucketPathsType = "bucket_script" + + PipelineMetricAggregationWithMultipleBucketPathsTypeCardinality PipelineMetricAggregationWithMultipleBucketPathsType = "cardinality" + + PipelineMetricAggregationWithMultipleBucketPathsTypeCount PipelineMetricAggregationWithMultipleBucketPathsType = "count" + + PipelineMetricAggregationWithMultipleBucketPathsTypeCumulativeSum PipelineMetricAggregationWithMultipleBucketPathsType = "cumulative_sum" + + PipelineMetricAggregationWithMultipleBucketPathsTypeDerivative PipelineMetricAggregationWithMultipleBucketPathsType = "derivative" + + PipelineMetricAggregationWithMultipleBucketPathsTypeExtendedStats PipelineMetricAggregationWithMultipleBucketPathsType = "extended_stats" + + PipelineMetricAggregationWithMultipleBucketPathsTypeLogs PipelineMetricAggregationWithMultipleBucketPathsType = "logs" + + PipelineMetricAggregationWithMultipleBucketPathsTypeMax PipelineMetricAggregationWithMultipleBucketPathsType = "max" + + PipelineMetricAggregationWithMultipleBucketPathsTypeMin PipelineMetricAggregationWithMultipleBucketPathsType = "min" + + PipelineMetricAggregationWithMultipleBucketPathsTypeMovingAvg PipelineMetricAggregationWithMultipleBucketPathsType = "moving_avg" + + PipelineMetricAggregationWithMultipleBucketPathsTypeMovingFn PipelineMetricAggregationWithMultipleBucketPathsType = "moving_fn" + + PipelineMetricAggregationWithMultipleBucketPathsTypePercentiles PipelineMetricAggregationWithMultipleBucketPathsType = "percentiles" + + PipelineMetricAggregationWithMultipleBucketPathsTypeRate PipelineMetricAggregationWithMultipleBucketPathsType = "rate" + + PipelineMetricAggregationWithMultipleBucketPathsTypeRawData PipelineMetricAggregationWithMultipleBucketPathsType = "raw_data" + + PipelineMetricAggregationWithMultipleBucketPathsTypeRawDocument PipelineMetricAggregationWithMultipleBucketPathsType = "raw_document" + + PipelineMetricAggregationWithMultipleBucketPathsTypeSerialDiff PipelineMetricAggregationWithMultipleBucketPathsType = "serial_diff" + + PipelineMetricAggregationWithMultipleBucketPathsTypeSum PipelineMetricAggregationWithMultipleBucketPathsType = "sum" + + PipelineMetricAggregationWithMultipleBucketPathsTypeTopMetrics PipelineMetricAggregationWithMultipleBucketPathsType = "top_metrics" +) + +// Defines values for RateType. +const ( + RateTypeRate RateType = "rate" +) + +// Defines values for RawDataType. +const ( + RawDataTypeRawData RawDataType = "raw_data" +) + +// Defines values for RawDocumentType. +const ( + RawDocumentTypeRawDocument RawDocumentType = "raw_document" +) + +// Defines values for SerialDiffType. +const ( + SerialDiffTypeSerialDiff SerialDiffType = "serial_diff" +) + +// Defines values for SumType. +const ( + SumTypeSum SumType = "sum" +) + +// Defines values for TermsSettingsOrder. +const ( + TermsSettingsOrderAsc TermsSettingsOrder = "asc" + + TermsSettingsOrderDesc TermsSettingsOrder = "desc" +) + +// Defines values for TermsType. +const ( + TermsTypeTerms TermsType = "terms" +) + +// Defines values for TermsOrder. +const ( + TermsOrderAsc TermsOrder = "asc" + + TermsOrderDesc TermsOrder = "desc" +) + +// Defines values for TopMetricsType. +const ( + TopMetricsTypeTopMetrics TopMetricsType = "top_metrics" +) + +// Defines values for UniqueCountType. +const ( + UniqueCountTypeCardinality UniqueCountType = "cardinality" +) + +// Average defines model for Average. +type Average struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Missing *string `json:"missing,omitempty"` + Script *interface{} `json:"script,omitempty"` + } `json:"settings,omitempty"` + Type AverageType `json:"type"` +} + +// AverageType defines model for Average.Type. +type AverageType string + +// BaseBucketAggregation defines model for BaseBucketAggregation. +type BaseBucketAggregation struct { + Id string `json:"id"` + Settings map[string]interface{} `json:"settings,omitempty"` + Type BaseBucketAggregationType `json:"type"` +} + +// BaseBucketAggregationType defines model for BaseBucketAggregation.Type. +type BaseBucketAggregationType string + +// BaseMetricAggregation defines model for BaseMetricAggregation. +type BaseMetricAggregation struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Type BaseMetricAggregationType `json:"type"` +} + +// BaseMetricAggregationType defines model for BaseMetricAggregation.Type. +type BaseMetricAggregationType string + +// BaseMovingAverageModelSettings defines model for BaseMovingAverageModelSettings. +type BaseMovingAverageModelSettings struct { + Model BaseMovingAverageModelSettingsModel `json:"model"` + Predict string `json:"predict"` + Window string `json:"window"` +} + +// BaseMovingAverageModelSettingsModel defines model for BaseMovingAverageModelSettings.Model. +type BaseMovingAverageModelSettingsModel string + +// BasePipelineMetricAggregation defines model for BasePipelineMetricAggregation. +type BasePipelineMetricAggregation struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + + // TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + // type: #PipelineMetricAggregationType + PipelineAgg *string `json:"pipelineAgg,omitempty"` + Type BasePipelineMetricAggregationType `json:"type"` +} + +// BasePipelineMetricAggregationType defines model for BasePipelineMetricAggregation.Type. +type BasePipelineMetricAggregationType string + +// BucketAggregation defines model for BucketAggregation. +type BucketAggregation interface{} + +// BucketAggregationType defines model for BucketAggregationType. +type BucketAggregationType string + +// BucketAggregationWithField defines model for BucketAggregationWithField. +type BucketAggregationWithField struct { + Field *string `json:"field,omitempty"` + Id string `json:"id"` + Settings map[string]interface{} `json:"settings,omitempty"` + Type BucketAggregationWithFieldType `json:"type"` +} + +// BucketAggregationWithFieldType defines model for BucketAggregationWithField.Type. +type BucketAggregationWithFieldType string + +// BucketScript defines model for BucketScript. +type BucketScript struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + + // TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + // type: #PipelineMetricAggregationType + PipelineVariables *[]struct { + Name string `json:"name"` + PipelineAgg string `json:"pipelineAgg"` + } `json:"pipelineVariables,omitempty"` + Settings *struct { + Script *interface{} `json:"script,omitempty"` + } `json:"settings,omitempty"` + Type BucketScriptType `json:"type"` +} + +// BucketScriptType defines model for BucketScript.Type. +type BucketScriptType string + +// Count defines model for Count. +type Count struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Type CountType `json:"type"` +} + +// CountType defines model for Count.Type. +type CountType string + +// CumulativeSum defines model for CumulativeSum. +type CumulativeSum struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + + // TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + // type: #PipelineMetricAggregationType + PipelineAgg *string `json:"pipelineAgg,omitempty"` + Settings *struct { + Format *string `json:"format,omitempty"` + } `json:"settings,omitempty"` + Type CumulativeSumType `json:"type"` +} + +// CumulativeSumType defines model for CumulativeSum.Type. +type CumulativeSumType string + +// DateHistogram defines model for DateHistogram. +type DateHistogram struct { + Field *string `json:"field,omitempty"` + Id string `json:"id"` + Settings *struct { + Interval *string `json:"interval,omitempty"` + MinDocCount *string `json:"min_doc_count,omitempty"` + Offset *string `json:"offset,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + TrimEdges *string `json:"trimEdges,omitempty"` + } `json:"settings,omitempty"` + Type DateHistogramType `json:"type"` +} + +// DateHistogramType defines model for DateHistogram.Type. +type DateHistogramType string + +// DateHistogramSettings defines model for DateHistogramSettings. +type DateHistogramSettings struct { + Interval *string `json:"interval,omitempty"` + MinDocCount *string `json:"min_doc_count,omitempty"` + Offset *string `json:"offset,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + TrimEdges *string `json:"trimEdges,omitempty"` +} + +// Derivative defines model for Derivative. +type Derivative struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + + // TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + // type: #PipelineMetricAggregationType + PipelineAgg *string `json:"pipelineAgg,omitempty"` + Settings *struct { + Unit *string `json:"unit,omitempty"` + } `json:"settings,omitempty"` + Type DerivativeType `json:"type"` +} + +// DerivativeType defines model for Derivative.Type. +type DerivativeType string + +// ElasticsearchDataQuery defines model for ElasticsearchDataQuery. +type ElasticsearchDataQuery struct { + Alias *string `json:"alias,omitempty"` + BucketAggs *[]interface{} `json:"bucketAggs,omitempty"` + + // For mixed data sources the selected datasource is on the query level. + // For non mixed scenarios this is undefined. + // TODO find a better way to do this ^ that's friendly to schema + // TODO this shouldn't be unknown but DataSourceRef | null + Datasource *interface{} `json:"datasource,omitempty"` + + // true if query is disabled (ie should not be returned to the dashboard) + Hide *bool `json:"hide,omitempty"` + + // Unique, guid like, string used in explore mode + Key *string `json:"key,omitempty"` + Metrics *[]interface{} `json:"metrics,omitempty"` + Query *string `json:"query,omitempty"` + + // Specify the query flavor + // TODO make this required and give it a default + QueryType *string `json:"queryType,omitempty"` + + // A - Z + RefId string `json:"refId"` + TimeField *string `json:"timeField,omitempty"` +} + +// ExtendedStat defines model for ExtendedStat. +type ExtendedStat struct { + Label string `json:"label"` + Value ExtendedStatValue `json:"value"` +} + +// ExtendedStatValue defines model for ExtendedStat.Value. +type ExtendedStatValue string + +// ExtendedStatMetaType defines model for ExtendedStatMetaType. +type ExtendedStatMetaType string + +// ExtendedStats defines model for ExtendedStats. +type ExtendedStats struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Meta *map[string]interface{} `json:"meta,omitempty"` + Settings *struct { + Missing *string `json:"missing,omitempty"` + Script *interface{} `json:"script,omitempty"` + Sigma *string `json:"sigma,omitempty"` + } `json:"settings,omitempty"` + Type ExtendedStatsType `json:"type"` +} + +// ExtendedStatsType defines model for ExtendedStats.Type. +type ExtendedStatsType string + +// Filter defines model for Filter. +type Filter struct { + Label string `json:"label"` + Query string `json:"query"` +} + +// Filters defines model for Filters. +type Filters struct { + Id string `json:"id"` + Settings *struct { + Filters *[]struct { + Label string `json:"label"` + Query string `json:"query"` + } `json:"filters,omitempty"` + } `json:"settings,omitempty"` + Type FiltersType `json:"type"` +} + +// FiltersType defines model for Filters.Type. +type FiltersType string + +// FiltersSettings defines model for FiltersSettings. +type FiltersSettings struct { + Filters *[]struct { + Label string `json:"label"` + Query string `json:"query"` + } `json:"filters,omitempty"` +} + +// GeoHashGrid defines model for GeoHashGrid. +type GeoHashGrid struct { + Field *string `json:"field,omitempty"` + Id string `json:"id"` + Settings *struct { + Precision *string `json:"precision,omitempty"` + } `json:"settings,omitempty"` + Type GeoHashGridType `json:"type"` +} + +// GeoHashGridType defines model for GeoHashGrid.Type. +type GeoHashGridType string + +// GeoHashGridSettings defines model for GeoHashGridSettings. +type GeoHashGridSettings struct { + Precision *string `json:"precision,omitempty"` +} + +// Histogram defines model for Histogram. +type Histogram struct { + Field *string `json:"field,omitempty"` + Id string `json:"id"` + Settings *struct { + Interval *string `json:"interval,omitempty"` + MinDocCount *string `json:"min_doc_count,omitempty"` + } `json:"settings,omitempty"` + Type HistogramType `json:"type"` +} + +// HistogramType defines model for Histogram.Type. +type HistogramType string + +// HistogramSettings defines model for HistogramSettings. +type HistogramSettings struct { + Interval *string `json:"interval,omitempty"` + MinDocCount *string `json:"min_doc_count,omitempty"` +} + +// InlineScript defines model for InlineScript. +type InlineScript interface{} + +// Logs defines model for Logs. +type Logs struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Limit *string `json:"limit,omitempty"` + } `json:"settings,omitempty"` + Type LogsType `json:"type"` +} + +// LogsType defines model for Logs.Type. +type LogsType string + +// Max defines model for Max. +type Max struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Missing *string `json:"missing,omitempty"` + Script *interface{} `json:"script,omitempty"` + } `json:"settings,omitempty"` + Type MaxType `json:"type"` +} + +// MaxType defines model for Max.Type. +type MaxType string + +// MetricAggregation defines model for MetricAggregation. +type MetricAggregation interface{} + +// MetricAggregationType defines model for MetricAggregationType. +type MetricAggregationType string + +// MetricAggregationWithField defines model for MetricAggregationWithField. +type MetricAggregationWithField struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Type MetricAggregationWithFieldType `json:"type"` +} + +// MetricAggregationWithFieldType defines model for MetricAggregationWithField.Type. +type MetricAggregationWithFieldType string + +// MetricAggregationWithInlineScript defines model for MetricAggregationWithInlineScript. +type MetricAggregationWithInlineScript struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Script *interface{} `json:"script,omitempty"` + } `json:"settings,omitempty"` + Type MetricAggregationWithInlineScriptType `json:"type"` +} + +// MetricAggregationWithInlineScriptType defines model for MetricAggregationWithInlineScript.Type. +type MetricAggregationWithInlineScriptType string + +// MetricAggregationWithMissingSupport defines model for MetricAggregationWithMissingSupport. +type MetricAggregationWithMissingSupport struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Missing *string `json:"missing,omitempty"` + } `json:"settings,omitempty"` + Type MetricAggregationWithMissingSupportType `json:"type"` +} + +// MetricAggregationWithMissingSupportType defines model for MetricAggregationWithMissingSupport.Type. +type MetricAggregationWithMissingSupportType string + +// MetricAggregationWithSettings defines model for MetricAggregationWithSettings. +type MetricAggregationWithSettings interface{} + +// Min defines model for Min. +type Min struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Missing *string `json:"missing,omitempty"` + Script *interface{} `json:"script,omitempty"` + } `json:"settings,omitempty"` + Type MinType `json:"type"` +} + +// MinType defines model for Min.Type. +type MinType string + +// #MovingAverage's settings are overridden in types.ts +type MovingAverage struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + + // TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + // type: #PipelineMetricAggregationType + PipelineAgg *string `json:"pipelineAgg,omitempty"` + Settings map[string]interface{} `json:"settings,omitempty"` + Type MovingAverageType `json:"type"` +} + +// MovingAverageType defines model for MovingAverage.Type. +type MovingAverageType string + +// MovingAverageEWMAModelSettings defines model for MovingAverageEWMAModelSettings. +type MovingAverageEWMAModelSettings struct { + Minimize bool `json:"minimize"` + Model MovingAverageEWMAModelSettingsModel `json:"model"` + Predict string `json:"predict"` + Settings *struct { + Alpha *string `json:"alpha,omitempty"` + } `json:"settings,omitempty"` + Window string `json:"window"` +} + +// MovingAverageEWMAModelSettingsModel defines model for MovingAverageEWMAModelSettings.Model. +type MovingAverageEWMAModelSettingsModel string + +// MovingAverageHoltModelSettings defines model for MovingAverageHoltModelSettings. +type MovingAverageHoltModelSettings struct { + Minimize bool `json:"minimize"` + Model MovingAverageHoltModelSettingsModel `json:"model"` + Predict string `json:"predict"` + Settings struct { + Alpha *string `json:"alpha,omitempty"` + Beta *string `json:"beta,omitempty"` + } `json:"settings"` + Window string `json:"window"` +} + +// MovingAverageHoltModelSettingsModel defines model for MovingAverageHoltModelSettings.Model. +type MovingAverageHoltModelSettingsModel string + +// MovingAverageHoltWintersModelSettings defines model for MovingAverageHoltWintersModelSettings. +type MovingAverageHoltWintersModelSettings struct { + Minimize bool `json:"minimize"` + Model MovingAverageHoltWintersModelSettingsModel `json:"model"` + Predict string `json:"predict"` + Settings struct { + Alpha *string `json:"alpha,omitempty"` + Beta *string `json:"beta,omitempty"` + Gamma *string `json:"gamma,omitempty"` + Pad *bool `json:"pad,omitempty"` + Period *string `json:"period,omitempty"` + } `json:"settings"` + Window string `json:"window"` +} + +// MovingAverageHoltWintersModelSettingsModel defines model for MovingAverageHoltWintersModelSettings.Model. +type MovingAverageHoltWintersModelSettingsModel string + +// MovingAverageLinearModelSettings defines model for MovingAverageLinearModelSettings. +type MovingAverageLinearModelSettings struct { + Model MovingAverageLinearModelSettingsModel `json:"model"` + Predict string `json:"predict"` + Window string `json:"window"` +} + +// MovingAverageLinearModelSettingsModel defines model for MovingAverageLinearModelSettings.Model. +type MovingAverageLinearModelSettingsModel string + +// MovingAverageModel defines model for MovingAverageModel. +type MovingAverageModel string + +// MovingAverageModelOption defines model for MovingAverageModelOption. +type MovingAverageModelOption struct { + Label string `json:"label"` + Value MovingAverageModelOptionValue `json:"value"` +} + +// MovingAverageModelOptionValue defines model for MovingAverageModelOption.Value. +type MovingAverageModelOptionValue string + +// MovingAverageSimpleModelSettings defines model for MovingAverageSimpleModelSettings. +type MovingAverageSimpleModelSettings struct { + Model MovingAverageSimpleModelSettingsModel `json:"model"` + Predict string `json:"predict"` + Window string `json:"window"` +} + +// MovingAverageSimpleModelSettingsModel defines model for MovingAverageSimpleModelSettings.Model. +type MovingAverageSimpleModelSettingsModel string + +// MovingFunction defines model for MovingFunction. +type MovingFunction struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + + // TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + // type: #PipelineMetricAggregationType + PipelineAgg *string `json:"pipelineAgg,omitempty"` + Settings *struct { + Script *interface{} `json:"script,omitempty"` + Shift *string `json:"shift,omitempty"` + Window *string `json:"window,omitempty"` + } `json:"settings,omitempty"` + Type MovingFunctionType `json:"type"` +} + +// MovingFunctionType defines model for MovingFunction.Type. +type MovingFunctionType string + +// Nested defines model for Nested. +type Nested struct { + Field *string `json:"field,omitempty"` + Id string `json:"id"` + Settings map[string]interface{} `json:"settings,omitempty"` + Type NestedType `json:"type"` +} + +// NestedType defines model for Nested.Type. +type NestedType string + +// Percentiles defines model for Percentiles. +type Percentiles struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Missing *string `json:"missing,omitempty"` + Percents *[]string `json:"percents,omitempty"` + Script *interface{} `json:"script,omitempty"` + } `json:"settings,omitempty"` + Type PercentilesType `json:"type"` +} + +// PercentilesType defines model for Percentiles.Type. +type PercentilesType string + +// PipelineMetricAggregation defines model for PipelineMetricAggregation. +type PipelineMetricAggregation interface{} + +// PipelineMetricAggregationType defines model for PipelineMetricAggregationType. +type PipelineMetricAggregationType string + +// PipelineMetricAggregationWithMultipleBucketPaths defines model for PipelineMetricAggregationWithMultipleBucketPaths. +type PipelineMetricAggregationWithMultipleBucketPaths struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + + // TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + // type: #PipelineMetricAggregationType + PipelineVariables *[]struct { + Name string `json:"name"` + PipelineAgg string `json:"pipelineAgg"` + } `json:"pipelineVariables,omitempty"` + Type PipelineMetricAggregationWithMultipleBucketPathsType `json:"type"` +} + +// PipelineMetricAggregationWithMultipleBucketPathsType defines model for PipelineMetricAggregationWithMultipleBucketPaths.Type. +type PipelineMetricAggregationWithMultipleBucketPathsType string + +// PipelineVariable defines model for PipelineVariable. +type PipelineVariable struct { + Name string `json:"name"` + PipelineAgg string `json:"pipelineAgg"` +} + +// Rate defines model for Rate. +type Rate struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Mode *string `json:"mode,omitempty"` + Unit *string `json:"unit,omitempty"` + } `json:"settings,omitempty"` + Type RateType `json:"type"` +} + +// RateType defines model for Rate.Type. +type RateType string + +// RawData defines model for RawData. +type RawData struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Size *string `json:"size,omitempty"` + } `json:"settings,omitempty"` + Type RawDataType `json:"type"` +} + +// RawDataType defines model for RawData.Type. +type RawDataType string + +// RawDocument defines model for RawDocument. +type RawDocument struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Size *string `json:"size,omitempty"` + } `json:"settings,omitempty"` + Type RawDocumentType `json:"type"` +} + +// RawDocumentType defines model for RawDocument.Type. +type RawDocumentType string + +// SerialDiff defines model for SerialDiff. +type SerialDiff struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + + // TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + // type: #PipelineMetricAggregationType + PipelineAgg *string `json:"pipelineAgg,omitempty"` + Settings *struct { + Lag *string `json:"lag,omitempty"` + } `json:"settings,omitempty"` + Type SerialDiffType `json:"type"` +} + +// SerialDiffType defines model for SerialDiff.Type. +type SerialDiffType string + +// Sum defines model for Sum. +type Sum struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Missing *string `json:"missing,omitempty"` + Script *interface{} `json:"script,omitempty"` + } `json:"settings,omitempty"` + Type SumType `json:"type"` +} + +// SumType defines model for Sum.Type. +type SumType string + +// Terms defines model for Terms. +type Terms struct { + Field *string `json:"field,omitempty"` + Id string `json:"id"` + Settings *struct { + MinDocCount *string `json:"min_doc_count,omitempty"` + Missing *string `json:"missing,omitempty"` + Order *TermsSettingsOrder `json:"order,omitempty"` + OrderBy *string `json:"orderBy,omitempty"` + Size *string `json:"size,omitempty"` + } `json:"settings,omitempty"` + Type TermsType `json:"type"` +} + +// TermsSettingsOrder defines model for Terms.Settings.Order. +type TermsSettingsOrder string + +// TermsType defines model for Terms.Type. +type TermsType string + +// TermsOrder defines model for TermsOrder. +type TermsOrder string + +// TermsSettings defines model for TermsSettings. +type TermsSettings struct { + MinDocCount *string `json:"min_doc_count,omitempty"` + Missing *string `json:"missing,omitempty"` + Order *TermsSettingsOrder `json:"order,omitempty"` + OrderBy *string `json:"orderBy,omitempty"` + Size *string `json:"size,omitempty"` +} + +// TopMetrics defines model for TopMetrics. +type TopMetrics struct { + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Metrics *[]string `json:"metrics,omitempty"` + Order *string `json:"order,omitempty"` + OrderBy *string `json:"orderBy,omitempty"` + } `json:"settings,omitempty"` + Type TopMetricsType `json:"type"` +} + +// TopMetricsType defines model for TopMetrics.Type. +type TopMetricsType string + +// UniqueCount defines model for UniqueCount. +type UniqueCount struct { + Field *string `json:"field,omitempty"` + Hide *bool `json:"hide,omitempty"` + Id string `json:"id"` + Settings *struct { + Missing *string `json:"missing,omitempty"` + PrecisionThreshold *string `json:"precision_threshold,omitempty"` + } `json:"settings,omitempty"` + Type UniqueCountType `json:"type"` +} + +// UniqueCountType defines model for UniqueCount.Type. +type UniqueCountType string diff --git a/public/app/plugins/datasource/elasticsearch/dataquery.cue b/public/app/plugins/datasource/elasticsearch/dataquery.cue new file mode 100644 index 00000000000..f7eff4bb1b4 --- /dev/null +++ b/public/app/plugins/datasource/elasticsearch/dataquery.cue @@ -0,0 +1,431 @@ +// Copyright 2023 Grafana Labs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package grafanaplugin + +import ( + "github.com/grafana/grafana/packages/grafana-schema/src/common" + "github.com/grafana/grafana/pkg/plugins/pfs" +) + +// This file (with its sibling .cue files) implements pfs.GrafanaPlugin +pfs.GrafanaPlugin + +composableKinds: DataQuery: { + maturity: "merged" + + lineage: { + seqs: [ + { + schemas: [ + { + common.DataQuery + + alias?: string + query?: string + timeField?: string + bucketAggs?: [...#BucketAggregation] + metrics?: [...#MetricAggregation] + + #BucketAggregation: #DateHistogram | #Histogram | #Terms | #Filters | #GeoHashGrid | #Nested @cuetsy(kind="type") + #MetricAggregation: #Count | #PipelineMetricAggregation | #MetricAggregationWithSettings @cuetsy(kind="type") + + #BucketAggregationType: "terms" | "filters" | "geohash_grid" | "date_histogram" | "histogram" | "nested" @cuetsy(kind="type") + + #BaseBucketAggregation: { + id: string + type: #BucketAggregationType + settings?: {...} + } @cuetsy(kind="interface") + + #BucketAggregationWithField: { + #BaseBucketAggregation + field?: string + } @cuetsy(kind="interface") + + #DateHistogram: { + #BucketAggregationWithField + type: #BucketAggregationType & "date_histogram" + settings?: #DateHistogramSettings + } @cuetsy(kind="interface") + + #DateHistogramSettings: { + interval?: string + min_doc_count?: string + trimEdges?: string + offset?: string + timeZone?: string + } @cuetsy(kind="interface") + + #Histogram: { + #BucketAggregationWithField + type: #BucketAggregationType & "histogram" + settings?: #HistogramSettings + } @cuetsy(kind="interface") + + #HistogramSettings: { + interval?: string + min_doc_count?: string + } @cuetsy(kind="interface") + + #TermsOrder: "desc" | "asc" @cuetsy(kind="type") + + #Nested: { + #BucketAggregationWithField + type: #BucketAggregationType & "nested" + settings?: {} + } @cuetsy(kind="interface") + + #Terms: { + #BucketAggregationWithField + type: #BucketAggregationType & "terms" + settings?: #TermsSettings + } @cuetsy(kind="interface") + + #TermsSettings: { + order?: #TermsOrder + size?: string + min_doc_count?: string + orderBy?: string + missing?: string + } @cuetsy(kind="interface") + + #Filters: { + #BaseBucketAggregation + type: #BucketAggregationType & "filters" + settings?: #FiltersSettings + } @cuetsy(kind="interface") + + #Filter: { + query: string + label: string + } @cuetsy(kind="type") + + #FiltersSettings: { + filters?: [...#Filter] + } @cuetsy(kind="interface") + + #GeoHashGrid: { + #BucketAggregationWithField + type: #BucketAggregationType & "geohash_grid" + settings?: #GeoHashGridSettings + } @cuetsy(kind="interface") + + #GeoHashGridSettings: { + precision?: string + } @cuetsy(kind="interface") + + #PipelineMetricAggregationType: "moving_avg" | "moving_fn" | "derivative" | "serial_diff" | "cumulative_sum" | "bucket_script" @cuetsy(kind="type") + #MetricAggregationType: "count" | "avg" | "sum" | "min" | "max" | "extended_stats" | "percentiles" | "cardinality" | "raw_document" | "raw_data" | "logs" | "rate" | "top_metrics" | #PipelineMetricAggregationType @cuetsy(kind="type") + + #BaseMetricAggregation: { + type: #MetricAggregationType + id: string + hide?: bool + } @cuetsy(kind="interface") + + #PipelineVariable: { + name: string + pipelineAgg: string + } @cuetsy(kind="interface") + + #MetricAggregationWithField: { + #BaseMetricAggregation + field?: string + } @cuetsy(kind="interface") + + #MetricAggregationWithMissingSupport: { + #BaseMetricAggregation + settings?: { + missing?: string + } + } @cuetsy(kind="interface") + + #InlineScript: string | {inline?: string} @cuetsy(kind="type") + + #MetricAggregationWithInlineScript: { + #BaseMetricAggregation + settings?: { + script?: #InlineScript + } + } @cuetsy(kind="interface") + + #Count: { + #BaseMetricAggregation + type: #MetricAggregationType & "count" + } @cuetsy(kind="interface") + + #Average: { + #MetricAggregationWithField + #MetricAggregationWithMissingSupport + #MetricAggregationWithInlineScript + type: #MetricAggregationType & "avg" + settings?: { + script?: #InlineScript + missing?: string + } + } @cuetsy(kind="interface") + + #Sum: { + #MetricAggregationWithField + #MetricAggregationWithInlineScript + type: #MetricAggregationType & "sum" + settings?: { + script?: #InlineScript + missing?: string + } + } @cuetsy(kind="interface") + + #Max: { + #MetricAggregationWithField + #MetricAggregationWithInlineScript + type: #MetricAggregationType & "max" + settings?: { + script?: #InlineScript + missing?: string + } + } @cuetsy(kind="interface") + + #Min: { + #MetricAggregationWithField + #MetricAggregationWithInlineScript + type: #MetricAggregationType & "min" + settings?: { + script?: #InlineScript + missing?: string + } + } @cuetsy(kind="interface") + + #ExtendedStatMetaType: "avg" | "min" | "max" | "sum" | "count" | "std_deviation" | "std_deviation_bounds_upper" | "std_deviation_bounds_lower" @cuetsy(kind="type") + + #ExtendedStat: { + label: string + value: #ExtendedStatMetaType + } @cuetsy(kind="interface") + + #ExtendedStats: { + #MetricAggregationWithField + #MetricAggregationWithInlineScript + type: #MetricAggregationType & "extended_stats" + settings?: { + script?: #InlineScript + missing?: string + sigma?: string + } + meta?: [#ExtendedStatMetaType]: bool + } @cuetsy(kind="interface") + + #Percentiles: { + #MetricAggregationWithField + #MetricAggregationWithInlineScript + type: #MetricAggregationType & "percentiles" + settings?: { + script?: #InlineScript + missing?: string + percents?: [...string] + } + } @cuetsy(kind="interface") + + #UniqueCount: { + #MetricAggregationWithField + type: #MetricAggregationType & "cardinality" + settings?: { + precision_threshold?: string + missing?: string + } + } @cuetsy(kind="interface") + + #RawDocument: { + #BaseMetricAggregation + type: #MetricAggregationType & "raw_document" + settings?: { + size?: string + } + } @cuetsy(kind="interface") + + #RawData: { + #BaseMetricAggregation + type: #MetricAggregationType & "raw_data" + settings?: { + size?: string + } + } @cuetsy(kind="interface") + + #Logs: { + #BaseMetricAggregation + type: #MetricAggregationType & "logs" + settings?: { + limit?: string + } + } @cuetsy(kind="interface") + + #Rate: { + #MetricAggregationWithField + type: #MetricAggregationType & "rate" + settings?: { + unit?: string + mode?: string + } + } @cuetsy(kind="interface") + + #BasePipelineMetricAggregation: { + #MetricAggregationWithField + + //TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + //type: #PipelineMetricAggregationType + pipelineAgg?: string + } @cuetsy(kind="interface") + + #PipelineMetricAggregationWithMultipleBucketPaths: { + #BaseMetricAggregation + + //TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + //type: #PipelineMetricAggregationType + pipelineVariables?: [...#PipelineVariable] + } @cuetsy(kind="interface") + + #MovingAverageModel: "simple" | "linear" | "ewma" | "holt" | "holt_winters" @cuetsy(kind="type") + + #MovingAverageModelOption: { + label: string + value: #MovingAverageModel + } @cuetsy(kind="interface") + + #BaseMovingAverageModelSettings: { + model: #MovingAverageModel + window: string + predict: string + } @cuetsy(kind="interface") + + #MovingAverageSimpleModelSettings: { + #BaseMovingAverageModelSettings + model: #MovingAverageModel & "simple" + } @cuetsy(kind="interface") + + #MovingAverageLinearModelSettings: { + #BaseMovingAverageModelSettings + model: #MovingAverageModel & "linear" + } @cuetsy(kind="interface") + + #MovingAverageEWMAModelSettings: { + #BaseMovingAverageModelSettings + model: #MovingAverageModel & "ewma" + settings?: { + alpha?: string + } + minimize: bool + } @cuetsy(kind="interface") + + #MovingAverageHoltModelSettings: { + #BaseMovingAverageModelSettings + model: #MovingAverageModel & "holt" + settings: { + alpha?: string + beta?: string + } + minimize: bool + } @cuetsy(kind="interface") + + #MovingAverageHoltWintersModelSettings: { + #BaseMovingAverageModelSettings + model: #MovingAverageModel & "holt_winters" + settings: { + alpha?: string + beta?: string + gamma?: string + period?: string + pad?: bool + } + minimize: bool + } @cuetsy(kind="interface") + + // #MovingAverageModelSettings Not sure how to do this one: + // export type MovingAverageModelSettings = Partial< + // Extract< + // | MovingAverageSimpleModelSettings + // | MovingAverageLinearModelSettings + // | MovingAverageEWMAModelSettings + // | MovingAverageHoltModelSettings + // | MovingAverageHoltWintersModelSettings, + // { model: T } + // > + // >; + + // #MovingAverage's settings are overridden in types.ts + #MovingAverage: { + #BasePipelineMetricAggregation + type: "moving_avg" + settings?: {...} + } @cuetsy(kind="interface") + + #MovingFunction: { + #BasePipelineMetricAggregation + type: #PipelineMetricAggregationType & "moving_fn" + settings?: { + window?: string + script?: #InlineScript + shift?: string + } + } @cuetsy(kind="interface") + + #Derivative: { + #BasePipelineMetricAggregation + type: #PipelineMetricAggregationType & "derivative" + settings?: { + unit?: string + } + } @cuetsy(kind="interface") + + #SerialDiff: { + #BasePipelineMetricAggregation + type: #PipelineMetricAggregationType & "serial_diff" + settings?: { + lag?: string + } + } @cuetsy(kind="interface") + + #CumulativeSum: { + #BasePipelineMetricAggregation + type: #PipelineMetricAggregationType & "cumulative_sum" + settings?: { + format?: string + } + } @cuetsy(kind="interface") + + #BucketScript: { + #PipelineMetricAggregationWithMultipleBucketPaths + type: #PipelineMetricAggregationType & "bucket_script" + settings?: { + script?: #InlineScript + } + } @cuetsy(kind="interface") + + #TopMetrics: { + #BaseMetricAggregation + type: #MetricAggregationType & "top_metrics" + settings?: { + order?: string + orderBy?: string + metrics?: [...string] + } + } @cuetsy(kind="interface") + + #PipelineMetricAggregation: #MovingAverage | #Derivative | #CumulativeSum | #BucketScript @cuetsy(kind="type") + #MetricAggregationWithSettings: #BucketScript | #CumulativeSum | #Derivative | #SerialDiff | #RawData | #RawDocument | #UniqueCount | #Percentiles | #ExtendedStats | #Min | #Max | #Sum | #Average | #MovingAverage | #MovingFunction | #Logs | #Rate | #TopMetrics @cuetsy(kind="type") + }, + ] + }, + ] + } +} diff --git a/public/app/plugins/datasource/elasticsearch/dataquery.gen.ts b/public/app/plugins/datasource/elasticsearch/dataquery.gen.ts new file mode 100644 index 00000000000..afed01ad557 --- /dev/null +++ b/public/app/plugins/datasource/elasticsearch/dataquery.gen.ts @@ -0,0 +1,374 @@ +// Code generated - EDITING IS FUTILE. DO NOT EDIT. +// +// Generated by: +// public/app/plugins/gen.go +// Using jennies: +// TSTypesJenny +// PluginTSTypesJenny +// +// Run 'make gen-cue' from repository root to regenerate. + +import * as common from '@grafana/schema'; + +export const DataQueryModelVersion = Object.freeze([0, 0]); + +export type BucketAggregation = (DateHistogram | Histogram | Terms | Filters | GeoHashGrid | Nested); + +export type MetricAggregation = (Count | PipelineMetricAggregation | MetricAggregationWithSettings); + +export type BucketAggregationType = ('terms' | 'filters' | 'geohash_grid' | 'date_histogram' | 'histogram' | 'nested'); + +export interface BaseBucketAggregation { + id: string; + settings?: Record; + type: BucketAggregationType; +} + +export interface BucketAggregationWithField extends BaseBucketAggregation { + field?: string; +} + +export interface DateHistogram extends BucketAggregationWithField { + type: 'date_histogram'; +} + +export interface DateHistogramSettings { + interval?: string; + min_doc_count?: string; + offset?: string; + timeZone?: string; + trimEdges?: string; +} + +export interface Histogram extends BucketAggregationWithField { + type: 'histogram'; +} + +export interface HistogramSettings { + interval?: string; + min_doc_count?: string; +} + +export type TermsOrder = ('desc' | 'asc'); + +export interface Nested extends BucketAggregationWithField { + type: 'nested'; +} + +export interface Terms extends BucketAggregationWithField { + type: 'terms'; +} + +export interface TermsSettings { + min_doc_count?: string; + missing?: string; + order?: TermsOrder; + orderBy?: string; + size?: string; +} + +export interface Filters extends BaseBucketAggregation { + type: 'filters'; +} + +export type Filter = { + query: string, + label: string, +}; + +export interface FiltersSettings { + filters?: Array; +} + +export const defaultFiltersSettings: Partial = { + filters: [], +}; + +export interface GeoHashGrid extends BucketAggregationWithField { + type: 'geohash_grid'; +} + +export interface GeoHashGridSettings { + precision?: string; +} + +export type PipelineMetricAggregationType = ('moving_avg' | 'moving_fn' | 'derivative' | 'serial_diff' | 'cumulative_sum' | 'bucket_script'); + +export type MetricAggregationType = ('count' | 'avg' | 'sum' | 'min' | 'max' | 'extended_stats' | 'percentiles' | 'cardinality' | 'raw_document' | 'raw_data' | 'logs' | 'rate' | 'top_metrics' | PipelineMetricAggregationType); + +export interface BaseMetricAggregation { + hide?: boolean; + id: string; + type: MetricAggregationType; +} + +export interface PipelineVariable { + name: string; + pipelineAgg: string; +} + +export interface MetricAggregationWithField extends BaseMetricAggregation { + field?: string; +} + +export interface MetricAggregationWithMissingSupport extends BaseMetricAggregation { + settings?: { + missing?: string; + }; +} + +export type InlineScript = (string | { + inline?: string + }); + +export interface MetricAggregationWithInlineScript extends BaseMetricAggregation { + settings?: { + script?: InlineScript; + }; +} + +export interface Count extends BaseMetricAggregation { + type: 'count'; +} + +export interface Average extends MetricAggregationWithField, MetricAggregationWithMissingSupport, MetricAggregationWithInlineScript { + field?: string; + settings?: { + script?: (InlineScript | InlineScript); + missing?: string; + }; + type: 'avg'; +} + +export interface Sum extends MetricAggregationWithField, MetricAggregationWithInlineScript { + field?: string; + settings?: { + script?: (InlineScript | InlineScript); + missing?: string; + }; + type: 'sum'; +} + +export interface Max extends MetricAggregationWithField, MetricAggregationWithInlineScript { + field?: string; + settings?: { + script?: (InlineScript | InlineScript); + missing?: string; + }; + type: 'max'; +} + +export interface Min extends MetricAggregationWithField, MetricAggregationWithInlineScript { + field?: string; + settings?: { + script?: (InlineScript | InlineScript); + missing?: string; + }; + type: 'min'; +} + +export type ExtendedStatMetaType = ('avg' | 'min' | 'max' | 'sum' | 'count' | 'std_deviation' | 'std_deviation_bounds_upper' | 'std_deviation_bounds_lower'); + +export interface ExtendedStat { + label: string; + value: ExtendedStatMetaType; +} + +export interface ExtendedStats extends MetricAggregationWithField, MetricAggregationWithInlineScript { + field?: string; + meta?: Record; + settings?: { + script?: (InlineScript | InlineScript); + missing?: string; + sigma?: string; + }; + type: 'extended_stats'; +} + +export interface Percentiles extends MetricAggregationWithField, MetricAggregationWithInlineScript { + field?: string; + settings?: { + script?: (InlineScript | InlineScript); + missing?: string; + percents?: Array; + }; + type: 'percentiles'; +} + +export interface UniqueCount extends MetricAggregationWithField { + settings?: { + precision_threshold?: string; + missing?: string; + }; + type: 'cardinality'; +} + +export interface RawDocument extends BaseMetricAggregation { + settings?: { + size?: string; + }; + type: 'raw_document'; +} + +export interface RawData extends BaseMetricAggregation { + settings?: { + size?: string; + }; + type: 'raw_data'; +} + +export interface Logs extends BaseMetricAggregation { + settings?: { + limit?: string; + }; + type: 'logs'; +} + +export interface Rate extends MetricAggregationWithField { + settings?: { + unit?: string; + mode?: string; + }; + type: 'rate'; +} + +export interface BasePipelineMetricAggregation extends MetricAggregationWithField { + /** + * TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + * type: #PipelineMetricAggregationType + */ + pipelineAgg?: string; +} + +export interface PipelineMetricAggregationWithMultipleBucketPaths extends BaseMetricAggregation { + /** + * TODO: Type is temporarily commented out as it causes a type error in the generated code. In the meantime, we decided to manually extend the type in types.ts. + * type: #PipelineMetricAggregationType + */ + pipelineVariables?: Array; +} + +export const defaultPipelineMetricAggregationWithMultipleBucketPaths: Partial = { + pipelineVariables: [], +}; + +export type MovingAverageModel = ('simple' | 'linear' | 'ewma' | 'holt' | 'holt_winters'); + +export interface MovingAverageModelOption { + label: string; + value: MovingAverageModel; +} + +export interface BaseMovingAverageModelSettings { + model: MovingAverageModel; + predict: string; + window: string; +} + +export interface MovingAverageSimpleModelSettings extends BaseMovingAverageModelSettings { + model: 'simple'; +} + +export interface MovingAverageLinearModelSettings extends BaseMovingAverageModelSettings { + model: 'linear'; +} + +export interface MovingAverageEWMAModelSettings extends BaseMovingAverageModelSettings { + minimize: boolean; + model: 'ewma'; + settings?: { + alpha?: string; + }; +} + +export interface MovingAverageHoltModelSettings extends BaseMovingAverageModelSettings { + minimize: boolean; + model: 'holt'; + settings: { + alpha?: string; + beta?: string; + }; +} + +export interface MovingAverageHoltWintersModelSettings extends BaseMovingAverageModelSettings { + minimize: boolean; + model: 'holt_winters'; + settings: { + alpha?: string; + beta?: string; + gamma?: string; + period?: string; + pad?: boolean; + }; +} + +/** + * #MovingAverage's settings are overridden in types.ts + */ +export interface MovingAverage extends BasePipelineMetricAggregation { + settings?: Record; + type: 'moving_avg'; +} + +export interface MovingFunction extends BasePipelineMetricAggregation { + settings?: { + window?: string; + script?: InlineScript; + shift?: string; + }; + type: 'moving_fn'; +} + +export interface Derivative extends BasePipelineMetricAggregation { + settings?: { + unit?: string; + }; + type: 'derivative'; +} + +export interface SerialDiff extends BasePipelineMetricAggregation { + settings?: { + lag?: string; + }; + type: 'serial_diff'; +} + +export interface CumulativeSum extends BasePipelineMetricAggregation { + settings?: { + format?: string; + }; + type: 'cumulative_sum'; +} + +export interface BucketScript extends PipelineMetricAggregationWithMultipleBucketPaths { + settings?: { + script?: InlineScript; + }; + type: 'bucket_script'; +} + +export interface TopMetrics extends BaseMetricAggregation { + settings?: { + order?: string; + orderBy?: string; + metrics?: Array; + }; + type: 'top_metrics'; +} + +export type PipelineMetricAggregation = (MovingAverage | Derivative | CumulativeSum | BucketScript); + +export type MetricAggregationWithSettings = (BucketScript | CumulativeSum | Derivative | SerialDiff | RawData | RawDocument | UniqueCount | Percentiles | ExtendedStats | Min | Max | Sum | Average | MovingAverage | MovingFunction | Logs | Rate | TopMetrics); + +export interface Elasticsearch extends common.DataQuery { + alias?: string; + bucketAggs?: Array; + metrics?: Array; + query?: string; + timeField?: string; +} + +export const defaultElasticsearch: Partial = { + bucketAggs: [], + metrics: [], +}; diff --git a/public/app/plugins/datasource/elasticsearch/datasource.test.ts b/public/app/plugins/datasource/elasticsearch/datasource.test.ts index 44be841ff29..1dcd3a61d5b 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.test.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.test.ts @@ -314,7 +314,7 @@ describe('ElasticDatasource', () => { database: 'mock-index', }); - const query: DataQueryRequest = { + const query = { range: createTimeRange(toUtc([2015, 4, 30, 10]), toUtc([2019, 7, 1, 10])), targets: [ { @@ -332,7 +332,7 @@ describe('ElasticDatasource', () => { timeField: '@timestamp', }, ], - } as DataQueryRequest; + } as unknown as DataQueryRequest; const queryBuilderSpy = jest.spyOn(ds.queryBuilder, 'getLogsQuery'); let response: DataQueryResponse = { data: [] }; diff --git a/public/app/plugins/datasource/elasticsearch/types.ts b/public/app/plugins/datasource/elasticsearch/types.ts index 758acd48bf1..90ba5ab1a8d 100644 --- a/public/app/plugins/datasource/elasticsearch/types.ts +++ b/public/app/plugins/datasource/elasticsearch/types.ts @@ -1,13 +1,102 @@ -import { DataQuery, DataSourceJsonData } from '@grafana/data'; +import { DataSourceJsonData } from '@grafana/data'; import { - BucketAggregation, BucketAggregationType, -} from './components/QueryEditor/BucketAggregationsEditor/aggregations'; -import { + Filter, MetricAggregation, MetricAggregationType, -} from './components/QueryEditor/MetricAggregationsEditor/aggregations'; + MovingAverageEWMAModelSettings, + MovingAverageHoltModelSettings, + MovingAverageHoltWintersModelSettings, + MovingAverageLinearModelSettings, + MovingAverageModel, + MovingAverageSimpleModelSettings, + PipelineMetricAggregationType, + TermsOrder, + BasePipelineMetricAggregation as SchemaBasePipelineMetricAggregation, + PipelineMetricAggregationWithMultipleBucketPaths as SchemaPipelineMetricAggregationWithMultipleBucketPaths, + MovingAverage as SchemaMovingAverage, + Filters as SchemaFilters, + Terms as SchemaTerms, + DateHistogram as SchemaDateHistogram, + Histogram as SchemaHistogram, + GeoHashGrid as SchemaGeoHashGrid, + Nested as SchemaNested, +} from './dataquery.gen'; + +export * from './dataquery.gen'; +export { Elasticsearch as ElasticsearchQuery } from './dataquery.gen'; + +// Start of temporary overrides because of incorrect type generation in dataquery.gen.ts +export interface BasePipelineMetricAggregation extends SchemaBasePipelineMetricAggregation { + type: PipelineMetricAggregationType; +} + +export interface PipelineMetricAggregationWithMultipleBucketPaths + extends SchemaPipelineMetricAggregationWithMultipleBucketPaths { + type: PipelineMetricAggregationType; +} + +export type MovingAverageModelSettings = Partial< + Extract< + | MovingAverageSimpleModelSettings + | MovingAverageLinearModelSettings + | MovingAverageEWMAModelSettings + | MovingAverageHoltModelSettings + | MovingAverageHoltWintersModelSettings, + { model: T } + > +>; + +export interface MovingAverage extends SchemaMovingAverage { + settings?: MovingAverageModelSettings; +} + +export interface Filters extends SchemaFilters { + settings?: { + filters?: Filter[]; + }; +} + +export interface Terms extends SchemaTerms { + settings?: { + min_doc_count?: string; + missing?: string; + order?: TermsOrder; + orderBy?: string; + size?: string; + }; +} + +export interface DateHistogram extends SchemaDateHistogram { + settings?: { + interval?: string; + min_doc_count?: string; + offset?: string; + timeZone?: string; + trimEdges?: string; + }; +} + +export interface Histogram extends SchemaHistogram { + settings?: { + interval?: string; + min_doc_count?: string; + }; +} + +interface GeoHashGrid extends SchemaGeoHashGrid { + settings?: { + precision?: string; + }; +} + +interface Nested extends SchemaNested { + settings?: {}; +} + +export type BucketAggregation = DateHistogram | Histogram | Terms | Filters | GeoHashGrid | Nested; +// End of temporary overrides export type Interval = 'Hourly' | 'Daily' | 'Weekly' | 'Monthly' | 'Yearly'; @@ -65,14 +154,6 @@ export interface ElasticsearchAggregation { hide: boolean; } -export interface ElasticsearchQuery extends DataQuery { - alias?: string; - query?: string; - bucketAggs?: BucketAggregation[]; - metrics?: MetricAggregation[]; - timeField?: string; -} - export interface TermsQuery { query?: string; size?: number;