mirror of https://github.com/grafana/grafana
Elasticsearch: Implement schema for query (#62147)
* Elasticsearch: Implement schema for query * Comment out types I am not sure how to do * Manually fix typing for PipelineMetricAggregationWithMultipleBucketPaths and BasePipelineMetricAggregation * Import types to types.ts to have single source of truth * Cleanup, reorder * Remove unnecesary Schema. * Fix test * Refactorpull/62604/head
parent
4a8763d7b6
commit
ccfa9a4ef0
@ -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 | |
||||
|----------|------|----------|-------------| |
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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<T extends MovingAverageModel = MovingAverageModel> = 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") |
||||
}, |
||||
] |
||||
}, |
||||
] |
||||
} |
||||
} |
@ -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<string, unknown>; |
||||
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<Filter>; |
||||
} |
||||
|
||||
export const defaultFiltersSettings: Partial<FiltersSettings> = { |
||||
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<string, unknown>; |
||||
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<string>; |
||||
}; |
||||
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<PipelineVariable>; |
||||
} |
||||
|
||||
export const defaultPipelineMetricAggregationWithMultipleBucketPaths: Partial<PipelineMetricAggregationWithMultipleBucketPaths> = { |
||||
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<string, unknown>; |
||||
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<string>; |
||||
}; |
||||
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<BucketAggregation>; |
||||
metrics?: Array<MetricAggregation>; |
||||
query?: string; |
||||
timeField?: string; |
||||
} |
||||
|
||||
export const defaultElasticsearch: Partial<Elasticsearch> = { |
||||
bucketAggs: [], |
||||
metrics: [], |
||||
}; |
Loading…
Reference in new issue