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:
Andreas Christou
2023-05-22 17:19:54 +01:00
committed by GitHub
parent 2f74d0c6a9
commit 108acee08e
80 changed files with 1264 additions and 325 deletions
@@ -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"
+1 -1
View File
@@ -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