mirror of https://github.com/grafana/grafana.git
				
				
				
			CloudMonitoring: Initial GCM Schema (#67739)
* Initial GCM schema work - Split types for convenience - Update conditionals where needed - Update type references * Add additional supporting types * Add some more accessory and legacy types * Add missing type * Rename backend folder * Add missing generated file * Review
This commit is contained in:
		
							parent
							
								
									2f74d0c6a9
								
							
						
					
					
						commit
						108acee08e
					
				|  | @ -3774,7 +3774,7 @@ exports[`better eslint`] = { | |||
|       [0, 0, 0, "Do not use any type assertions.", "1"], | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "2"] | ||||
|     ], | ||||
|     "public/app/plugins/datasource/cloud-monitoring/types.ts:5381": [ | ||||
|     "public/app/plugins/datasource/cloud-monitoring/types/types.ts:5381": [ | ||||
|       [0, 0, 0, "Unexpected any. Specify a different type.", "0"] | ||||
|     ], | ||||
|     "public/app/plugins/datasource/cloudwatch/components/ConfigEditor.test.tsx:5381": [ | ||||
|  |  | |||
|  | @ -233,7 +233,7 @@ | |||
| # OSS Plugin Partnerships backend code | ||||
| /pkg/tsdb/cloudwatch/ @grafana/aws-datasources | ||||
| /pkg/tsdb/azuremonitor/ @grafana/partner-datasources | ||||
| /pkg/tsdb/cloudmonitoring/ @grafana/partner-datasources | ||||
| /pkg/tsdb/cloud-monitoring/ @grafana/partner-datasources | ||||
| 
 | ||||
| # Observability backend code | ||||
| /pkg/tsdb/prometheus/ @grafana/observability-metrics | ||||
|  |  | |||
|  | @ -89,7 +89,7 @@ | |||
|   }, | ||||
|   { | ||||
|     "type": "changedfiles", | ||||
|     "matches": [ "public/app/plugins/datasource/cloud-monitoring/**/*", "pkg/tsdb/cloudmonitoring/**/*"], | ||||
|     "matches": [ "public/app/plugins/datasource/cloud-monitoring/**/*", "pkg/tsdb/cloud-monitoring/**/*"], | ||||
|     "action": "updateLabel", | ||||
|     "addLabel": "datasource/GoogleCloudMonitoring" | ||||
|   }, | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ on: | |||
|     paths: | ||||
|       - 'pkg/tsdb/azuremonitor/**' | ||||
|       - 'pkg/tsdb/cloudwatch/**' | ||||
|       - 'pkg/tsdb/cloudmonitoring/**' | ||||
|       - 'pkg/tsdb/cloud-monitoring/**' | ||||
|       - 'public/app/plugins/datasource/azuremonitor/**' | ||||
|       - 'public/app/plugins/datasource/cloudwatch/**' | ||||
|       - 'public/app/plugins/datasource/cloud-monitoring/**' | ||||
|  | @ -17,4 +17,4 @@ jobs: | |||
|     uses: grafana/code-coverage/.github/workflows/code-coverage.yml@v0.1.19 | ||||
|     with: | ||||
|       frontend-path-regexp: public\/app\/plugins\/datasource\/(azuremonitor|cloud-monitoring|cloudwatch) | ||||
|       backend-path-regexp: pkg\/tsdb\/(azuremonitor|cloudmonitoring|cloudwatch) | ||||
|       backend-path-regexp: pkg\/tsdb\/(azuremonitor|cloud-monitoring|cloudwatch) | ||||
|  |  | |||
|  | @ -0,0 +1,19 @@ | |||
| --- | ||||
| keywords: | ||||
|   - grafana | ||||
|   - schema | ||||
| title: GoogleCloudMonitoringDataQuery kind | ||||
| --- | ||||
| > Both documentation generation and kinds schemas are in active development and subject to change without prior notice. | ||||
| 
 | ||||
| ## GoogleCloudMonitoringDataQuery | ||||
| 
 | ||||
| #### Maturity: [merged](../../../maturity/#merged) | ||||
| #### Version: 0.0 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| | Property | Type | Required | Default | Description | | ||||
| |----------|------|----------|---------|-------------| | ||||
| 
 | ||||
| 
 | ||||
|  | @ -10,7 +10,7 @@ import ( | |||
| 	"github.com/grafana/grafana/pkg/plugins/backendplugin" | ||||
| 	"github.com/grafana/grafana/pkg/plugins/log" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/azuremonitor" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/cloudmonitoring" | ||||
| 	cloudmonitoring "github.com/grafana/grafana/pkg/tsdb/cloud-monitoring" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/cloudwatch" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/elasticsearch" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/grafanads" | ||||
|  |  | |||
|  | @ -37,7 +37,7 @@ import ( | |||
| 	"github.com/grafana/grafana/pkg/services/searchV2" | ||||
| 	"github.com/grafana/grafana/pkg/setting" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/azuremonitor" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/cloudmonitoring" | ||||
| 	cloudmonitoring "github.com/grafana/grafana/pkg/tsdb/cloud-monitoring" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/cloudwatch" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/elasticsearch" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/grafanads" | ||||
|  |  | |||
|  | @ -142,7 +142,7 @@ import ( | |||
| 	"github.com/grafana/grafana/pkg/services/user/userimpl" | ||||
| 	"github.com/grafana/grafana/pkg/setting" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/azuremonitor" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/cloudmonitoring" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/cloud-monitoring" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/cloudwatch" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/elasticsearch" | ||||
| 	"github.com/grafana/grafana/pkg/tsdb/grafanads" | ||||
|  |  | |||
|  | @ -0,0 +1,504 @@ | |||
| // 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 | ||||
| 
 | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for AlignmentTypes.
 | ||||
| const ( | ||||
| 	AlignmentTypesALIGNCOUNT         AlignmentTypes = "ALIGN_COUNT" | ||||
| 	AlignmentTypesALIGNCOUNTFALSE    AlignmentTypes = "ALIGN_COUNT_FALSE" | ||||
| 	AlignmentTypesALIGNCOUNTTRUE     AlignmentTypes = "ALIGN_COUNT_TRUE" | ||||
| 	AlignmentTypesALIGNDELTA         AlignmentTypes = "ALIGN_DELTA" | ||||
| 	AlignmentTypesALIGNFRACTIONTRUE  AlignmentTypes = "ALIGN_FRACTION_TRUE" | ||||
| 	AlignmentTypesALIGNINTERPOLATE   AlignmentTypes = "ALIGN_INTERPOLATE" | ||||
| 	AlignmentTypesALIGNMAX           AlignmentTypes = "ALIGN_MAX" | ||||
| 	AlignmentTypesALIGNMEAN          AlignmentTypes = "ALIGN_MEAN" | ||||
| 	AlignmentTypesALIGNMIN           AlignmentTypes = "ALIGN_MIN" | ||||
| 	AlignmentTypesALIGNNEXTOLDER     AlignmentTypes = "ALIGN_NEXT_OLDER" | ||||
| 	AlignmentTypesALIGNNONE          AlignmentTypes = "ALIGN_NONE" | ||||
| 	AlignmentTypesALIGNPERCENTCHANGE AlignmentTypes = "ALIGN_PERCENT_CHANGE" | ||||
| 	AlignmentTypesALIGNPERCENTILE05  AlignmentTypes = "ALIGN_PERCENTILE_05" | ||||
| 	AlignmentTypesALIGNPERCENTILE50  AlignmentTypes = "ALIGN_PERCENTILE_50" | ||||
| 	AlignmentTypesALIGNPERCENTILE95  AlignmentTypes = "ALIGN_PERCENTILE_95" | ||||
| 	AlignmentTypesALIGNPERCENTILE99  AlignmentTypes = "ALIGN_PERCENTILE_99" | ||||
| 	AlignmentTypesALIGNRATE          AlignmentTypes = "ALIGN_RATE" | ||||
| 	AlignmentTypesALIGNSTDDEV        AlignmentTypes = "ALIGN_STDDEV" | ||||
| 	AlignmentTypesALIGNSUM           AlignmentTypes = "ALIGN_SUM" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for AnnotationQueryPreprocessor.
 | ||||
| const ( | ||||
| 	AnnotationQueryPreprocessorDelta AnnotationQueryPreprocessor = "delta" | ||||
| 	AnnotationQueryPreprocessorNone  AnnotationQueryPreprocessor = "none" | ||||
| 	AnnotationQueryPreprocessorRate  AnnotationQueryPreprocessor = "rate" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for CloudMonitoringQueryTimeSeriesListPreprocessor.
 | ||||
| const ( | ||||
| 	CloudMonitoringQueryTimeSeriesListPreprocessorDelta CloudMonitoringQueryTimeSeriesListPreprocessor = "delta" | ||||
| 	CloudMonitoringQueryTimeSeriesListPreprocessorNone  CloudMonitoringQueryTimeSeriesListPreprocessor = "none" | ||||
| 	CloudMonitoringQueryTimeSeriesListPreprocessorRate  CloudMonitoringQueryTimeSeriesListPreprocessor = "rate" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for LegacyCloudMonitoringAnnotationQueryMetricKind.
 | ||||
| const ( | ||||
| 	LegacyCloudMonitoringAnnotationQueryMetricKindCUMULATIVE            LegacyCloudMonitoringAnnotationQueryMetricKind = "CUMULATIVE" | ||||
| 	LegacyCloudMonitoringAnnotationQueryMetricKindDELTA                 LegacyCloudMonitoringAnnotationQueryMetricKind = "DELTA" | ||||
| 	LegacyCloudMonitoringAnnotationQueryMetricKindGAUGE                 LegacyCloudMonitoringAnnotationQueryMetricKind = "GAUGE" | ||||
| 	LegacyCloudMonitoringAnnotationQueryMetricKindMETRICKINDUNSPECIFIED LegacyCloudMonitoringAnnotationQueryMetricKind = "METRIC_KIND_UNSPECIFIED" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for MetricFindQueryTypes.
 | ||||
| const ( | ||||
| 	MetricFindQueryTypesAggregations     MetricFindQueryTypes = "aggregations" | ||||
| 	MetricFindQueryTypesAligners         MetricFindQueryTypes = "aligners" | ||||
| 	MetricFindQueryTypesAlignmentPeriods MetricFindQueryTypes = "alignmentPeriods" | ||||
| 	MetricFindQueryTypesDefaultProject   MetricFindQueryTypes = "defaultProject" | ||||
| 	MetricFindQueryTypesLabelKeys        MetricFindQueryTypes = "labelKeys" | ||||
| 	MetricFindQueryTypesLabelValues      MetricFindQueryTypes = "labelValues" | ||||
| 	MetricFindQueryTypesMetricTypes      MetricFindQueryTypes = "metricTypes" | ||||
| 	MetricFindQueryTypesProjects         MetricFindQueryTypes = "projects" | ||||
| 	MetricFindQueryTypesResourceTypes    MetricFindQueryTypes = "resourceTypes" | ||||
| 	MetricFindQueryTypesSelectors        MetricFindQueryTypes = "selectors" | ||||
| 	MetricFindQueryTypesServices         MetricFindQueryTypes = "services" | ||||
| 	MetricFindQueryTypesSlo              MetricFindQueryTypes = "slo" | ||||
| 	MetricFindQueryTypesSloServices      MetricFindQueryTypes = "sloServices" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for MetricKind.
 | ||||
| const ( | ||||
| 	MetricKindCUMULATIVE            MetricKind = "CUMULATIVE" | ||||
| 	MetricKindDELTA                 MetricKind = "DELTA" | ||||
| 	MetricKindGAUGE                 MetricKind = "GAUGE" | ||||
| 	MetricKindMETRICKINDUNSPECIFIED MetricKind = "METRIC_KIND_UNSPECIFIED" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for MetricQueryMetricKind.
 | ||||
| const ( | ||||
| 	MetricQueryMetricKindCUMULATIVE            MetricQueryMetricKind = "CUMULATIVE" | ||||
| 	MetricQueryMetricKindDELTA                 MetricQueryMetricKind = "DELTA" | ||||
| 	MetricQueryMetricKindGAUGE                 MetricQueryMetricKind = "GAUGE" | ||||
| 	MetricQueryMetricKindMETRICKINDUNSPECIFIED MetricQueryMetricKind = "METRIC_KIND_UNSPECIFIED" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for MetricQueryPreprocessor.
 | ||||
| const ( | ||||
| 	MetricQueryPreprocessorDelta MetricQueryPreprocessor = "delta" | ||||
| 	MetricQueryPreprocessorNone  MetricQueryPreprocessor = "none" | ||||
| 	MetricQueryPreprocessorRate  MetricQueryPreprocessor = "rate" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for PreprocessorType.
 | ||||
| const ( | ||||
| 	PreprocessorTypeDelta PreprocessorType = "delta" | ||||
| 	PreprocessorTypeNone  PreprocessorType = "none" | ||||
| 	PreprocessorTypeRate  PreprocessorType = "rate" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for QueryType.
 | ||||
| const ( | ||||
| 	QueryTypeAnnotation      QueryType = "annotation" | ||||
| 	QueryTypeSlo             QueryType = "slo" | ||||
| 	QueryTypeTimeSeriesList  QueryType = "timeSeriesList" | ||||
| 	QueryTypeTimeSeriesQuery QueryType = "timeSeriesQuery" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for TimeSeriesListPreprocessor.
 | ||||
| const ( | ||||
| 	TimeSeriesListPreprocessorDelta TimeSeriesListPreprocessor = "delta" | ||||
| 	TimeSeriesListPreprocessorNone  TimeSeriesListPreprocessor = "none" | ||||
| 	TimeSeriesListPreprocessorRate  TimeSeriesListPreprocessor = "rate" | ||||
| ) | ||||
| 
 | ||||
| // Defines values for ValueTypes.
 | ||||
| const ( | ||||
| 	ValueTypesBOOL                 ValueTypes = "BOOL" | ||||
| 	ValueTypesDISTRIBUTION         ValueTypes = "DISTRIBUTION" | ||||
| 	ValueTypesDOUBLE               ValueTypes = "DOUBLE" | ||||
| 	ValueTypesINT64                ValueTypes = "INT64" | ||||
| 	ValueTypesMONEY                ValueTypes = "MONEY" | ||||
| 	ValueTypesSTRING               ValueTypes = "STRING" | ||||
| 	ValueTypesVALUETYPEUNSPECIFIED ValueTypes = "VALUE_TYPE_UNSPECIFIED" | ||||
| ) | ||||
| 
 | ||||
| // AlignmentTypes defines model for AlignmentTypes.
 | ||||
| type AlignmentTypes string | ||||
| 
 | ||||
| // Annotation sub-query properties.
 | ||||
| type AnnotationQuery struct { | ||||
| 	// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 	AlignmentPeriod *string `json:"alignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
 | ||||
| 	CrossSeriesReducer string `json:"crossSeriesReducer"` | ||||
| 
 | ||||
| 	// Array of filters to query data by. Labels that can be filtered on are defined by the metric.
 | ||||
| 	Filters []string `json:"filters,omitempty"` | ||||
| 
 | ||||
| 	// Array of labels to group data by.
 | ||||
| 	GroupBys []string `json:"groupBys,omitempty"` | ||||
| 
 | ||||
| 	// Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 	PerSeriesAligner *string `json:"perSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 	// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
 | ||||
| 	Preprocessor *AnnotationQueryPreprocessor `json:"preprocessor,omitempty"` | ||||
| 
 | ||||
| 	// GCP project to execute the query against.
 | ||||
| 	ProjectName string `json:"projectName"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 	SecondaryAlignmentPeriod *string `json:"secondaryAlignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
 | ||||
| 	SecondaryCrossSeriesReducer *string `json:"secondaryCrossSeriesReducer,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Array of labels to group data by.
 | ||||
| 	SecondaryGroupBys []string `json:"secondaryGroupBys,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 	SecondaryPerSeriesAligner *string `json:"secondaryPerSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 	// Annotation text.
 | ||||
| 	Text *string `json:"text,omitempty"` | ||||
| 
 | ||||
| 	// Annotation title.
 | ||||
| 	Title *string `json:"title,omitempty"` | ||||
| 
 | ||||
| 	// Data view, defaults to FULL.
 | ||||
| 	View                 *string                `json:"view,omitempty"` | ||||
| 	AdditionalProperties map[string]interface{} `json:"-"` | ||||
| } | ||||
| 
 | ||||
| // Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
 | ||||
| type AnnotationQueryPreprocessor string | ||||
| 
 | ||||
| // CloudMonitoringQuery defines model for CloudMonitoringQuery.
 | ||||
| type CloudMonitoringQuery struct { | ||||
| 	// Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.
 | ||||
| 	AliasBy *string `json:"aliasBy,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"` | ||||
| 
 | ||||
| 	// Hide true if query is disabled (ie should not be returned to the dashboard)
 | ||||
| 	// Note this does not always imply that the query should not be executed since
 | ||||
| 	// the results from a hidden query may be used as the input to other queries (SSE etc)
 | ||||
| 	Hide *bool `json:"hide,omitempty"` | ||||
| 
 | ||||
| 	// Time interval in milliseconds.
 | ||||
| 	IntervalMs *float32 `json:"intervalMs,omitempty"` | ||||
| 
 | ||||
| 	// Specify the query flavor
 | ||||
| 	// TODO make this required and give it a default
 | ||||
| 	QueryType *string `json:"queryType,omitempty"` | ||||
| 
 | ||||
| 	// A unique identifier for the query within the list of targets.
 | ||||
| 	// In server side expressions, the refId is used as a variable name to identify results.
 | ||||
| 	// By default, the UI will assign A->Z; however setting meaningful names may be useful.
 | ||||
| 	RefId string `json:"refId"` | ||||
| 
 | ||||
| 	// SLO sub-query properties.
 | ||||
| 	SloQuery *struct { | ||||
| 		// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 		AlignmentPeriod *string `json:"alignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 		// SLO goal value.
 | ||||
| 		Goal *float32 `json:"goal,omitempty"` | ||||
| 
 | ||||
| 		// Specific lookback period for the SLO.
 | ||||
| 		LookbackPeriod *string `json:"lookbackPeriod,omitempty"` | ||||
| 
 | ||||
| 		// Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 		PerSeriesAligner *string `json:"perSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 		// GCP project to execute the query against.
 | ||||
| 		ProjectName string `json:"projectName"` | ||||
| 
 | ||||
| 		// SLO selector.
 | ||||
| 		SelectorName string `json:"selectorName"` | ||||
| 
 | ||||
| 		// ID for the service the SLO is in.
 | ||||
| 		ServiceId string `json:"serviceId"` | ||||
| 
 | ||||
| 		// Name for the service the SLO is in.
 | ||||
| 		ServiceName string `json:"serviceName"` | ||||
| 
 | ||||
| 		// ID for the SLO.
 | ||||
| 		SloId string `json:"sloId"` | ||||
| 
 | ||||
| 		// Name of the SLO.
 | ||||
| 		SloName string `json:"sloName"` | ||||
| 	} `json:"sloQuery,omitempty"` | ||||
| 
 | ||||
| 	// GCM query type.
 | ||||
| 	// queryType: #QueryType
 | ||||
| 	// Time Series List sub-query properties.
 | ||||
| 	TimeSeriesList *CloudMonitoringQueryTimeSeriesList `json:"timeSeriesList,omitempty"` | ||||
| 
 | ||||
| 	// Time Series sub-query properties.
 | ||||
| 	TimeSeriesQuery *struct { | ||||
| 		// To disable the graphPeriod, it should explictly be set to 'disabled'.
 | ||||
| 		GraphPeriod *string `json:"graphPeriod,omitempty"` | ||||
| 
 | ||||
| 		// GCP project to execute the query against.
 | ||||
| 		ProjectName string `json:"projectName"` | ||||
| 
 | ||||
| 		// MQL query to be executed.
 | ||||
| 		Query string `json:"query"` | ||||
| 	} `json:"timeSeriesQuery,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
 | ||||
| type CloudMonitoringQueryTimeSeriesListPreprocessor string | ||||
| 
 | ||||
| // GCM query type.
 | ||||
| // queryType: #QueryType
 | ||||
| // Time Series List sub-query properties.
 | ||||
| type CloudMonitoringQueryTimeSeriesList struct { | ||||
| 	// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 	AlignmentPeriod *string `json:"alignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
 | ||||
| 	CrossSeriesReducer *string `json:"crossSeriesReducer,omitempty"` | ||||
| 
 | ||||
| 	// Array of filters to query data by. Labels that can be filtered on are defined by the metric.
 | ||||
| 	Filters []string `json:"filters,omitempty"` | ||||
| 
 | ||||
| 	// Array of labels to group data by.
 | ||||
| 	GroupBys []string `json:"groupBys,omitempty"` | ||||
| 
 | ||||
| 	// Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 	PerSeriesAligner *string `json:"perSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 	// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
 | ||||
| 	Preprocessor *CloudMonitoringQueryTimeSeriesListPreprocessor `json:"preprocessor,omitempty"` | ||||
| 
 | ||||
| 	// GCP project to execute the query against.
 | ||||
| 	ProjectName *string `json:"projectName,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 	SecondaryAlignmentPeriod *string `json:"secondaryAlignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
 | ||||
| 	SecondaryCrossSeriesReducer *string `json:"secondaryCrossSeriesReducer,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Array of labels to group data by.
 | ||||
| 	SecondaryGroupBys []string `json:"secondaryGroupBys,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 	SecondaryPerSeriesAligner *string `json:"secondaryPerSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 	// Annotation text.
 | ||||
| 	Text *string `json:"text,omitempty"` | ||||
| 
 | ||||
| 	// Annotation title.
 | ||||
| 	Title *string `json:"title,omitempty"` | ||||
| 
 | ||||
| 	// Data view, defaults to FULL.
 | ||||
| 	View                 *string                `json:"view,omitempty"` | ||||
| 	AdditionalProperties map[string]interface{} `json:"-"` | ||||
| 	union                json.RawMessage | ||||
| } | ||||
| 
 | ||||
| // Query filter representation.
 | ||||
| type Filter struct { | ||||
| 	// Filter condition.
 | ||||
| 	Condition *string `json:"condition,omitempty"` | ||||
| 
 | ||||
| 	// Filter key.
 | ||||
| 	Key string `json:"key"` | ||||
| 
 | ||||
| 	// Filter operator.
 | ||||
| 	Operator string `json:"operator"` | ||||
| 
 | ||||
| 	// Filter value.
 | ||||
| 	Value string `json:"value"` | ||||
| } | ||||
| 
 | ||||
| // GoogleCloudMonitoringDataQuery defines model for GoogleCloudMonitoringDataQuery.
 | ||||
| type GoogleCloudMonitoringDataQuery = map[string]interface{} | ||||
| 
 | ||||
| // @deprecated Use AnnotationQuery instead. Legacy annotation query properties for migration purposes.
 | ||||
| type LegacyCloudMonitoringAnnotationQuery struct { | ||||
| 	// Array of filters to query data by. Labels that can be filtered on are defined by the metric.
 | ||||
| 	Filters    []string                                       `json:"filters"` | ||||
| 	MetricKind LegacyCloudMonitoringAnnotationQueryMetricKind `json:"metricKind"` | ||||
| 	MetricType string                                         `json:"metricType"` | ||||
| 
 | ||||
| 	// GCP project to execute the query against.
 | ||||
| 	ProjectName string `json:"projectName"` | ||||
| 
 | ||||
| 	// Query refId.
 | ||||
| 	RefId string `json:"refId"` | ||||
| 
 | ||||
| 	// Annotation text.
 | ||||
| 	Text string `json:"text"` | ||||
| 
 | ||||
| 	// Annotation title.
 | ||||
| 	Title     string `json:"title"` | ||||
| 	ValueType string `json:"valueType"` | ||||
| } | ||||
| 
 | ||||
| // LegacyCloudMonitoringAnnotationQueryMetricKind defines model for LegacyCloudMonitoringAnnotationQuery.MetricKind.
 | ||||
| type LegacyCloudMonitoringAnnotationQueryMetricKind string | ||||
| 
 | ||||
| // MetricFindQueryTypes defines model for MetricFindQueryTypes.
 | ||||
| type MetricFindQueryTypes string | ||||
| 
 | ||||
| // MetricKind defines model for MetricKind.
 | ||||
| type MetricKind string | ||||
| 
 | ||||
| // @deprecated This type is for migration purposes only. Replaced by TimeSeriesList Metric sub-query properties.
 | ||||
| type MetricQuery struct { | ||||
| 	// Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.
 | ||||
| 	AliasBy *string `json:"aliasBy,omitempty"` | ||||
| 
 | ||||
| 	// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 	AlignmentPeriod *string `json:"alignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
 | ||||
| 	CrossSeriesReducer string `json:"crossSeriesReducer"` | ||||
| 	EditorMode         string `json:"editorMode"` | ||||
| 
 | ||||
| 	// Array of filters to query data by. Labels that can be filtered on are defined by the metric.
 | ||||
| 	Filters []string `json:"filters,omitempty"` | ||||
| 
 | ||||
| 	// To disable the graphPeriod, it should explictly be set to 'disabled'.
 | ||||
| 	GraphPeriod *string `json:"graphPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Array of labels to group data by.
 | ||||
| 	GroupBys   []string               `json:"groupBys,omitempty"` | ||||
| 	MetricKind *MetricQueryMetricKind `json:"metricKind,omitempty"` | ||||
| 	MetricType string                 `json:"metricType"` | ||||
| 
 | ||||
| 	// Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 	PerSeriesAligner *string `json:"perSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 	// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
 | ||||
| 	Preprocessor *MetricQueryPreprocessor `json:"preprocessor,omitempty"` | ||||
| 
 | ||||
| 	// GCP project to execute the query against.
 | ||||
| 	ProjectName string `json:"projectName"` | ||||
| 
 | ||||
| 	// MQL query to be executed.
 | ||||
| 	Query     string  `json:"query"` | ||||
| 	ValueType *string `json:"valueType,omitempty"` | ||||
| 	View      *string `json:"view,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // MetricQueryMetricKind defines model for MetricQuery.MetricKind.
 | ||||
| type MetricQueryMetricKind string | ||||
| 
 | ||||
| // Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
 | ||||
| type MetricQueryPreprocessor string | ||||
| 
 | ||||
| // Types of pre-processor available. Defined by the metric.
 | ||||
| type PreprocessorType string | ||||
| 
 | ||||
| // Defines the supported queryTypes.
 | ||||
| type QueryType string | ||||
| 
 | ||||
| // SLO sub-query properties.
 | ||||
| type SLOQuery struct { | ||||
| 	// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 	AlignmentPeriod *string `json:"alignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 	// SLO goal value.
 | ||||
| 	Goal *float32 `json:"goal,omitempty"` | ||||
| 
 | ||||
| 	// Specific lookback period for the SLO.
 | ||||
| 	LookbackPeriod *string `json:"lookbackPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 	PerSeriesAligner *string `json:"perSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 	// GCP project to execute the query against.
 | ||||
| 	ProjectName string `json:"projectName"` | ||||
| 
 | ||||
| 	// SLO selector.
 | ||||
| 	SelectorName string `json:"selectorName"` | ||||
| 
 | ||||
| 	// ID for the service the SLO is in.
 | ||||
| 	ServiceId string `json:"serviceId"` | ||||
| 
 | ||||
| 	// Name for the service the SLO is in.
 | ||||
| 	ServiceName string `json:"serviceName"` | ||||
| 
 | ||||
| 	// ID for the SLO.
 | ||||
| 	SloId string `json:"sloId"` | ||||
| 
 | ||||
| 	// Name of the SLO.
 | ||||
| 	SloName string `json:"sloName"` | ||||
| } | ||||
| 
 | ||||
| // Time Series List sub-query properties.
 | ||||
| type TimeSeriesList struct { | ||||
| 	// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 	AlignmentPeriod *string `json:"alignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
 | ||||
| 	CrossSeriesReducer string `json:"crossSeriesReducer"` | ||||
| 
 | ||||
| 	// Array of filters to query data by. Labels that can be filtered on are defined by the metric.
 | ||||
| 	Filters []string `json:"filters,omitempty"` | ||||
| 
 | ||||
| 	// Array of labels to group data by.
 | ||||
| 	GroupBys []string `json:"groupBys,omitempty"` | ||||
| 
 | ||||
| 	// Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 	PerSeriesAligner *string `json:"perSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 	// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
 | ||||
| 	Preprocessor *TimeSeriesListPreprocessor `json:"preprocessor,omitempty"` | ||||
| 
 | ||||
| 	// GCP project to execute the query against.
 | ||||
| 	ProjectName string `json:"projectName"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
 | ||||
| 	SecondaryAlignmentPeriod *string `json:"secondaryAlignmentPeriod,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
 | ||||
| 	SecondaryCrossSeriesReducer *string `json:"secondaryCrossSeriesReducer,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Array of labels to group data by.
 | ||||
| 	SecondaryGroupBys []string `json:"secondaryGroupBys,omitempty"` | ||||
| 
 | ||||
| 	// Only present if a preprocessor is selected. Alignment function to be used. Defaults to ALIGN_MEAN.
 | ||||
| 	SecondaryPerSeriesAligner *string `json:"secondaryPerSeriesAligner,omitempty"` | ||||
| 
 | ||||
| 	// Data view, defaults to FULL.
 | ||||
| 	View                 *string                `json:"view,omitempty"` | ||||
| 	AdditionalProperties map[string]interface{} `json:"-"` | ||||
| } | ||||
| 
 | ||||
| // Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
 | ||||
| type TimeSeriesListPreprocessor string | ||||
| 
 | ||||
| // Time Series sub-query properties.
 | ||||
| type TimeSeriesQuery struct { | ||||
| 	// To disable the graphPeriod, it should explictly be set to 'disabled'.
 | ||||
| 	GraphPeriod *string `json:"graphPeriod,omitempty"` | ||||
| 
 | ||||
| 	// GCP project to execute the query against.
 | ||||
| 	ProjectName string `json:"projectName"` | ||||
| 
 | ||||
| 	// MQL query to be executed.
 | ||||
| 	Query string `json:"query"` | ||||
| } | ||||
| 
 | ||||
| // ValueTypes defines model for ValueTypes.
 | ||||
| type ValueTypes string | ||||
|  | @ -11,7 +11,8 @@ import { | |||
|   getLabelKeys, | ||||
|   getMetricTypesByService, | ||||
| } from './functions'; | ||||
| import { CloudMonitoringVariableQuery, MetricDescriptor, MetricFindQueryTypes, MetricKind, ValueTypes } from './types'; | ||||
| import { MetricKind, ValueTypes, MetricFindQueryTypes } from './types/query'; | ||||
| import { CloudMonitoringVariableQuery, MetricDescriptor } from './types/types'; | ||||
| 
 | ||||
| export default class CloudMonitoringMetricFindQuery { | ||||
|   constructor(private datasource: CloudMonitoringDatasource) {} | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { DataSourceInstanceSettings, DataSourcePluginMeta } from '@grafana/data'; | ||||
| import { GoogleAuthType } from '@grafana/google-sdk'; | ||||
| 
 | ||||
| import { CloudMonitoringOptions } from '../types'; | ||||
| import { CloudMonitoringOptions } from '../types/types'; | ||||
| 
 | ||||
| export const createMockInstanceSetttings = ( | ||||
|   overrides?: Partial<DataSourceInstanceSettings<CloudMonitoringOptions>> | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| import { MetricDescriptor, MetricKind, ValueTypes } from '../types'; | ||||
| import { MetricKind, ValueTypes } from '../types/query'; | ||||
| import { MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| export const createMockMetricDescriptor = (overrides?: Partial<MetricDescriptor>): MetricDescriptor => { | ||||
|   return { | ||||
|  |  | |||
|  | @ -1,4 +1,11 @@ | |||
| import { AlignmentTypes, CloudMonitoringQuery, QueryType, SLOQuery, TimeSeriesList, TimeSeriesQuery } from '../types'; | ||||
| import { | ||||
|   AlignmentTypes, | ||||
|   CloudMonitoringQuery, | ||||
|   QueryType, | ||||
|   SLOQuery, | ||||
|   TimeSeriesList, | ||||
|   TimeSeriesQuery, | ||||
| } from '../types/query'; | ||||
| 
 | ||||
| type Subset<K> = { | ||||
|   [attr in keyof K]?: K[attr] extends object ? Subset<K[attr]> : K[attr]; | ||||
|  |  | |||
|  | @ -5,10 +5,10 @@ import { CloudMonitoringAnnotationSupport } from './annotationSupport'; | |||
| import { | ||||
|   AlignmentTypes, | ||||
|   CloudMonitoringQuery, | ||||
|   LegacyCloudMonitoringAnnotationQuery, | ||||
|   MetricKind, | ||||
|   QueryType, | ||||
| } from './types'; | ||||
|   MetricKind, | ||||
|   LegacyCloudMonitoringAnnotationQuery, | ||||
| } from './types/query'; | ||||
| 
 | ||||
| const query: CloudMonitoringQuery = { | ||||
|   refId: 'query', | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { AnnotationSupport, AnnotationQuery } from '@grafana/data'; | |||
| 
 | ||||
| import { AnnotationQueryEditor } from './components/AnnotationQueryEditor'; | ||||
| import CloudMonitoringDatasource from './datasource'; | ||||
| import { AlignmentTypes, CloudMonitoringQuery, LegacyCloudMonitoringAnnotationQuery, QueryType } from './types'; | ||||
| import { AlignmentTypes, CloudMonitoringQuery, QueryType, LegacyCloudMonitoringAnnotationQuery } from './types/query'; | ||||
| 
 | ||||
| // The legacy query format sets the title and text values to empty strings by default.
 | ||||
| // If the title or text is not undefined at the top-level of the annotation target,
 | ||||
|  |  | |||
|  | @ -3,7 +3,8 @@ import React from 'react'; | |||
| import { openMenu } from 'react-select-event'; | ||||
| import { TemplateSrvStub } from 'test/specs/helpers'; | ||||
| 
 | ||||
| import { ValueTypes, MetricKind, MetricDescriptor } from '../types'; | ||||
| import { MetricKind, ValueTypes } from '../types/query'; | ||||
| import { MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| import { Aggregation, Props } from './Aggregation'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,7 +5,8 @@ import { EditorField } from '@grafana/experimental'; | |||
| import { Select } from '@grafana/ui'; | ||||
| 
 | ||||
| import { getAggregationOptionsByMetric } from '../functions'; | ||||
| import { MetricDescriptor, MetricKind, ValueTypes } from '../types'; | ||||
| import { MetricKind, ValueTypes } from '../types/query'; | ||||
| import { MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| export interface Props { | ||||
|   refId: string; | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ import { TemplateSrvMock } from 'app/features/templating/template_srv.mock'; | |||
| import { createMockDatasource } from '../__mocks__/cloudMonitoringDatasource'; | ||||
| import { createMockMetricDescriptor } from '../__mocks__/cloudMonitoringMetricDescriptor'; | ||||
| import { createMockTimeSeriesList } from '../__mocks__/cloudMonitoringQuery'; | ||||
| import { MetricKind, ValueTypes } from '../types'; | ||||
| import { MetricKind, ValueTypes } from '../types/query'; | ||||
| 
 | ||||
| import { Alignment } from './Alignment'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,7 +6,8 @@ import { EditorField, EditorFieldGroup } from '@grafana/experimental'; | |||
| import { ALIGNMENT_PERIODS } from '../constants'; | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { alignmentPeriodLabel } from '../functions'; | ||||
| import { CustomMetaData, MetricDescriptor, PreprocessorType, TimeSeriesList } from '../types'; | ||||
| import { PreprocessorType, TimeSeriesList } from '../types/query'; | ||||
| import { CustomMetaData, MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| import { AlignmentFunction } from './AlignmentFunction'; | ||||
| import { PeriodSelect } from './PeriodSelect'; | ||||
|  |  | |||
|  | @ -4,7 +4,8 @@ import { SelectableValue } from '@grafana/data'; | |||
| import { Select } from '@grafana/ui'; | ||||
| 
 | ||||
| import { getAlignmentPickerData } from '../functions'; | ||||
| import { MetricDescriptor, PreprocessorType, SLOQuery, TimeSeriesList } from '../types'; | ||||
| import { PreprocessorType, SLOQuery, TimeSeriesList } from '../types/query'; | ||||
| import { MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| export interface Props { | ||||
|   inputId: string; | ||||
|  |  | |||
|  | @ -6,7 +6,8 @@ import { EditorField, EditorRows } from '@grafana/experimental'; | |||
| import { Input } from '@grafana/ui'; | ||||
| 
 | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { AnnotationQuery, CloudMonitoringOptions, CloudMonitoringQuery, QueryType } from '../types'; | ||||
| import { AnnotationQuery, CloudMonitoringQuery, QueryType } from '../types/query'; | ||||
| import { CloudMonitoringOptions } from '../types/types'; | ||||
| 
 | ||||
| import { MetricQueryEditor, defaultTimeSeriesList } from './MetricQueryEditor'; | ||||
| 
 | ||||
|  | @ -56,7 +57,7 @@ export const AnnotationQueryEditor = (props: Props) => { | |||
| 
 | ||||
|   // Use a known query type
 | ||||
|   useEffect(() => { | ||||
|     if (!Object.values(QueryType).includes(query.queryType)) { | ||||
|     if (!query.queryType || !Object.values(QueryType).includes(query.queryType)) { | ||||
|       onChange({ ...query, queryType: QueryType.TIME_SERIES_LIST }); | ||||
|     } | ||||
|   }); | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import React, { PureComponent } from 'react'; | |||
| 
 | ||||
| import { QueryEditorHelpProps } from '@grafana/data'; | ||||
| 
 | ||||
| import { CloudMonitoringQuery } from '../types'; | ||||
| import { CloudMonitoringQuery } from '../types/query'; | ||||
| 
 | ||||
| export default class CloudMonitoringCheatSheet extends PureComponent< | ||||
|   QueryEditorHelpProps<CloudMonitoringQuery>, | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import { reportInteraction } from '@grafana/runtime'; | |||
| import { SecureSocksProxySettings } from '@grafana/ui'; | ||||
| import { config } from 'app/core/config'; | ||||
| 
 | ||||
| import { CloudMonitoringOptions, CloudMonitoringSecureJsonData } from '../../types'; | ||||
| import { CloudMonitoringOptions, CloudMonitoringSecureJsonData } from '../../types/types'; | ||||
| 
 | ||||
| export type Props = DataSourcePluginOptionsEditorProps<CloudMonitoringOptions, CloudMonitoringSecureJsonData>; | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import React from 'react'; | |||
| import { openMenu, select } from 'react-select-event'; | ||||
| 
 | ||||
| import { createMockTimeSeriesList } from '../__mocks__/cloudMonitoringQuery'; | ||||
| import { MetricDescriptor } from '../types'; | ||||
| import { MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| import { GroupBy, Props } from './GroupBy'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,7 +6,8 @@ import { MultiSelect } from '@grafana/ui'; | |||
| 
 | ||||
| import { SYSTEM_LABELS } from '../constants'; | ||||
| import { labelsToGroupedOptions } from '../functions'; | ||||
| import { MetricDescriptor, TimeSeriesList } from '../types'; | ||||
| import { TimeSeriesList } from '../types/query'; | ||||
| import { MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| import { Aggregation } from './Aggregation'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import React from 'react'; | |||
| 
 | ||||
| import { createMockDatasource } from '../__mocks__/cloudMonitoringDatasource'; | ||||
| import { createMockQuery } from '../__mocks__/cloudMonitoringQuery'; | ||||
| import { QueryType } from '../types'; | ||||
| import { QueryType } from '../types/query'; | ||||
| 
 | ||||
| import { MetricQueryEditor } from './MetricQueryEditor'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,14 +4,8 @@ import { SelectableValue } from '@grafana/data'; | |||
| import { EditorRows } from '@grafana/experimental'; | ||||
| 
 | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { | ||||
|   AlignmentTypes, | ||||
|   CloudMonitoringQuery, | ||||
|   CustomMetaData, | ||||
|   QueryType, | ||||
|   TimeSeriesList, | ||||
|   TimeSeriesQuery, | ||||
| } from '../types'; | ||||
| import { AlignmentTypes, CloudMonitoringQuery, QueryType, TimeSeriesList, TimeSeriesQuery } from '../types/query'; | ||||
| import { CustomMetaData } from '../types/types'; | ||||
| 
 | ||||
| import { GraphPeriod } from './GraphPeriod'; | ||||
| import { MQLQueryEditor } from './MQLQueryEditor'; | ||||
|  | @ -85,18 +79,19 @@ function Editor({ | |||
| 
 | ||||
|   return ( | ||||
|     <EditorRows> | ||||
|       {[QueryType.TIME_SERIES_LIST, QueryType.ANNOTATION].includes(query.queryType) && query.timeSeriesList && ( | ||||
|         <VisualMetricQueryEditor | ||||
|           refId={refId} | ||||
|           variableOptionGroup={variableOptionGroup} | ||||
|           customMetaData={customMetaData} | ||||
|           onChange={onChangeTimeSeriesList} | ||||
|           datasource={datasource} | ||||
|           query={query.timeSeriesList} | ||||
|           aliasBy={query.aliasBy} | ||||
|           onChangeAliasBy={(aliasBy: string) => onQueryChange({ ...query, aliasBy })} | ||||
|         /> | ||||
|       )} | ||||
|       {(query.queryType === QueryType.ANNOTATION || query.queryType === QueryType.TIME_SERIES_LIST) && | ||||
|         query.timeSeriesList && ( | ||||
|           <VisualMetricQueryEditor | ||||
|             refId={refId} | ||||
|             variableOptionGroup={variableOptionGroup} | ||||
|             customMetaData={customMetaData} | ||||
|             onChange={onChangeTimeSeriesList} | ||||
|             datasource={datasource} | ||||
|             query={query.timeSeriesList} | ||||
|             aliasBy={query.aliasBy} | ||||
|             onChangeAliasBy={(aliasBy: string) => onQueryChange({ ...query, aliasBy })} | ||||
|           /> | ||||
|         )} | ||||
| 
 | ||||
|       {query.queryType === QueryType.TIME_SERIES_QUERY && query.timeSeriesQuery && ( | ||||
|         <> | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import { TemplateSrvMock } from 'app/features/templating/template_srv.mock'; | |||
| 
 | ||||
| import { createMockMetricDescriptor } from '../__mocks__/cloudMonitoringMetricDescriptor'; | ||||
| import { createMockTimeSeriesList } from '../__mocks__/cloudMonitoringQuery'; | ||||
| import { MetricKind, ValueTypes } from '../types'; | ||||
| import { MetricKind, ValueTypes } from '../types/query'; | ||||
| 
 | ||||
| import { Preprocessor } from './Preprocessor'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,7 +5,8 @@ import { EditorField } from '@grafana/experimental'; | |||
| import { RadioButtonGroup } from '@grafana/ui'; | ||||
| 
 | ||||
| import { getAlignmentPickerData } from '../functions'; | ||||
| import { MetricDescriptor, MetricKind, PreprocessorType, TimeSeriesList, ValueTypes } from '../types'; | ||||
| import { PreprocessorType, TimeSeriesList, MetricKind, ValueTypes } from '../types/query'; | ||||
| import { MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| const NONE_OPTION = { label: 'None', value: PreprocessorType.None }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import React from 'react'; | |||
| 
 | ||||
| import { createMockDatasource } from '../__mocks__/cloudMonitoringDatasource'; | ||||
| import { createMockQuery } from '../__mocks__/cloudMonitoringQuery'; | ||||
| import { QueryType } from '../types'; | ||||
| import { QueryType } from '../types/query'; | ||||
| 
 | ||||
| import { QueryEditor } from './QueryEditor'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,7 +4,8 @@ import { QueryEditorProps, toOption } from '@grafana/data'; | |||
| import { EditorRows } from '@grafana/experimental'; | ||||
| 
 | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { CloudMonitoringQuery, QueryType, SLOQuery, CloudMonitoringOptions } from '../types'; | ||||
| import { CloudMonitoringQuery, QueryType, SLOQuery } from '../types/query'; | ||||
| import { CloudMonitoringOptions } from '../types/types'; | ||||
| 
 | ||||
| import { QueryHeader } from './QueryHeader'; | ||||
| import { defaultQuery as defaultSLOQuery } from './SLOQueryEditor'; | ||||
|  | @ -44,7 +45,7 @@ export const QueryEditor = (props: Props) => { | |||
| 
 | ||||
|   // Use a known query type
 | ||||
|   useEffect(() => { | ||||
|     if (!Object.values(QueryType).includes(query.queryType)) { | ||||
|     if (!query.queryType || !Object.values(QueryType).includes(query.queryType)) { | ||||
|       onChange({ ...query, queryType: QueryType.TIME_SERIES_LIST }); | ||||
|     } | ||||
|   }); | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import React from 'react'; | |||
| import { openMenu, select } from 'react-select-event'; | ||||
| 
 | ||||
| import { createMockQuery } from '../__mocks__/cloudMonitoringQuery'; | ||||
| import { QueryType } from '../types'; | ||||
| import { QueryType } from '../types/query'; | ||||
| 
 | ||||
| import { QueryHeader } from './QueryHeader'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import React from 'react'; | |||
| import { EditorHeader, FlexItem, InlineSelect } from '@grafana/experimental'; | ||||
| 
 | ||||
| import { QUERY_TYPES } from '../constants'; | ||||
| import { CloudMonitoringQuery } from '../types'; | ||||
| import { CloudMonitoringQuery } from '../types/query'; | ||||
| 
 | ||||
| export interface QueryEditorHeaderProps { | ||||
|   query: CloudMonitoringQuery; | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import { EditorField } from '@grafana/experimental'; | |||
| import { Select } from '@grafana/ui'; | ||||
| 
 | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { SLOQuery } from '../types'; | ||||
| import { SLOQuery } from '../types/query'; | ||||
| 
 | ||||
| export interface Props { | ||||
|   refId: string; | ||||
|  |  | |||
|  | @ -6,7 +6,8 @@ import { EditorField, EditorFieldGroup, EditorRow } from '@grafana/experimental' | |||
| import { ALIGNMENT_PERIODS, SLO_BURN_RATE_SELECTOR_NAME } from '../constants'; | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { alignmentPeriodLabel } from '../functions'; | ||||
| import { AlignmentTypes, CustomMetaData, SLOQuery } from '../types'; | ||||
| import { AlignmentTypes, SLOQuery } from '../types/query'; | ||||
| import { CustomMetaData } from '../types/types'; | ||||
| 
 | ||||
| import { AliasBy } from './AliasBy'; | ||||
| import { LookbackPeriodSelect } from './LookbackPeriodSelect'; | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import { Select } from '@grafana/ui'; | |||
| 
 | ||||
| import { SELECTORS } from '../constants'; | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { SLOQuery } from '../types'; | ||||
| import { SLOQuery } from '../types/query'; | ||||
| 
 | ||||
| export interface Props { | ||||
|   refId: string; | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import { EditorField } from '@grafana/experimental'; | |||
| import { Select } from '@grafana/ui'; | ||||
| 
 | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { SLOQuery } from '../types'; | ||||
| import { SLOQuery } from '../types/query'; | ||||
| 
 | ||||
| export interface Props { | ||||
|   refId: string; | ||||
|  |  | |||
|  | @ -5,7 +5,8 @@ import renderer from 'react-test-renderer'; | |||
| import { VariableModel } from '@grafana/data'; | ||||
| 
 | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { CloudMonitoringVariableQuery, MetricFindQueryTypes } from '../types'; | ||||
| import { MetricFindQueryTypes } from '../types/query'; | ||||
| import { CloudMonitoringVariableQuery } from '../types/types'; | ||||
| 
 | ||||
| import { CloudMonitoringVariableQueryEditor, Props } from './VariableQueryEditor'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,14 +5,13 @@ import { getTemplateSrv } from '@grafana/runtime'; | |||
| 
 | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { extractServicesFromMetricDescriptors, getLabelKeys, getMetricTypes } from '../functions'; | ||||
| import { CloudMonitoringQuery, MetricFindQueryTypes } from '../types/query'; | ||||
| import { | ||||
|   CloudMonitoringOptions, | ||||
|   CloudMonitoringQuery, | ||||
|   CloudMonitoringVariableQuery, | ||||
|   MetricDescriptor, | ||||
|   MetricFindQueryTypes, | ||||
|   VariableQueryData, | ||||
| } from '../types'; | ||||
| } from '../types/types'; | ||||
| 
 | ||||
| import { VariableQueryField } from './'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ import { TemplateSrv } from 'app/features/templating/template_srv'; | |||
| import { createMockDatasource } from '../__mocks__/cloudMonitoringDatasource'; | ||||
| import { createMockMetricDescriptor } from '../__mocks__/cloudMonitoringMetricDescriptor'; | ||||
| import { createMockTimeSeriesList } from '../__mocks__/cloudMonitoringQuery'; | ||||
| import { MetricKind, PreprocessorType } from '../types'; | ||||
| import { PreprocessorType, MetricKind } from '../types/query'; | ||||
| 
 | ||||
| import { defaultTimeSeriesList } from './MetricQueryEditor'; | ||||
| import { VisualMetricQueryEditor } from './VisualMetricQueryEditor'; | ||||
|  |  | |||
|  | @ -10,7 +10,8 @@ import { getSelectStyles, Select, AsyncSelect, useStyles2, useTheme2 } from '@gr | |||
| 
 | ||||
| import CloudMonitoringDatasource from '../datasource'; | ||||
| import { getAlignmentPickerData, getMetricType, setMetricType } from '../functions'; | ||||
| import { CustomMetaData, MetricDescriptor, MetricKind, PreprocessorType, TimeSeriesList, ValueTypes } from '../types'; | ||||
| import { PreprocessorType, TimeSeriesList, MetricKind, ValueTypes } from '../types/query'; | ||||
| import { CustomMetaData, MetricDescriptor } from '../types/types'; | ||||
| 
 | ||||
| import { AliasBy } from './AliasBy'; | ||||
| import { Alignment } from './Alignment'; | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { MetricKind, QueryType, ValueTypes } from './types'; | ||||
| import { QueryType, MetricKind, ValueTypes } from './types/query'; | ||||
| 
 | ||||
| // not super excited about using uneven numbers, but this makes it align perfectly with rows that has two fields
 | ||||
| export const INPUT_WIDTH = 71; | ||||
|  |  | |||
|  | @ -0,0 +1,197 @@ | |||
| // 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" | ||||
| ) | ||||
| 
 | ||||
| pfs.GrafanaPlugin | ||||
| 
 | ||||
| composableKinds: DataQuery: { | ||||
| 	maturity: "merged" | ||||
| 
 | ||||
| 	lineage: { | ||||
| 		seqs: [ | ||||
| 			{ | ||||
| 				schemas: [ | ||||
| 					{ | ||||
| 						#CloudMonitoringQuery: common.DataQuery & { | ||||
| 							// Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail. | ||||
| 							aliasBy?: string | ||||
| 							// GCM query type. | ||||
| 							// queryType: #QueryType | ||||
| 							// Time Series List sub-query properties. | ||||
| 							timeSeriesList?: #TimeSeriesList | #AnnotationQuery | ||||
| 							// Time Series sub-query properties. | ||||
| 							timeSeriesQuery?: #TimeSeriesQuery | ||||
| 							// SLO sub-query properties. | ||||
| 							sloQuery?: #SLOQuery | ||||
| 							// Time interval in milliseconds. | ||||
| 							intervalMs?: number | ||||
| 						} @cuetsy(kind="interface") | ||||
| 
 | ||||
| 						// Defines the supported queryTypes. | ||||
| 						#QueryType: "timeSeriesList" | "timeSeriesQuery" | "slo" | "annotation" @cuetsy(kind="enum", memberNames="TIME_SERIES_LIST|TIME_SERIES_QUERY|SLO|ANNOTATION") | ||||
| 
 | ||||
| 						// Time Series List sub-query properties. | ||||
| 						#TimeSeriesList: { | ||||
| 							// GCP project to execute the query against. | ||||
| 							projectName: string | ||||
| 							// Reducer applied across a set of time-series values. Defaults to REDUCE_NONE. | ||||
| 							crossSeriesReducer: string | ||||
| 							// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. | ||||
| 							alignmentPeriod?: string | ||||
| 							// Alignment function to be used. Defaults to ALIGN_MEAN. | ||||
| 							perSeriesAligner?: string | ||||
| 							// Array of labels to group data by. | ||||
| 							groupBys?: [...string] | ||||
| 							// Array of filters to query data by. Labels that can be filtered on are defined by the metric. | ||||
| 							filters?: [...string] | ||||
| 							// Data view, defaults to FULL. | ||||
| 							view?: string | ||||
| 
 | ||||
| 							// Only present if a preprocessor is selected. Reducer applied across a set of time-series values. Defaults to REDUCE_NONE. | ||||
| 							secondaryCrossSeriesReducer?: string | ||||
| 							// Only present if a preprocessor is selected. Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. | ||||
| 							secondaryAlignmentPeriod?: string | ||||
| 							// Only present if a preprocessor is selected. Alignment function to be used. Defaults to ALIGN_MEAN. | ||||
| 							secondaryPerSeriesAligner?: string | ||||
| 							// Only present if a preprocessor is selected. Array of labels to group data by. | ||||
| 							secondaryGroupBys?: [...string] | ||||
| 
 | ||||
| 							// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters | ||||
| 							preprocessor?: #PreprocessorType | ||||
| 							... | ||||
| 						} @cuetsy(kind="interface") | ||||
| 
 | ||||
| 						// Types of pre-processor available. Defined by the metric. | ||||
| 						#PreprocessorType: "none" | "rate" | "delta" @cuetsy(kind="enum") | ||||
| 
 | ||||
| 						// Annotation sub-query properties. | ||||
| 						#AnnotationQuery: #TimeSeriesList & { | ||||
| 							// Annotation title. | ||||
| 							title?: string | ||||
| 							// Annotation text. | ||||
| 							text?: string | ||||
| 						} @cuetsy(kind="interface") | ||||
| 
 | ||||
| 						// Time Series sub-query properties. | ||||
| 						#TimeSeriesQuery: { | ||||
| 							// GCP project to execute the query against. | ||||
| 							projectName: string | ||||
| 							// MQL query to be executed. | ||||
| 							query: string | ||||
| 							// To disable the graphPeriod, it should explictly be set to 'disabled'. | ||||
| 							graphPeriod?: "disabled" | string | ||||
| 						} @cuetsy(kind="interface") | ||||
| 
 | ||||
| 						// SLO sub-query properties. | ||||
| 						#SLOQuery: { | ||||
| 							// GCP project to execute the query against. | ||||
| 							projectName: string | ||||
| 							// Alignment function to be used. Defaults to ALIGN_MEAN. | ||||
| 							perSeriesAligner?: string | ||||
| 							// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. | ||||
| 							alignmentPeriod?: string | ||||
| 							// SLO selector. | ||||
| 							selectorName: string | ||||
| 							// ID for the service the SLO is in. | ||||
| 							serviceId: string | ||||
| 							// Name for the service the SLO is in. | ||||
| 							serviceName: string | ||||
| 							// ID for the SLO. | ||||
| 							sloId: string | ||||
| 							// Name of the SLO. | ||||
| 							sloName: string | ||||
| 							// SLO goal value. | ||||
| 							goal?: number | ||||
| 							// Specific lookback period for the SLO. | ||||
| 							lookbackPeriod?: string | ||||
| 						} @cuetsy(kind="interface") | ||||
| 
 | ||||
| 						// @deprecated This type is for migration purposes only. Replaced by TimeSeriesList Metric sub-query properties. | ||||
| 						#MetricQuery: { | ||||
| 							// GCP project to execute the query against. | ||||
| 							projectName: string | ||||
| 							// Alignment function to be used. Defaults to ALIGN_MEAN. | ||||
| 							perSeriesAligner?: string | ||||
| 							// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. | ||||
| 							alignmentPeriod?: string | ||||
| 							// Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail. | ||||
| 							aliasBy?:   string | ||||
| 							editorMode: string | ||||
| 							metricType: string | ||||
| 							// Reducer applied across a set of time-series values. Defaults to REDUCE_NONE. | ||||
| 							crossSeriesReducer: string | ||||
| 							// Array of labels to group data by. | ||||
| 							groupBys?: [...string] | ||||
| 							// Array of filters to query data by. Labels that can be filtered on are defined by the metric. | ||||
| 							filters?: [...string] | ||||
| 							metricKind?: #MetricKind | ||||
| 							valueType?:  string | ||||
| 							view?:       string | ||||
| 							// MQL query to be executed. | ||||
| 							query: string | ||||
| 							// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters | ||||
| 							preprocessor?: #PreprocessorType | ||||
| 							// To disable the graphPeriod, it should explictly be set to 'disabled'. | ||||
| 							graphPeriod?: "disabled" | string | ||||
| 						} @cuetsy(kind="interface") | ||||
| 
 | ||||
| 						#MetricKind: "METRIC_KIND_UNSPECIFIED" | "GAUGE" | "DELTA" | "CUMULATIVE" @cuetsy(kind="enum") | ||||
| 
 | ||||
| 						#ValueTypes: "VALUE_TYPE_UNSPECIFIED" | "BOOL" | "INT64" | "DOUBLE" | "STRING" | "DISTRIBUTION" | "MONEY" @cuetsy(kind="enum") | ||||
| 
 | ||||
| 						#AlignmentTypes: "ALIGN_DELTA" | "ALIGN_RATE" | "ALIGN_INTERPOLATE" | "ALIGN_NEXT_OLDER" | "ALIGN_MIN" | "ALIGN_MAX" | "ALIGN_MEAN" | "ALIGN_COUNT" | "ALIGN_SUM" | "ALIGN_STDDEV" | "ALIGN_COUNT_TRUE" | "ALIGN_COUNT_FALSE" | "ALIGN_FRACTION_TRUE" | "ALIGN_PERCENTILE_99" | "ALIGN_PERCENTILE_95" | "ALIGN_PERCENTILE_50" | "ALIGN_PERCENTILE_05" | "ALIGN_PERCENT_CHANGE" | "ALIGN_NONE" @cuetsy(kind="enum") | ||||
| 
 | ||||
| 						// @deprecated Use AnnotationQuery instead. Legacy annotation query properties for migration purposes. | ||||
| 						#LegacyCloudMonitoringAnnotationQuery: { | ||||
| 							// GCP project to execute the query against. | ||||
| 							projectName: string | ||||
| 							metricType:  string | ||||
| 							// Query refId. | ||||
| 							refId: string | ||||
| 							// Array of filters to query data by. Labels that can be filtered on are defined by the metric. | ||||
| 							filters: [...string] | ||||
| 							metricKind: #MetricKind | ||||
| 							valueType:  string | ||||
| 							// Annotation title. | ||||
| 							title: string | ||||
| 							// Annotation text. | ||||
| 							text: string | ||||
| 						} @cuetsy(kind="interface") | ||||
| 
 | ||||
| 						// Query filter representation. | ||||
| 						#Filter: { | ||||
| 							// Filter key. | ||||
| 							key: string | ||||
| 							// Filter operator. | ||||
| 							operator: string | ||||
| 							// Filter value. | ||||
| 							value: string | ||||
| 							// Filter condition. | ||||
| 							condition?: string | ||||
| 						} @cuetsy(kind="interface") | ||||
| 
 | ||||
| 						#MetricFindQueryTypes: "projects" | "services" | "defaultProject" | "metricTypes" | "labelKeys" | "labelValues" | "resourceTypes" | "aggregations" | "aligners" | "alignmentPeriods" | "selectors" | "sloServices" | "slo" @cuetsy(kind="enum", memberNames="Projects|Services|DefaultProject|MetricTypes|LabelKeys|LabelValues|ResourceTypes|Aggregations|Aligners|AlignmentPeriods|Selectors|SLOServices|SLO") | ||||
| 					}, | ||||
| 
 | ||||
| 				] | ||||
| 			}, | ||||
| 		] | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,363 @@ | |||
| // 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 interface CloudMonitoringQuery extends common.DataQuery { | ||||
|   /** | ||||
|    * Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail. | ||||
|    */ | ||||
|   aliasBy?: string; | ||||
|   /** | ||||
|    * Time interval in milliseconds. | ||||
|    */ | ||||
|   intervalMs?: number; | ||||
|   /** | ||||
|    * SLO sub-query properties. | ||||
|    */ | ||||
|   sloQuery?: SLOQuery; | ||||
|   /** | ||||
|    * GCM query type. | ||||
|    * queryType: #QueryType | ||||
|    * Time Series List sub-query properties. | ||||
|    */ | ||||
|   timeSeriesList?: (TimeSeriesList | AnnotationQuery); | ||||
|   /** | ||||
|    * Time Series sub-query properties. | ||||
|    */ | ||||
|   timeSeriesQuery?: TimeSeriesQuery; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Defines the supported queryTypes. | ||||
|  */ | ||||
| export enum QueryType { | ||||
|   ANNOTATION = 'annotation', | ||||
|   SLO = 'slo', | ||||
|   TIME_SERIES_LIST = 'timeSeriesList', | ||||
|   TIME_SERIES_QUERY = 'timeSeriesQuery', | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Time Series List sub-query properties. | ||||
|  */ | ||||
| export interface TimeSeriesList { | ||||
|   /** | ||||
|    * Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. | ||||
|    */ | ||||
|   alignmentPeriod?: string; | ||||
|   /** | ||||
|    * Reducer applied across a set of time-series values. Defaults to REDUCE_NONE. | ||||
|    */ | ||||
|   crossSeriesReducer: string; | ||||
|   /** | ||||
|    * Array of filters to query data by. Labels that can be filtered on are defined by the metric. | ||||
|    */ | ||||
|   filters?: Array<string>; | ||||
|   /** | ||||
|    * Array of labels to group data by. | ||||
|    */ | ||||
|   groupBys?: Array<string>; | ||||
|   /** | ||||
|    * Alignment function to be used. Defaults to ALIGN_MEAN. | ||||
|    */ | ||||
|   perSeriesAligner?: string; | ||||
|   /** | ||||
|    * Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters | ||||
|    */ | ||||
|   preprocessor?: PreprocessorType; | ||||
|   /** | ||||
|    * GCP project to execute the query against. | ||||
|    */ | ||||
|   projectName: string; | ||||
|   /** | ||||
|    * Only present if a preprocessor is selected. Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. | ||||
|    */ | ||||
|   secondaryAlignmentPeriod?: string; | ||||
|   /** | ||||
|    * Only present if a preprocessor is selected. Reducer applied across a set of time-series values. Defaults to REDUCE_NONE. | ||||
|    */ | ||||
|   secondaryCrossSeriesReducer?: string; | ||||
|   /** | ||||
|    * Only present if a preprocessor is selected. Array of labels to group data by. | ||||
|    */ | ||||
|   secondaryGroupBys?: Array<string>; | ||||
|   /** | ||||
|    * Only present if a preprocessor is selected. Alignment function to be used. Defaults to ALIGN_MEAN. | ||||
|    */ | ||||
|   secondaryPerSeriesAligner?: string; | ||||
|   /** | ||||
|    * Data view, defaults to FULL. | ||||
|    */ | ||||
|   view?: string; | ||||
| } | ||||
| 
 | ||||
| export const defaultTimeSeriesList: Partial<TimeSeriesList> = { | ||||
|   filters: [], | ||||
|   groupBys: [], | ||||
|   secondaryGroupBys: [], | ||||
| }; | ||||
| 
 | ||||
| /** | ||||
|  * Types of pre-processor available. Defined by the metric. | ||||
|  */ | ||||
| export enum PreprocessorType { | ||||
|   Delta = 'delta', | ||||
|   None = 'none', | ||||
|   Rate = 'rate', | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Annotation sub-query properties. | ||||
|  */ | ||||
| export interface AnnotationQuery extends TimeSeriesList { | ||||
|   /** | ||||
|    * Annotation text. | ||||
|    */ | ||||
|   text?: string; | ||||
|   /** | ||||
|    * Annotation title. | ||||
|    */ | ||||
|   title?: string; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Time Series sub-query properties. | ||||
|  */ | ||||
| export interface TimeSeriesQuery { | ||||
|   /** | ||||
|    * To disable the graphPeriod, it should explictly be set to 'disabled'. | ||||
|    */ | ||||
|   graphPeriod?: ('disabled' | string); | ||||
|   /** | ||||
|    * GCP project to execute the query against. | ||||
|    */ | ||||
|   projectName: string; | ||||
|   /** | ||||
|    * MQL query to be executed. | ||||
|    */ | ||||
|   query: string; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * SLO sub-query properties. | ||||
|  */ | ||||
| export interface SLOQuery { | ||||
|   /** | ||||
|    * Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. | ||||
|    */ | ||||
|   alignmentPeriod?: string; | ||||
|   /** | ||||
|    * SLO goal value. | ||||
|    */ | ||||
|   goal?: number; | ||||
|   /** | ||||
|    * Specific lookback period for the SLO. | ||||
|    */ | ||||
|   lookbackPeriod?: string; | ||||
|   /** | ||||
|    * Alignment function to be used. Defaults to ALIGN_MEAN. | ||||
|    */ | ||||
|   perSeriesAligner?: string; | ||||
|   /** | ||||
|    * GCP project to execute the query against. | ||||
|    */ | ||||
|   projectName: string; | ||||
|   /** | ||||
|    * SLO selector. | ||||
|    */ | ||||
|   selectorName: string; | ||||
|   /** | ||||
|    * ID for the service the SLO is in. | ||||
|    */ | ||||
|   serviceId: string; | ||||
|   /** | ||||
|    * Name for the service the SLO is in. | ||||
|    */ | ||||
|   serviceName: string; | ||||
|   /** | ||||
|    * ID for the SLO. | ||||
|    */ | ||||
|   sloId: string; | ||||
|   /** | ||||
|    * Name of the SLO. | ||||
|    */ | ||||
|   sloName: string; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * @deprecated This type is for migration purposes only. Replaced by TimeSeriesList Metric sub-query properties. | ||||
|  */ | ||||
| export interface MetricQuery { | ||||
|   /** | ||||
|    * Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail. | ||||
|    */ | ||||
|   aliasBy?: string; | ||||
|   /** | ||||
|    * Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. | ||||
|    */ | ||||
|   alignmentPeriod?: string; | ||||
|   /** | ||||
|    * Reducer applied across a set of time-series values. Defaults to REDUCE_NONE. | ||||
|    */ | ||||
|   crossSeriesReducer: string; | ||||
|   editorMode: string; | ||||
|   /** | ||||
|    * Array of filters to query data by. Labels that can be filtered on are defined by the metric. | ||||
|    */ | ||||
|   filters?: Array<string>; | ||||
|   /** | ||||
|    * To disable the graphPeriod, it should explictly be set to 'disabled'. | ||||
|    */ | ||||
|   graphPeriod?: ('disabled' | string); | ||||
|   /** | ||||
|    * Array of labels to group data by. | ||||
|    */ | ||||
|   groupBys?: Array<string>; | ||||
|   metricKind?: MetricKind; | ||||
|   metricType: string; | ||||
|   /** | ||||
|    * Alignment function to be used. Defaults to ALIGN_MEAN. | ||||
|    */ | ||||
|   perSeriesAligner?: string; | ||||
|   /** | ||||
|    * Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters | ||||
|    */ | ||||
|   preprocessor?: PreprocessorType; | ||||
|   /** | ||||
|    * GCP project to execute the query against. | ||||
|    */ | ||||
|   projectName: string; | ||||
|   /** | ||||
|    * MQL query to be executed. | ||||
|    */ | ||||
|   query: string; | ||||
|   valueType?: string; | ||||
|   view?: string; | ||||
| } | ||||
| 
 | ||||
| export const defaultMetricQuery: Partial<MetricQuery> = { | ||||
|   filters: [], | ||||
|   groupBys: [], | ||||
| }; | ||||
| 
 | ||||
| export enum MetricKind { | ||||
|   CUMULATIVE = 'CUMULATIVE', | ||||
|   DELTA = 'DELTA', | ||||
|   GAUGE = 'GAUGE', | ||||
|   METRIC_KIND_UNSPECIFIED = 'METRIC_KIND_UNSPECIFIED', | ||||
| } | ||||
| 
 | ||||
| export enum ValueTypes { | ||||
|   BOOL = 'BOOL', | ||||
|   DISTRIBUTION = 'DISTRIBUTION', | ||||
|   DOUBLE = 'DOUBLE', | ||||
|   INT64 = 'INT64', | ||||
|   MONEY = 'MONEY', | ||||
|   STRING = 'STRING', | ||||
|   VALUE_TYPE_UNSPECIFIED = 'VALUE_TYPE_UNSPECIFIED', | ||||
| } | ||||
| 
 | ||||
| export enum AlignmentTypes { | ||||
|   ALIGN_COUNT = 'ALIGN_COUNT', | ||||
|   ALIGN_COUNT_FALSE = 'ALIGN_COUNT_FALSE', | ||||
|   ALIGN_COUNT_TRUE = 'ALIGN_COUNT_TRUE', | ||||
|   ALIGN_DELTA = 'ALIGN_DELTA', | ||||
|   ALIGN_FRACTION_TRUE = 'ALIGN_FRACTION_TRUE', | ||||
|   ALIGN_INTERPOLATE = 'ALIGN_INTERPOLATE', | ||||
|   ALIGN_MAX = 'ALIGN_MAX', | ||||
|   ALIGN_MEAN = 'ALIGN_MEAN', | ||||
|   ALIGN_MIN = 'ALIGN_MIN', | ||||
|   ALIGN_NEXT_OLDER = 'ALIGN_NEXT_OLDER', | ||||
|   ALIGN_NONE = 'ALIGN_NONE', | ||||
|   ALIGN_PERCENTILE_05 = 'ALIGN_PERCENTILE_05', | ||||
|   ALIGN_PERCENTILE_50 = 'ALIGN_PERCENTILE_50', | ||||
|   ALIGN_PERCENTILE_95 = 'ALIGN_PERCENTILE_95', | ||||
|   ALIGN_PERCENTILE_99 = 'ALIGN_PERCENTILE_99', | ||||
|   ALIGN_PERCENT_CHANGE = 'ALIGN_PERCENT_CHANGE', | ||||
|   ALIGN_RATE = 'ALIGN_RATE', | ||||
|   ALIGN_STDDEV = 'ALIGN_STDDEV', | ||||
|   ALIGN_SUM = 'ALIGN_SUM', | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * @deprecated Use AnnotationQuery instead. Legacy annotation query properties for migration purposes. | ||||
|  */ | ||||
| export interface LegacyCloudMonitoringAnnotationQuery { | ||||
|   /** | ||||
|    * Array of filters to query data by. Labels that can be filtered on are defined by the metric. | ||||
|    */ | ||||
|   filters: Array<string>; | ||||
|   metricKind: MetricKind; | ||||
|   metricType: string; | ||||
|   /** | ||||
|    * GCP project to execute the query against. | ||||
|    */ | ||||
|   projectName: string; | ||||
|   /** | ||||
|    * Query refId. | ||||
|    */ | ||||
|   refId: string; | ||||
|   /** | ||||
|    * Annotation text. | ||||
|    */ | ||||
|   text: string; | ||||
|   /** | ||||
|    * Annotation title. | ||||
|    */ | ||||
|   title: string; | ||||
|   valueType: string; | ||||
| } | ||||
| 
 | ||||
| export const defaultLegacyCloudMonitoringAnnotationQuery: Partial<LegacyCloudMonitoringAnnotationQuery> = { | ||||
|   filters: [], | ||||
| }; | ||||
| 
 | ||||
| /** | ||||
|  * Query filter representation. | ||||
|  */ | ||||
| export interface Filter { | ||||
|   /** | ||||
|    * Filter condition. | ||||
|    */ | ||||
|   condition?: string; | ||||
|   /** | ||||
|    * Filter key. | ||||
|    */ | ||||
|   key: string; | ||||
|   /** | ||||
|    * Filter operator. | ||||
|    */ | ||||
|   operator: string; | ||||
|   /** | ||||
|    * Filter value. | ||||
|    */ | ||||
|   value: string; | ||||
| } | ||||
| 
 | ||||
| export enum MetricFindQueryTypes { | ||||
|   Aggregations = 'aggregations', | ||||
|   Aligners = 'aligners', | ||||
|   AlignmentPeriods = 'alignmentPeriods', | ||||
|   DefaultProject = 'defaultProject', | ||||
|   LabelKeys = 'labelKeys', | ||||
|   LabelValues = 'labelValues', | ||||
|   MetricTypes = 'metricTypes', | ||||
|   Projects = 'projects', | ||||
|   ResourceTypes = 'resourceTypes', | ||||
|   SLO = 'slo', | ||||
|   SLOServices = 'sloServices', | ||||
|   Selectors = 'selectors', | ||||
|   Services = 'services', | ||||
| } | ||||
| 
 | ||||
| export interface GoogleCloudMonitoring {} | ||||
|  | @ -6,7 +6,7 @@ import { TemplateSrv } from 'app/features/templating/template_srv'; | |||
| import { createMockInstanceSetttings } from './__mocks__/cloudMonitoringInstanceSettings'; | ||||
| import { createMockQuery } from './__mocks__/cloudMonitoringQuery'; | ||||
| import Datasource from './datasource'; | ||||
| import { CloudMonitoringQuery, MetricKind, PreprocessorType, QueryType } from './types'; | ||||
| import { CloudMonitoringQuery, PreprocessorType, QueryType, MetricKind } from './types/query'; | ||||
| 
 | ||||
| describe('Cloud Monitoring Datasource', () => { | ||||
|   describe('interpolateVariablesInQueries', () => { | ||||
|  |  | |||
|  | @ -17,16 +17,8 @@ import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_sr | |||
| import { CloudMonitoringAnnotationSupport } from './annotationSupport'; | ||||
| import { SLO_BURN_RATE_SELECTOR_NAME } from './constants'; | ||||
| import { getMetricType, setMetricType } from './functions'; | ||||
| import { | ||||
|   CloudMonitoringOptions, | ||||
|   CloudMonitoringQuery, | ||||
|   Filter, | ||||
|   MetricDescriptor, | ||||
|   QueryType, | ||||
|   PostResponse, | ||||
|   Aggregation, | ||||
|   MetricQuery, | ||||
| } from './types'; | ||||
| import { CloudMonitoringQuery, QueryType, MetricQuery, Filter } from './types/query'; | ||||
| import { CloudMonitoringOptions, MetricDescriptor, PostResponse, Aggregation } from './types/types'; | ||||
| import { CloudMonitoringVariableSupport } from './variables'; | ||||
| 
 | ||||
| export default class CloudMonitoringDatasource extends DataSourceWithBackend< | ||||
|  | @ -255,7 +247,7 @@ export default class CloudMonitoringDatasource extends DataSourceWithBackend< | |||
|       }; | ||||
|     } | ||||
| 
 | ||||
|     if (has(query, 'metricQuery') && ['metrics', QueryType.ANNOTATION].includes(query.queryType)) { | ||||
|     if (has(query, 'metricQuery') && ['metrics', QueryType.ANNOTATION].includes(query.queryType ?? '')) { | ||||
|       const metricQuery: MetricQuery = get(query, 'metricQuery')!; | ||||
|       if (metricQuery.editorMode === 'mql') { | ||||
|         query.timeSeriesQuery = { | ||||
|  | @ -327,7 +319,7 @@ export default class CloudMonitoringDatasource extends DataSourceWithBackend< | |||
|       return !!query.timeSeriesQuery && !!query.timeSeriesQuery.projectName && !!query.timeSeriesQuery.query; | ||||
|     } | ||||
| 
 | ||||
|     if ([QueryType.TIME_SERIES_LIST, QueryType.ANNOTATION].includes(query.queryType)) { | ||||
|     if (query.queryType && [QueryType.TIME_SERIES_LIST, QueryType.ANNOTATION].includes(query.queryType)) { | ||||
|       return !!query.timeSeriesList && !!query.timeSeriesList.projectName && !!getMetricType(query.timeSeriesList); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -14,7 +14,8 @@ import { | |||
|   setMetricType, | ||||
| } from './functions'; | ||||
| import { newMockDatasource } from './specs/testData'; | ||||
| import { AlignmentTypes, MetricDescriptor, MetricKind, TimeSeriesList, ValueTypes } from './types'; | ||||
| import { AlignmentTypes, TimeSeriesList, MetricKind, ValueTypes } from './types/query'; | ||||
| import { MetricDescriptor } from './types/types'; | ||||
| 
 | ||||
| jest.mock('@grafana/runtime', () => ({ | ||||
|   ...jest.requireActual('@grafana/runtime'), | ||||
|  |  | |||
|  | @ -5,15 +5,8 @@ import { getTemplateSrv, TemplateSrv } from '@grafana/runtime'; | |||
| 
 | ||||
| import { AGGREGATIONS, ALIGNMENTS, SYSTEM_LABELS } from './constants'; | ||||
| import CloudMonitoringDatasource from './datasource'; | ||||
| import { | ||||
|   AlignmentTypes, | ||||
|   CustomMetaData, | ||||
|   MetricDescriptor, | ||||
|   MetricKind, | ||||
|   PreprocessorType, | ||||
|   TimeSeriesList, | ||||
|   ValueTypes, | ||||
| } from './types'; | ||||
| import { AlignmentTypes, PreprocessorType, TimeSeriesList, MetricKind, ValueTypes } from './types/query'; | ||||
| import { CustomMetaData, MetricDescriptor } from './types/types'; | ||||
| 
 | ||||
| export const extractServicesFromMetricDescriptors = (metricDescriptors: MetricDescriptor[]) => | ||||
|   uniqBy(metricDescriptors, 'service'); | ||||
|  |  | |||
|  | @ -10,7 +10,7 @@ import { CloudMonitoringVariableQueryEditor } from './components/VariableQueryEd | |||
| import CloudMonitoringDatasource from './datasource'; | ||||
| import pluginJson from './plugin.json'; | ||||
| import { trackCloudMonitoringDashboardLoaded } from './tracking'; | ||||
| import { CloudMonitoringQuery, QueryType } from './types'; | ||||
| import { CloudMonitoringQuery, QueryType } from './types/query'; | ||||
| 
 | ||||
| export const plugin = new DataSourcePlugin<CloudMonitoringDatasource, CloudMonitoringQuery>(CloudMonitoringDatasource) | ||||
|   .setQueryEditorHelp(CloudMonitoringCheatSheet) | ||||
|  |  | |||
|  | @ -9,7 +9,8 @@ import { TemplateSrv } from 'app/features/templating/template_srv'; | |||
| import { initialCustomVariableModelState } from '../../../../features/variables/custom/reducer'; | ||||
| import { CustomVariableModel } from '../../../../features/variables/types'; | ||||
| import CloudMonitoringDataSource from '../datasource'; | ||||
| import { CloudMonitoringOptions, CloudMonitoringQuery } from '../types'; | ||||
| import { CloudMonitoringQuery } from '../types/query'; | ||||
| import { CloudMonitoringOptions } from '../types/types'; | ||||
| 
 | ||||
| jest.mock('@grafana/runtime', () => ({ | ||||
|   ...jest.requireActual('@grafana/runtime'), | ||||
|  |  | |||
|  | @ -1,233 +0,0 @@ | |||
| import { DataQuery, SelectableValue } from '@grafana/data'; | ||||
| import { DataSourceOptions, DataSourceSecureJsonData } from '@grafana/google-sdk'; | ||||
| 
 | ||||
| export enum MetricFindQueryTypes { | ||||
|   Projects = 'projects', | ||||
|   Services = 'services', | ||||
|   DefaultProject = 'defaultProject', | ||||
|   MetricTypes = 'metricTypes', | ||||
|   LabelKeys = 'labelKeys', | ||||
|   LabelValues = 'labelValues', | ||||
|   ResourceTypes = 'resourceTypes', | ||||
|   Aggregations = 'aggregations', | ||||
|   Aligners = 'aligners', | ||||
|   AlignmentPeriods = 'alignmentPeriods', | ||||
|   Selectors = 'selectors', | ||||
|   SLOServices = 'sloServices', | ||||
|   SLO = 'slo', | ||||
| } | ||||
| 
 | ||||
| export interface CloudMonitoringVariableQuery extends DataQuery { | ||||
|   selectedQueryType: string; | ||||
|   selectedService: string; | ||||
|   selectedMetricType: string; | ||||
|   selectedSLOService: string; | ||||
|   labelKey: string; | ||||
|   projects: SelectableValue[]; | ||||
|   sloServices: SelectableValue[]; | ||||
|   projectName: string; | ||||
| } | ||||
| 
 | ||||
| export interface VariableQueryData { | ||||
|   selectedQueryType: string; | ||||
|   metricDescriptors: MetricDescriptor[]; | ||||
|   selectedService: string; | ||||
|   selectedMetricType: string; | ||||
|   selectedSLOService: string; | ||||
|   labels: string[]; | ||||
|   labelKey: string; | ||||
|   metricTypes: Array<{ value: string; name: string }>; | ||||
|   services: SelectableValue[]; | ||||
|   projects: SelectableValue[]; | ||||
|   sloServices: SelectableValue[]; | ||||
|   projectName: string; | ||||
|   loading: boolean; | ||||
| } | ||||
| 
 | ||||
| export interface Aggregation { | ||||
|   crossSeriesReducer?: string; | ||||
|   groupBys?: string[]; | ||||
| } | ||||
| 
 | ||||
| export enum QueryType { | ||||
|   TIME_SERIES_LIST = 'timeSeriesList', | ||||
|   TIME_SERIES_QUERY = 'timeSeriesQuery', | ||||
|   SLO = 'slo', | ||||
|   ANNOTATION = 'annotation', | ||||
| } | ||||
| 
 | ||||
| export enum PreprocessorType { | ||||
|   None = 'none', | ||||
|   Rate = 'rate', | ||||
|   Delta = 'delta', | ||||
| } | ||||
| 
 | ||||
| export enum MetricKind { | ||||
|   METRIC_KIND_UNSPECIFIED = 'METRIC_KIND_UNSPECIFIED', | ||||
|   GAUGE = 'GAUGE', | ||||
|   DELTA = 'DELTA', | ||||
|   CUMULATIVE = 'CUMULATIVE', | ||||
| } | ||||
| 
 | ||||
| export enum ValueTypes { | ||||
|   VALUE_TYPE_UNSPECIFIED = 'VALUE_TYPE_UNSPECIFIED', | ||||
|   BOOL = 'BOOL', | ||||
|   INT64 = 'INT64', | ||||
|   DOUBLE = 'DOUBLE', | ||||
|   STRING = 'STRING', | ||||
|   DISTRIBUTION = 'DISTRIBUTION', | ||||
|   MONEY = 'MONEY', | ||||
| } | ||||
| 
 | ||||
| export enum AlignmentTypes { | ||||
|   ALIGN_DELTA = 'ALIGN_DELTA', | ||||
|   ALIGN_RATE = 'ALIGN_RATE', | ||||
|   ALIGN_INTERPOLATE = 'ALIGN_INTERPOLATE', | ||||
|   ALIGN_NEXT_OLDER = 'ALIGN_NEXT_OLDER', | ||||
|   ALIGN_MIN = 'ALIGN_MIN', | ||||
|   ALIGN_MAX = 'ALIGN_MAX', | ||||
|   ALIGN_MEAN = 'ALIGN_MEAN', | ||||
|   ALIGN_COUNT = 'ALIGN_COUNT', | ||||
|   ALIGN_SUM = 'ALIGN_SUM', | ||||
|   ALIGN_STDDEV = 'ALIGN_STDDEV', | ||||
|   ALIGN_COUNT_TRUE = 'ALIGN_COUNT_TRUE', | ||||
|   ALIGN_COUNT_FALSE = 'ALIGN_COUNT_FALSE', | ||||
|   ALIGN_FRACTION_TRUE = 'ALIGN_FRACTION_TRUE', | ||||
|   ALIGN_PERCENTILE_99 = 'ALIGN_PERCENTILE_99', | ||||
|   ALIGN_PERCENTILE_95 = 'ALIGN_PERCENTILE_95', | ||||
|   ALIGN_PERCENTILE_50 = 'ALIGN_PERCENTILE_50', | ||||
|   ALIGN_PERCENTILE_05 = 'ALIGN_PERCENTILE_05', | ||||
|   ALIGN_PERCENT_CHANGE = 'ALIGN_PERCENT_CHANGE', | ||||
|   ALIGN_NONE = 'ALIGN_NONE', | ||||
| } | ||||
| 
 | ||||
| // deprecated: use TimeSeriesList instead
 | ||||
| // left here for migration purposes
 | ||||
| export interface MetricQuery { | ||||
|   projectName: string; | ||||
|   perSeriesAligner?: string; | ||||
|   alignmentPeriod?: string; | ||||
|   aliasBy?: string; | ||||
|   editorMode: string; | ||||
|   metricType: string; | ||||
|   crossSeriesReducer: string; | ||||
|   groupBys?: string[]; | ||||
|   filters?: string[]; | ||||
|   metricKind?: MetricKind; | ||||
|   valueType?: string; | ||||
|   view?: string; | ||||
|   query: string; | ||||
|   preprocessor?: PreprocessorType; | ||||
|   // To disable the graphPeriod, it should explictly be set to 'disabled'
 | ||||
|   graphPeriod?: 'disabled' | string; | ||||
| } | ||||
| 
 | ||||
| export interface TimeSeriesList { | ||||
|   projectName: string; | ||||
|   crossSeriesReducer: string; | ||||
|   alignmentPeriod?: string; | ||||
|   perSeriesAligner?: string; | ||||
|   groupBys?: string[]; | ||||
|   filters?: string[]; | ||||
|   view?: string; | ||||
|   secondaryCrossSeriesReducer?: string; | ||||
|   secondaryAlignmentPeriod?: string; | ||||
|   secondaryPerSeriesAligner?: string; | ||||
|   secondaryGroupBys?: string[]; | ||||
|   // preprocessor is not part of the API, but is used to store the preprocessor
 | ||||
|   // and not affect the UI for the rest of parameters
 | ||||
|   preprocessor?: PreprocessorType; | ||||
| } | ||||
| 
 | ||||
| export interface TimeSeriesQuery { | ||||
|   projectName: string; | ||||
|   query: string; | ||||
|   // To disable the graphPeriod, it should explictly be set to 'disabled'
 | ||||
|   graphPeriod?: 'disabled' | string; | ||||
| } | ||||
| 
 | ||||
| export interface AnnotationQuery extends TimeSeriesList { | ||||
|   title?: string; | ||||
|   text?: string; | ||||
| } | ||||
| 
 | ||||
| export interface SLOQuery { | ||||
|   projectName: string; | ||||
|   perSeriesAligner?: string; | ||||
|   alignmentPeriod?: string; | ||||
|   selectorName: string; | ||||
|   serviceId: string; | ||||
|   serviceName: string; | ||||
|   sloId: string; | ||||
|   sloName: string; | ||||
|   goal?: number; | ||||
|   lookbackPeriod?: string; | ||||
| } | ||||
| 
 | ||||
| export interface CloudMonitoringQuery extends DataQuery { | ||||
|   aliasBy?: string; | ||||
|   datasourceId?: number; // Should not be necessary anymore
 | ||||
|   queryType: QueryType; | ||||
|   timeSeriesList?: TimeSeriesList | AnnotationQuery; | ||||
|   timeSeriesQuery?: TimeSeriesQuery; | ||||
|   sloQuery?: SLOQuery; | ||||
|   intervalMs: number; | ||||
| } | ||||
| 
 | ||||
| export interface CloudMonitoringOptions extends DataSourceOptions { | ||||
|   gceDefaultProject?: string; | ||||
| } | ||||
| 
 | ||||
| export interface CloudMonitoringSecureJsonData extends DataSourceSecureJsonData {} | ||||
| 
 | ||||
| export interface LegacyCloudMonitoringAnnotationQuery { | ||||
|   projectName: string; | ||||
|   metricType: string; | ||||
|   refId: string; | ||||
|   filters: string[]; | ||||
|   metricKind: MetricKind; | ||||
|   valueType: string; | ||||
|   title: string; | ||||
|   text: string; | ||||
| } | ||||
| 
 | ||||
| export interface QueryMeta { | ||||
|   alignmentPeriod: string; | ||||
|   rawQuery: string; | ||||
|   rawQueryString: string; | ||||
|   metricLabels: { [key: string]: string[] }; | ||||
|   resourceLabels: { [key: string]: string[] }; | ||||
|   resourceTypes: string[]; | ||||
| } | ||||
| 
 | ||||
| export interface MetricDescriptor { | ||||
|   valueType: string; | ||||
|   metricKind: MetricKind; | ||||
|   type: string; | ||||
|   unit: string; | ||||
|   service: string; | ||||
|   serviceShortName: string; | ||||
|   displayName: string; | ||||
|   description: string; | ||||
| } | ||||
| 
 | ||||
| export interface Segment { | ||||
|   type: string; | ||||
|   value: string; | ||||
| } | ||||
| 
 | ||||
| export interface Filter { | ||||
|   key: string; | ||||
|   operator: string; | ||||
|   value: string; | ||||
|   condition?: string; | ||||
| } | ||||
| 
 | ||||
| export interface CustomMetaData { | ||||
|   perSeriesAligner?: string; | ||||
|   alignmentPeriod?: string; | ||||
| } | ||||
| 
 | ||||
| export interface PostResponse { | ||||
|   results: Record<string, any>; | ||||
| } | ||||
|  | @ -0,0 +1,26 @@ | |||
| import { CloudMonitoringQuery as CloudMonitoringQueryBase, QueryType } from '../dataquery.gen'; | ||||
| 
 | ||||
| export { QueryType }; | ||||
| export { | ||||
|   TimeSeriesList, | ||||
|   PreprocessorType, | ||||
|   AnnotationQuery, | ||||
|   TimeSeriesQuery, | ||||
|   SLOQuery, | ||||
|   MetricQuery, | ||||
|   MetricKind, | ||||
|   LegacyCloudMonitoringAnnotationQuery, | ||||
|   Filter, | ||||
|   AlignmentTypes, | ||||
|   ValueTypes, | ||||
|   MetricFindQueryTypes, | ||||
| } from '../dataquery.gen'; | ||||
| 
 | ||||
| /** | ||||
|  * Represents the query as it moves through the frontend query editor and datasource files. | ||||
|  * It can represent new queries that are still being edited, so all properties are optional | ||||
|  */ | ||||
| // TODO: This is a workaround until the type extensions issue is resolved in CUE
 | ||||
| export interface CloudMonitoringQuery extends CloudMonitoringQueryBase { | ||||
|   queryType?: QueryType; | ||||
| } | ||||
|  | @ -0,0 +1,62 @@ | |||
| import { DataQuery, SelectableValue } from '@grafana/data'; | ||||
| import { DataSourceOptions, DataSourceSecureJsonData } from '@grafana/google-sdk'; | ||||
| 
 | ||||
| import { MetricKind } from './query'; | ||||
| 
 | ||||
| export interface CloudMonitoringVariableQuery extends DataQuery { | ||||
|   selectedQueryType: string; | ||||
|   selectedService: string; | ||||
|   selectedMetricType: string; | ||||
|   selectedSLOService: string; | ||||
|   labelKey: string; | ||||
|   projects: SelectableValue[]; | ||||
|   sloServices: SelectableValue[]; | ||||
|   projectName: string; | ||||
| } | ||||
| 
 | ||||
| export interface VariableQueryData { | ||||
|   selectedQueryType: string; | ||||
|   metricDescriptors: MetricDescriptor[]; | ||||
|   selectedService: string; | ||||
|   selectedMetricType: string; | ||||
|   selectedSLOService: string; | ||||
|   labels: string[]; | ||||
|   labelKey: string; | ||||
|   metricTypes: Array<{ value: string; name: string }>; | ||||
|   services: SelectableValue[]; | ||||
|   projects: SelectableValue[]; | ||||
|   sloServices: SelectableValue[]; | ||||
|   projectName: string; | ||||
|   loading: boolean; | ||||
| } | ||||
| 
 | ||||
| export interface Aggregation { | ||||
|   crossSeriesReducer?: string; | ||||
|   groupBys?: string[]; | ||||
| } | ||||
| 
 | ||||
| export interface CloudMonitoringOptions extends DataSourceOptions { | ||||
|   gceDefaultProject?: string; | ||||
| } | ||||
| 
 | ||||
| export interface CloudMonitoringSecureJsonData extends DataSourceSecureJsonData {} | ||||
| 
 | ||||
| export interface MetricDescriptor { | ||||
|   valueType: string; | ||||
|   metricKind: MetricKind; | ||||
|   type: string; | ||||
|   unit: string; | ||||
|   service: string; | ||||
|   serviceShortName: string; | ||||
|   displayName: string; | ||||
|   description: string; | ||||
| } | ||||
| 
 | ||||
| export interface CustomMetaData { | ||||
|   perSeriesAligner?: string; | ||||
|   alignmentPeriod?: string; | ||||
| } | ||||
| 
 | ||||
| export interface PostResponse { | ||||
|   results: Record<string, any>; | ||||
| } | ||||
|  | @ -6,7 +6,7 @@ import { CustomVariableSupport, DataQueryRequest, DataQueryResponse } from '@gra | |||
| import CloudMonitoringMetricFindQuery from './CloudMonitoringMetricFindQuery'; | ||||
| import { CloudMonitoringVariableQueryEditor } from './components/VariableQueryEditor'; | ||||
| import CloudMonitoringDatasource from './datasource'; | ||||
| import { CloudMonitoringVariableQuery } from './types'; | ||||
| import { CloudMonitoringVariableQuery } from './types/types'; | ||||
| 
 | ||||
| export class CloudMonitoringVariableSupport extends CustomVariableSupport< | ||||
|   CloudMonitoringDatasource, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue