Chore: Unify references for dataquery (#68963)

* Unify references for dataquery

* Fix ResultFormat in azure types

* Update azure-log with new schema

* Fix cloudwatch query

* Update thema

* Fix test

* More fixes

* More fixes

* Fix lint
This commit is contained in:
Selene 2023-05-26 10:16:01 +02:00 committed by GitHub
parent 37c960e104
commit bd622a5381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 707 additions and 2331 deletions

2
go.mod
View File

@ -265,7 +265,7 @@ require (
github.com/grafana/dataplane/sdata v0.0.6
github.com/grafana/go-mssqldb v0.9.1
github.com/grafana/kindsys v0.0.0-20230508162304-452481b63482
github.com/grafana/thema v0.0.0-20230523123227-db9596a7096e
github.com/grafana/thema v0.0.0-20230524160113-4e9d6e28a640
github.com/ory/fosite v0.44.1-0.20230317114349-45a6785cc54f
github.com/redis/go-redis/v9 v9.0.2
github.com/weaveworks/common v0.0.0-20230208133027-16871410fca4

4
go.sum
View File

@ -1395,8 +1395,8 @@ github.com/grafana/saml v0.4.13-0.20230331080031-67cbfa09c7b6 h1:oHn/OOUkECNX06D
github.com/grafana/saml v0.4.13-0.20230331080031-67cbfa09c7b6/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA=
github.com/grafana/sqlds/v2 v2.3.10 h1:HWKhE0vR6LoEiE+Is8CSZOgaB//D1yqb2ntkass9Fd4=
github.com/grafana/sqlds/v2 v2.3.10/go.mod h1:c6ibxnxRVGxV/0YkEgvy7QpQH/lyifFyV7K/14xvdIs=
github.com/grafana/thema v0.0.0-20230523123227-db9596a7096e h1:pg6l/d7m7tsmlMQ6JCRI8AHFuqT41I7MWVPj8IADXzE=
github.com/grafana/thema v0.0.0-20230523123227-db9596a7096e/go.mod h1:Pn9nfzCk7nV0mvNgwusgCjCROZP6nm4GpwTnmEhLT24=
github.com/grafana/thema v0.0.0-20230524160113-4e9d6e28a640 h1:kFCq4pmBB61xzTHen/TNttd5hNlkeqGfqU9usmCc81U=
github.com/grafana/thema v0.0.0-20230524160113-4e9d6e28a640/go.mod h1:Pn9nfzCk7nV0mvNgwusgCjCROZP6nm4GpwTnmEhLT24=
github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6 h1:I9dh1MXGX0wGyxdV/Sl7+ugnki4Dfsy8lv2s5Yf887o=
github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6/go.mod h1:ZkJLEYLoVyg7amJK/5r779bHyzs2AU8f8VMiP6BM7uY=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=

View File

@ -40,9 +40,9 @@ func (j *pgoJenny) Generate(decl *pfs.PluginDecl) (*codejen.File, error) {
Config: &openapi.Config{
Group: decl.SchemaInterface.IsGroup(),
Config: &copenapi.Config{
ExpandReferences: true,
MaxCycleDepth: 10,
MaxCycleDepth: 10,
},
SplitSchema: true,
},
PackageName: slotname,
ApplyFuncs: []dstutil.ApplyFunc{corecodegen.PrefixDropper(decl.Lineage.Name())},

View File

@ -9,10 +9,6 @@
package dataquery
import (
"encoding/json"
)
// Defines values for AppInsightsGroupByQueryKind.
const (
AppInsightsGroupByQueryKindAppInsightsGroupByQuery AppInsightsGroupByQueryKind = "AppInsightsGroupByQuery"
@ -23,27 +19,6 @@ const (
AppInsightsMetricNameQueryKindAppInsightsMetricNameQuery AppInsightsMetricNameQueryKind = "AppInsightsMetricNameQuery"
)
// Defines values for AzureLogsQueryResultFormat.
const (
AzureLogsQueryResultFormatTable AzureLogsQueryResultFormat = "table"
AzureLogsQueryResultFormatTimeSeries AzureLogsQueryResultFormat = "time_series"
AzureLogsQueryResultFormatTrace AzureLogsQueryResultFormat = "trace"
)
// Defines values for AzureMonitorQueryAzureLogAnalyticsResultFormat.
const (
AzureMonitorQueryAzureLogAnalyticsResultFormatTable AzureMonitorQueryAzureLogAnalyticsResultFormat = "table"
AzureMonitorQueryAzureLogAnalyticsResultFormatTimeSeries AzureMonitorQueryAzureLogAnalyticsResultFormat = "time_series"
AzureMonitorQueryAzureLogAnalyticsResultFormatTrace AzureMonitorQueryAzureLogAnalyticsResultFormat = "trace"
)
// Defines values for AzureMonitorQueryAzureTracesResultFormat.
const (
AzureMonitorQueryAzureTracesResultFormatTable AzureMonitorQueryAzureTracesResultFormat = "table"
AzureMonitorQueryAzureTracesResultFormatTimeSeries AzureMonitorQueryAzureTracesResultFormat = "time_series"
AzureMonitorQueryAzureTracesResultFormatTrace AzureMonitorQueryAzureTracesResultFormat = "trace"
)
// Defines values for AzureQueryType.
const (
AzureQueryTypeAzureLogAnalytics AzureQueryType = "Azure Log Analytics"
@ -60,13 +35,6 @@ const (
AzureQueryTypeGrafanaTemplateVariableFunction AzureQueryType = "Grafana Template Variable Function"
)
// Defines values for AzureTracesQueryResultFormat.
const (
AzureTracesQueryResultFormatTable AzureTracesQueryResultFormat = "table"
AzureTracesQueryResultFormatTimeSeries AzureTracesQueryResultFormat = "time_series"
AzureTracesQueryResultFormatTrace AzureTracesQueryResultFormat = "trace"
)
// Defines values for GrafanaTemplateVariableQueryType.
const (
GrafanaTemplateVariableQueryTypeAppInsightsGroupByQuery GrafanaTemplateVariableQueryType = "AppInsightsGroupByQuery"
@ -129,10 +97,10 @@ const (
// AppInsightsGroupByQuery defines model for AppInsightsGroupByQuery.
type AppInsightsGroupByQuery struct {
Kind AppInsightsGroupByQueryKind `json:"kind"`
MetricName string `json:"metricName"`
RawQuery *string `json:"rawQuery,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind AppInsightsGroupByQueryKind `json:"kind"`
MetricName string `json:"metricName"`
RawQuery *string `json:"rawQuery,omitempty"`
}
// AppInsightsGroupByQueryKind defines model for AppInsightsGroupByQuery.Kind.
@ -140,9 +108,9 @@ type AppInsightsGroupByQueryKind string
// AppInsightsMetricNameQuery defines model for AppInsightsMetricNameQuery.
type AppInsightsMetricNameQuery struct {
Kind AppInsightsMetricNameQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind AppInsightsMetricNameQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
}
// AppInsightsMetricNameQueryKind defines model for AppInsightsMetricNameQuery.Kind.
@ -157,18 +125,13 @@ type AzureLogsQuery struct {
Resource *string `json:"resource,omitempty"`
// Array of resource URIs to be queried.
Resources []string `json:"resources,omitempty"`
// Specifies the format results should be returned as.
ResultFormat *AzureLogsQueryResultFormat `json:"resultFormat,omitempty"`
Resources []string `json:"resources,omitempty"`
ResultFormat *ResultFormat `json:"resultFormat,omitempty"`
// Workspace ID. This was removed in Grafana 8, but remains for backwards compat
Workspace *string `json:"workspace,omitempty"`
}
// Specifies the format results should be returned as.
type AzureLogsQueryResultFormat string
// AzureMetricDimension defines model for AzureMetricDimension.
type AzureMetricDimension struct {
// Name of Dimension to be filtered on.
@ -205,19 +168,7 @@ type AzureMetricQuery struct {
DimensionFilter *string `json:"dimensionFilter,omitempty"`
// Filters to reduce the set of data returned. Dimensions that can be filtered on are defined by the metric.
DimensionFilters []struct {
// Name of Dimension to be filtered on.
Dimension *string `json:"dimension,omitempty"`
// @deprecated filter is deprecated in favour of filters to support multiselect.
Filter *string `json:"filter,omitempty"`
// Values to match with the filter.
Filters []string `json:"filters,omitempty"`
// String denoting the filter operation. Supports 'eq' - equals,'ne' - not equals, 'sw' - starts with. Note that some dimensions may not support all operators.
Operator *string `json:"operator,omitempty"`
} `json:"dimensionFilters,omitempty"`
DimensionFilters []AzureMetricDimension `json:"dimensionFilters,omitempty"`
// @deprecated Use metricNamespace instead
MetricDefinition *string `json:"metricDefinition,omitempty"`
@ -243,13 +194,7 @@ type AzureMetricQuery struct {
ResourceUri *string `json:"resourceUri,omitempty"`
// Array of resource URIs to be queried.
Resources []struct {
MetricNamespace *string `json:"metricNamespace,omitempty"`
Region *string `json:"region,omitempty"`
ResourceGroup *string `json:"resourceGroup,omitempty"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription *string `json:"subscription,omitempty"`
} `json:"resources,omitempty"`
Resources []AzureMonitorResource `json:"resources,omitempty"`
// The granularity of data points to be queried. Defaults to auto.
TimeGrain *string `json:"timeGrain,omitempty"`
@ -266,163 +211,20 @@ type AzureMonitorDataQuery = map[string]interface{}
// AzureMonitorQuery defines model for AzureMonitorQuery.
type AzureMonitorQuery struct {
// Azure Monitor Logs sub-query properties.
AzureLogAnalytics *struct {
// KQL query to be executed.
Query *string `json:"query,omitempty"`
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// @deprecated Use resources instead
Resource *string `json:"resource,omitempty"`
// Azure Monitor Logs sub-query properties
AzureLogAnalytics *AzureLogsQuery `json:"azureLogAnalytics,omitempty"`
AzureMonitor *AzureMetricQuery `json:"azureMonitor,omitempty"`
AzureResourceGraph *AzureResourceGraphQuery `json:"azureResourceGraph,omitempty"`
// Array of resource URIs to be queried.
Resources []string `json:"resources,omitempty"`
// Specifies the format results should be returned as.
ResultFormat *AzureMonitorQueryAzureLogAnalyticsResultFormat `json:"resultFormat,omitempty"`
// Workspace ID. This was removed in Grafana 8, but remains for backwards compat
Workspace *string `json:"workspace,omitempty"`
} `json:"azureLogAnalytics,omitempty"`
// Azure Monitor Metrics sub-query properties.
AzureMonitor *struct {
// The aggregation to be used within the query. Defaults to the primaryAggregationType defined by the metric.
Aggregation *string `json:"aggregation,omitempty"`
// Aliases can be set to modify the legend labels. e.g. {{ resourceGroup }}. See docs for more detail.
Alias *string `json:"alias,omitempty"`
// Time grains that are supported by the metric.
AllowedTimeGrainsMs []int64 `json:"allowedTimeGrainsMs,omitempty"`
// Used as the value for the metricNamespace property when it's different from the resource namespace.
CustomNamespace *string `json:"customNamespace,omitempty"`
// @deprecated This property was migrated to dimensionFilters and should only be accessed in the migration
Dimension *string `json:"dimension,omitempty"`
// @deprecated This property was migrated to dimensionFilters and should only be accessed in the migration
DimensionFilter *string `json:"dimensionFilter,omitempty"`
// Filters to reduce the set of data returned. Dimensions that can be filtered on are defined by the metric.
DimensionFilters []struct {
// Name of Dimension to be filtered on.
Dimension *string `json:"dimension,omitempty"`
// @deprecated filter is deprecated in favour of filters to support multiselect.
Filter *string `json:"filter,omitempty"`
// Values to match with the filter.
Filters []string `json:"filters,omitempty"`
// String denoting the filter operation. Supports 'eq' - equals,'ne' - not equals, 'sw' - starts with. Note that some dimensions may not support all operators.
Operator *string `json:"operator,omitempty"`
} `json:"dimensionFilters,omitempty"`
// @deprecated Use metricNamespace instead
MetricDefinition *string `json:"metricDefinition,omitempty"`
// The metric to query data for within the specified metricNamespace. e.g. UsedCapacity
MetricName *string `json:"metricName,omitempty"`
// metricNamespace is used as the resource type (or resource namespace).
// It's usually equal to the target metric namespace. e.g. microsoft.storage/storageaccounts
// Kept the name of the variable as metricNamespace to avoid backward incompatibility issues.
MetricNamespace *string `json:"metricNamespace,omitempty"`
// The Azure region containing the resource(s).
Region *string `json:"region,omitempty"`
// @deprecated Use resources instead
ResourceGroup *string `json:"resourceGroup,omitempty"`
// @deprecated Use resources instead
ResourceName *string `json:"resourceName,omitempty"`
// @deprecated Use resourceGroup, resourceName and metricNamespace instead
ResourceUri *string `json:"resourceUri,omitempty"`
// Array of resource URIs to be queried.
Resources []struct {
MetricNamespace *string `json:"metricNamespace,omitempty"`
Region *string `json:"region,omitempty"`
ResourceGroup *string `json:"resourceGroup,omitempty"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription *string `json:"subscription,omitempty"`
} `json:"resources,omitempty"`
// The granularity of data points to be queried. Defaults to auto.
TimeGrain *string `json:"timeGrain,omitempty"`
// TimeGrainUnit @deprecated
TimeGrainUnit *string `json:"timeGrainUnit,omitempty"`
// Maximum number of records to return. Defaults to 10.
Top *string `json:"top,omitempty"`
} `json:"azureMonitor,omitempty"`
// Azure Resource Graph sub-query properties.
AzureResourceGraph *struct {
// Azure Resource Graph KQL query to be executed.
Query *string `json:"query,omitempty"`
// Specifies the format results should be returned as. Defaults to table.
ResultFormat *string `json:"resultFormat,omitempty"`
} `json:"azureResourceGraph,omitempty"`
// Application Insights Traces sub-query properties.
AzureTraces *struct {
// Filters for property values.
Filters []struct {
// Values to filter by.
Filters []string `json:"filters"`
// Comparison operator to use. Either equals or not equals.
Operation string `json:"operation"`
// Property name, auto-populated based on available traces.
Property string `json:"property"`
} `json:"filters,omitempty"`
// Operation ID. Used only for Traces queries.
OperationId *string `json:"operationId,omitempty"`
// KQL query to be executed.
Query *string `json:"query,omitempty"`
// Array of resource URIs to be queried.
Resources []string `json:"resources,omitempty"`
// Specifies the format results should be returned as.
ResultFormat *AzureMonitorQueryAzureTracesResultFormat `json:"resultFormat,omitempty"`
// Types of events to filter by.
TraceTypes []string `json:"traceTypes,omitempty"`
} `json:"azureTraces,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"`
// @deprecated Legacy template variable support.
GrafanaTemplateVariableFn *AzureMonitorQueryGrafanaTemplateVariableFn `json:"grafanaTemplateVariableFn,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"`
Namespace *string `json:"namespace,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"`
// Application Insights Traces sub-query properties
AzureTraces *AzureTracesQuery `json:"azureTraces,omitempty"`
GrafanaTemplateVariableFn *interface{} `json:"grafanaTemplateVariableFn,omitempty"`
Namespace *string `json:"namespace,omitempty"`
// Azure Monitor query type.
// queryType: #AzureQueryType
@ -439,25 +241,6 @@ type AzureMonitorQuery struct {
Subscriptions []string `json:"subscriptions,omitempty"`
}
// Specifies the format results should be returned as.
type AzureMonitorQueryAzureLogAnalyticsResultFormat string
// Specifies the format results should be returned as.
type AzureMonitorQueryAzureTracesResultFormat string
// @deprecated Legacy template variable support.
type AzureMonitorQueryGrafanaTemplateVariableFn struct {
Kind *interface{} `json:"kind,omitempty"`
MetricName *string `json:"metricName,omitempty"`
MetricNamespace *string `json:"metricNamespace,omitempty"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup *string `json:"resourceGroup,omitempty"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription *string `json:"subscription,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
union json.RawMessage
}
// AzureMonitorResource defines model for AzureMonitorResource.
type AzureMonitorResource struct {
MetricNamespace *string `json:"metricNamespace,omitempty"`
@ -494,16 +277,7 @@ type AzureTracesFilter struct {
// Application Insights Traces sub-query properties
type AzureTracesQuery struct {
// Filters for property values.
Filters []struct {
// Values to filter by.
Filters []string `json:"filters"`
// Comparison operator to use. Either equals or not equals.
Operation string `json:"operation"`
// Property name, auto-populated based on available traces.
Property string `json:"property"`
} `json:"filters,omitempty"`
Filters []AzureTracesFilter `json:"filters,omitempty"`
// Operation ID. Used only for Traces queries.
OperationId *string `json:"operationId,omitempty"`
@ -512,49 +286,55 @@ type AzureTracesQuery struct {
Query *string `json:"query,omitempty"`
// Array of resource URIs to be queried.
Resources []string `json:"resources,omitempty"`
// Specifies the format results should be returned as.
ResultFormat *AzureTracesQueryResultFormat `json:"resultFormat,omitempty"`
Resources []string `json:"resources,omitempty"`
ResultFormat *ResultFormat `json:"resultFormat,omitempty"`
// Types of events to filter by.
TraceTypes []string `json:"traceTypes,omitempty"`
}
// Specifies the format results should be returned as.
type AzureTracesQueryResultFormat string
// BaseGrafanaTemplateVariableQuery defines model for BaseGrafanaTemplateVariableQuery.
type BaseGrafanaTemplateVariableQuery struct {
RawQuery *string `json:"rawQuery,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
RawQuery *string `json:"rawQuery,omitempty"`
}
// GrafanaTemplateVariableQuery defines model for GrafanaTemplateVariableQuery.
type GrafanaTemplateVariableQuery struct {
Kind *interface{} `json:"kind,omitempty"`
MetricName *string `json:"metricName,omitempty"`
MetricNamespace *string `json:"metricNamespace,omitempty"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup *string `json:"resourceGroup,omitempty"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription *string `json:"subscription,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
union json.RawMessage
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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"`
// 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"`
}
// GrafanaTemplateVariableQueryType defines model for GrafanaTemplateVariableQueryType.
type GrafanaTemplateVariableQueryType string
// @deprecated Use MetricNamespaceQuery instead
// MetricDefinitionsQuery defines model for MetricDefinitionsQuery.
type MetricDefinitionsQuery struct {
Kind MetricDefinitionsQueryKind `json:"kind"`
MetricNamespace *string `json:"metricNamespace,omitempty"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup string `json:"resourceGroup"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription string `json:"subscription"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind MetricDefinitionsQueryKind `json:"kind"`
MetricNamespace *string `json:"metricNamespace,omitempty"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup string `json:"resourceGroup"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription string `json:"subscription"`
}
// MetricDefinitionsQueryKind defines model for MetricDefinitionsQuery.Kind.
@ -562,13 +342,13 @@ type MetricDefinitionsQueryKind string
// MetricNamesQuery defines model for MetricNamesQuery.
type MetricNamesQuery struct {
Kind MetricNamesQueryKind `json:"kind"`
MetricNamespace string `json:"metricNamespace"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup string `json:"resourceGroup"`
ResourceName string `json:"resourceName"`
Subscription string `json:"subscription"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind MetricNamesQueryKind `json:"kind"`
MetricNamespace string `json:"metricNamespace"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup string `json:"resourceGroup"`
ResourceName string `json:"resourceName"`
Subscription string `json:"subscription"`
}
// MetricNamesQueryKind defines model for MetricNamesQuery.Kind.
@ -576,13 +356,13 @@ type MetricNamesQueryKind string
// MetricNamespaceQuery defines model for MetricNamespaceQuery.
type MetricNamespaceQuery struct {
Kind MetricNamespaceQueryKind `json:"kind"`
MetricNamespace *string `json:"metricNamespace,omitempty"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup string `json:"resourceGroup"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription string `json:"subscription"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind MetricNamespaceQueryKind `json:"kind"`
MetricNamespace *string `json:"metricNamespace,omitempty"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup string `json:"resourceGroup"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription string `json:"subscription"`
}
// MetricNamespaceQueryKind defines model for MetricNamespaceQuery.Kind.
@ -590,10 +370,10 @@ type MetricNamespaceQueryKind string
// ResourceGroupsQuery defines model for ResourceGroupsQuery.
type ResourceGroupsQuery struct {
Kind ResourceGroupsQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
Subscription string `json:"subscription"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind ResourceGroupsQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
Subscription string `json:"subscription"`
}
// ResourceGroupsQueryKind defines model for ResourceGroupsQuery.Kind.
@ -601,12 +381,12 @@ type ResourceGroupsQueryKind string
// ResourceNamesQuery defines model for ResourceNamesQuery.
type ResourceNamesQuery struct {
Kind ResourceNamesQueryKind `json:"kind"`
MetricNamespace string `json:"metricNamespace"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup string `json:"resourceGroup"`
Subscription string `json:"subscription"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind ResourceNamesQueryKind `json:"kind"`
MetricNamespace string `json:"metricNamespace"`
RawQuery *string `json:"rawQuery,omitempty"`
ResourceGroup string `json:"resourceGroup"`
Subscription string `json:"subscription"`
}
// ResourceNamesQueryKind defines model for ResourceNamesQuery.Kind.
@ -617,9 +397,9 @@ type ResultFormat string
// SubscriptionsQuery defines model for SubscriptionsQuery.
type SubscriptionsQuery struct {
Kind SubscriptionsQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind SubscriptionsQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
}
// SubscriptionsQueryKind defines model for SubscriptionsQuery.Kind.
@ -627,9 +407,9 @@ type SubscriptionsQueryKind string
// UnknownQuery defines model for UnknownQuery.
type UnknownQuery struct {
Kind UnknownQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind UnknownQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
}
// UnknownQueryKind defines model for UnknownQuery.Kind.
@ -637,10 +417,10 @@ type UnknownQueryKind string
// WorkspacesQuery defines model for WorkspacesQuery.
type WorkspacesQuery struct {
Kind WorkspacesQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
Subscription string `json:"subscription"`
AdditionalProperties map[string]interface{} `json:"-"`
BaseGrafanaTemplateVariableQuery
Kind WorkspacesQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"`
Subscription string `json:"subscription"`
}
// WorkspacesQueryKind defines model for WorkspacesQuery.Kind.

View File

@ -138,7 +138,7 @@ func (e *AzureLogAnalyticsDatasource) buildQueries(ctx context.Context, logger l
if azureTracesTarget.ResultFormat == nil {
resultFormat = types.Table
} else {
resultFormat = string(*azureTracesTarget.ResultFormat)
resultFormat = *azureTracesTarget.ResultFormat
if resultFormat == "" {
resultFormat = types.Table
}
@ -351,7 +351,7 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, logger l
return dataResponse
}
traceIdVariable := "${__data.fields.traceID}"
resultFormat := dataquery.AzureMonitorQueryAzureTracesResultFormatTrace
resultFormat := dataquery.ResultFormatTrace
queryJSONModel.AzureTraces.ResultFormat = &resultFormat
queryJSONModel.AzureTraces.Query = &query.TraceExploreQuery
if queryJSONModel.AzureTraces.OperationId == nil || *queryJSONModel.AzureTraces.OperationId == "" {
@ -360,20 +360,16 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, logger l
logsQueryType := string(dataquery.AzureQueryTypeAzureLogAnalytics)
logsJSONModel := dataquery.AzureMonitorQuery{
AzureLogAnalytics: &struct {
Query *string "json:\"query,omitempty\""
Resource *string "json:\"resource,omitempty\""
Resources []string "json:\"resources,omitempty\""
ResultFormat *dataquery.AzureMonitorQueryAzureLogAnalyticsResultFormat "json:\"resultFormat,omitempty\""
Workspace *string "json:\"workspace,omitempty\""
}{
Resources: []string{queryJSONModel.AzureTraces.Resources[0]},
Query: &query.TraceLogsExploreQuery,
DataQuery: dataquery.DataQuery{
QueryType: &logsQueryType,
},
AzureLogAnalytics: &dataquery.AzureLogsQuery{
Query: &query.TraceLogsExploreQuery,
Resources: []string{queryJSONModel.AzureTraces.Resources[0]},
},
QueryType: &logsQueryType,
}
if query.ResultFormat == string(dataquery.AzureMonitorQueryAzureTracesResultFormatTable) {
if query.ResultFormat == string(dataquery.ResultFormatTable) {
AddCustomDataLink(*frame, data.DataLink{
Title: "Explore Trace: ${__data.fields.traceID}",
URL: "",

View File

@ -11,7 +11,6 @@ import (
"github.com/grafana/grafana-azure-sdk-go/azcredentials"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/kinds/dataquery"
)
const (
@ -227,7 +226,7 @@ type TracesJSONQuery struct {
Resources []string `json:"resources"`
// Specifies the format results should be returned as.
ResultFormat *dataquery.AzureMonitorQueryAzureTracesResultFormat `json:"resultFormat"`
ResultFormat *string `json:"resultFormat"`
// Types of events to filter by.
TraceTypes []string `json:"traceTypes"`

View File

@ -9,10 +9,6 @@
package dataquery
import (
"encoding/json"
)
// Defines values for AlignmentTypes.
const (
AlignmentTypesALIGNCOUNT AlignmentTypes = "ALIGN_COUNT"
@ -36,28 +32,6 @@ const (
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"
@ -83,21 +57,6 @@ const (
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"
@ -113,13 +72,6 @@ const (
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"
@ -136,58 +88,45 @@ 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"`
// TimeSeriesList Time Series List sub-query properties.
TimeSeriesList
// 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 {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.
AliasBy *string `json:"aliasBy,omitempty"`
// Time interval in milliseconds.
IntervalMs *float32 `json:"intervalMs,omitempty"`
// SLO sub-query properties.
SloQuery *SLOQuery `json:"sloQuery,omitempty"`
// GCM query type.
// queryType: #QueryType
// Time Series List sub-query properties.
TimeSeriesList *interface{} `json:"timeSeriesList,omitempty"`
// Time Series sub-query properties.
TimeSeriesQuery *TimeSeriesQuery `json:"timeSeriesQuery,omitempty"`
}
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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
@ -199,9 +138,6 @@ type CloudMonitoringQuery struct {
// 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"`
@ -210,108 +146,6 @@ type CloudMonitoringQuery struct {
// 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.
@ -335,9 +169,9 @@ 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"`
Filters []string `json:"filters"`
MetricKind MetricKind `json:"metricKind"`
MetricType string `json:"metricType"`
// GCP project to execute the query against.
ProjectName string `json:"projectName"`
@ -353,9 +187,6 @@ type LegacyCloudMonitoringAnnotationQuery struct {
ValueType string `json:"valueType"`
}
// LegacyCloudMonitoringAnnotationQueryMetricKind defines model for LegacyCloudMonitoringAnnotationQuery.MetricKind.
type LegacyCloudMonitoringAnnotationQueryMetricKind string
// MetricFindQueryTypes defines model for MetricFindQueryTypes.
type MetricFindQueryTypes string
@ -381,15 +212,15 @@ type MetricQuery struct {
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"`
GroupBys []string `json:"groupBys,omitempty"`
MetricKind *MetricKind `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"`
// Types of pre-processor available. Defined by the metric.
Preprocessor *PreprocessorType `json:"preprocessor,omitempty"`
// GCP project to execute the query against.
ProjectName string `json:"projectName"`
@ -400,12 +231,6 @@ type MetricQuery struct {
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
@ -462,8 +287,8 @@ type TimeSeriesList struct {
// 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"`
// Types of pre-processor available. Defined by the metric.
Preprocessor *PreprocessorType `json:"preprocessor,omitempty"`
// GCP project to execute the query against.
ProjectName string `json:"projectName"`
@ -481,13 +306,9 @@ type TimeSeriesList struct {
SecondaryPerSeriesAligner *string `json:"secondaryPerSeriesAligner,omitempty"`
// Data view, defaults to FULL.
View *string `json:"view,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
View *string `json:"view,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 TimeSeriesListPreprocessor string
// Time Series sub-query properties.
type TimeSeriesQuery struct {
// To disable the graphPeriod, it should explictly be set to 'disabled'.

View File

@ -11,6 +11,7 @@ import (
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
)
type annotationEvent struct {
@ -59,6 +60,12 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
if model.MetricName != nil {
metricName = *model.MetricName
}
dimensions := dataquery.Dimensions{}
if model.Dimensions != nil {
dimensions = *model.Dimensions
}
if prefixMatching {
params := &cloudwatch.DescribeAlarmsInput{
MaxRecords: aws.Int64(100),
@ -69,14 +76,14 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
if err != nil {
return nil, fmt.Errorf("%v: %w", "failed to call cloudwatch:DescribeAlarms", err)
}
alarmNames = filterAlarms(resp, model.Namespace, metricName, model.Dimensions, statistic, period)
alarmNames = filterAlarms(resp, model.Namespace, metricName, dimensions, statistic, period)
} else {
if model.Region == "" || model.Namespace == "" || metricName == "" || statistic == "" {
return result, errors.New("invalid annotations query")
}
var qd []*cloudwatch.Dimension
for k, v := range model.Dimensions {
for k, v := range dimensions {
if vv, ok := v.([]interface{}); ok {
for _, vvv := range vv {
if vvvv, ok := vvv.(string); ok {

View File

@ -9,105 +9,6 @@
package dataquery
import (
"encoding/json"
)
// Defines values for CloudWatchAnnotationQueryQueryMode.
const (
CloudWatchAnnotationQueryQueryModeAnnotations CloudWatchAnnotationQueryQueryMode = "Annotations"
CloudWatchAnnotationQueryQueryModeLogs CloudWatchAnnotationQueryQueryMode = "Logs"
CloudWatchAnnotationQueryQueryModeMetrics CloudWatchAnnotationQueryQueryMode = "Metrics"
)
// Defines values for CloudWatchLogsQueryQueryMode.
const (
CloudWatchLogsQueryQueryModeAnnotations CloudWatchLogsQueryQueryMode = "Annotations"
CloudWatchLogsQueryQueryModeLogs CloudWatchLogsQueryQueryMode = "Logs"
CloudWatchLogsQueryQueryModeMetrics CloudWatchLogsQueryQueryMode = "Metrics"
)
// Defines values for CloudWatchMetricsQueryMetricEditorMode.
const (
CloudWatchMetricsQueryMetricEditorModeN0 CloudWatchMetricsQueryMetricEditorMode = 0
CloudWatchMetricsQueryMetricEditorModeN1 CloudWatchMetricsQueryMetricEditorMode = 1
)
// Defines values for CloudWatchMetricsQueryMetricQueryType.
const (
CloudWatchMetricsQueryMetricQueryTypeN0 CloudWatchMetricsQueryMetricQueryType = 0
CloudWatchMetricsQueryMetricQueryTypeN1 CloudWatchMetricsQueryMetricQueryType = 1
)
// Defines values for CloudWatchMetricsQueryQueryMode.
const (
CloudWatchMetricsQueryQueryModeAnnotations CloudWatchMetricsQueryQueryMode = "Annotations"
CloudWatchMetricsQueryQueryModeLogs CloudWatchMetricsQueryQueryMode = "Logs"
CloudWatchMetricsQueryQueryModeMetrics CloudWatchMetricsQueryQueryMode = "Metrics"
)
// Defines values for CloudWatchMetricsQuerySqlFromParametersType.
const (
CloudWatchMetricsQuerySqlFromParametersTypeFunctionParameter CloudWatchMetricsQuerySqlFromParametersType = "functionParameter"
)
// Defines values for CloudWatchMetricsQuerySqlFromPropertyType.
const (
CloudWatchMetricsQuerySqlFromPropertyTypeString CloudWatchMetricsQuerySqlFromPropertyType = "string"
)
// Defines values for CloudWatchMetricsQuerySqlGroupByExpressionsParametersType.
const (
CloudWatchMetricsQuerySqlGroupByExpressionsParametersTypeFunctionParameter CloudWatchMetricsQuerySqlGroupByExpressionsParametersType = "functionParameter"
)
// Defines values for CloudWatchMetricsQuerySqlGroupByExpressionsPropertyType.
const (
CloudWatchMetricsQuerySqlGroupByExpressionsPropertyTypeString CloudWatchMetricsQuerySqlGroupByExpressionsPropertyType = "string"
)
// Defines values for CloudWatchMetricsQuerySqlGroupByType.
const (
CloudWatchMetricsQuerySqlGroupByTypeAnd CloudWatchMetricsQuerySqlGroupByType = "and"
CloudWatchMetricsQuerySqlGroupByTypeOr CloudWatchMetricsQuerySqlGroupByType = "or"
)
// Defines values for CloudWatchMetricsQuerySqlOrderByParametersType.
const (
CloudWatchMetricsQuerySqlOrderByParametersTypeFunctionParameter CloudWatchMetricsQuerySqlOrderByParametersType = "functionParameter"
)
// Defines values for CloudWatchMetricsQuerySqlOrderByType.
const (
CloudWatchMetricsQuerySqlOrderByTypeFunction CloudWatchMetricsQuerySqlOrderByType = "function"
)
// Defines values for CloudWatchMetricsQuerySqlSelectParametersType.
const (
CloudWatchMetricsQuerySqlSelectParametersTypeFunctionParameter CloudWatchMetricsQuerySqlSelectParametersType = "functionParameter"
)
// Defines values for CloudWatchMetricsQuerySqlSelectType.
const (
CloudWatchMetricsQuerySqlSelectTypeFunction CloudWatchMetricsQuerySqlSelectType = "function"
)
// Defines values for CloudWatchMetricsQuerySqlWhereExpressionsParametersType.
const (
CloudWatchMetricsQuerySqlWhereExpressionsParametersTypeFunctionParameter CloudWatchMetricsQuerySqlWhereExpressionsParametersType = "functionParameter"
)
// Defines values for CloudWatchMetricsQuerySqlWhereExpressionsPropertyType.
const (
CloudWatchMetricsQuerySqlWhereExpressionsPropertyTypeString CloudWatchMetricsQuerySqlWhereExpressionsPropertyType = "string"
)
// Defines values for CloudWatchMetricsQuerySqlWhereType.
const (
CloudWatchMetricsQuerySqlWhereTypeAnd CloudWatchMetricsQuerySqlWhereType = "and"
CloudWatchMetricsQuerySqlWhereTypeOr CloudWatchMetricsQuerySqlWhereType = "or"
)
// Defines values for CloudWatchQueryMode.
const (
CloudWatchQueryModeAnnotations CloudWatchQueryMode = "Annotations"
@ -127,42 +28,12 @@ const (
MetricQueryTypeN1 MetricQueryType = 1
)
// Defines values for QueryEditorArrayExpressionExpressionsParametersType.
const (
QueryEditorArrayExpressionExpressionsParametersTypeFunctionParameter QueryEditorArrayExpressionExpressionsParametersType = "functionParameter"
)
// Defines values for QueryEditorArrayExpressionExpressionsPropertyType.
const (
QueryEditorArrayExpressionExpressionsPropertyTypeString QueryEditorArrayExpressionExpressionsPropertyType = "string"
)
// Defines values for QueryEditorArrayExpressionType.
const (
QueryEditorArrayExpressionTypeAnd QueryEditorArrayExpressionType = "and"
QueryEditorArrayExpressionTypeOr QueryEditorArrayExpressionType = "or"
)
// Defines values for QueryEditorExpressionExpressionsParametersType.
const (
QueryEditorExpressionExpressionsParametersTypeFunctionParameter QueryEditorExpressionExpressionsParametersType = "functionParameter"
)
// Defines values for QueryEditorExpressionExpressionsPropertyType.
const (
QueryEditorExpressionExpressionsPropertyTypeString QueryEditorExpressionExpressionsPropertyType = "string"
)
// Defines values for QueryEditorExpressionParametersType.
const (
QueryEditorExpressionParametersTypeFunctionParameter QueryEditorExpressionParametersType = "functionParameter"
)
// Defines values for QueryEditorExpressionPropertyType.
const (
QueryEditorExpressionPropertyTypeString QueryEditorExpressionPropertyType = "string"
)
// Defines values for QueryEditorExpressionType.
const (
QueryEditorExpressionTypeAnd QueryEditorExpressionType = "and"
@ -174,39 +45,59 @@ const (
QueryEditorExpressionTypeProperty QueryEditorExpressionType = "property"
)
// Defines values for QueryEditorFunctionExpressionParametersType.
const (
QueryEditorFunctionExpressionParametersTypeFunctionParameter QueryEditorFunctionExpressionParametersType = "functionParameter"
)
// Defines values for QueryEditorFunctionExpressionType.
const (
QueryEditorFunctionExpressionTypeFunction QueryEditorFunctionExpressionType = "function"
QueryEditorFunctionExpressionTypeAnd QueryEditorFunctionExpressionType = "and"
QueryEditorFunctionExpressionTypeFunction QueryEditorFunctionExpressionType = "function"
QueryEditorFunctionExpressionTypeFunctionParameter QueryEditorFunctionExpressionType = "functionParameter"
QueryEditorFunctionExpressionTypeGroupBy QueryEditorFunctionExpressionType = "groupBy"
QueryEditorFunctionExpressionTypeOperator QueryEditorFunctionExpressionType = "operator"
QueryEditorFunctionExpressionTypeOr QueryEditorFunctionExpressionType = "or"
QueryEditorFunctionExpressionTypeProperty QueryEditorFunctionExpressionType = "property"
)
// Defines values for QueryEditorFunctionParameterExpressionType.
const (
QueryEditorFunctionParameterExpressionTypeAnd QueryEditorFunctionParameterExpressionType = "and"
QueryEditorFunctionParameterExpressionTypeFunction QueryEditorFunctionParameterExpressionType = "function"
QueryEditorFunctionParameterExpressionTypeFunctionParameter QueryEditorFunctionParameterExpressionType = "functionParameter"
)
// Defines values for QueryEditorGroupByExpressionPropertyType.
const (
QueryEditorGroupByExpressionPropertyTypeString QueryEditorGroupByExpressionPropertyType = "string"
QueryEditorFunctionParameterExpressionTypeGroupBy QueryEditorFunctionParameterExpressionType = "groupBy"
QueryEditorFunctionParameterExpressionTypeOperator QueryEditorFunctionParameterExpressionType = "operator"
QueryEditorFunctionParameterExpressionTypeOr QueryEditorFunctionParameterExpressionType = "or"
QueryEditorFunctionParameterExpressionTypeProperty QueryEditorFunctionParameterExpressionType = "property"
)
// Defines values for QueryEditorGroupByExpressionType.
const (
QueryEditorGroupByExpressionTypeGroupBy QueryEditorGroupByExpressionType = "groupBy"
)
// Defines values for QueryEditorOperatorExpressionPropertyType.
const (
QueryEditorOperatorExpressionPropertyTypeString QueryEditorOperatorExpressionPropertyType = "string"
QueryEditorGroupByExpressionTypeAnd QueryEditorGroupByExpressionType = "and"
QueryEditorGroupByExpressionTypeFunction QueryEditorGroupByExpressionType = "function"
QueryEditorGroupByExpressionTypeFunctionParameter QueryEditorGroupByExpressionType = "functionParameter"
QueryEditorGroupByExpressionTypeGroupBy QueryEditorGroupByExpressionType = "groupBy"
QueryEditorGroupByExpressionTypeOperator QueryEditorGroupByExpressionType = "operator"
QueryEditorGroupByExpressionTypeOr QueryEditorGroupByExpressionType = "or"
QueryEditorGroupByExpressionTypeProperty QueryEditorGroupByExpressionType = "property"
)
// Defines values for QueryEditorOperatorExpressionType.
const (
QueryEditorOperatorExpressionTypeOperator QueryEditorOperatorExpressionType = "operator"
QueryEditorOperatorExpressionTypeAnd QueryEditorOperatorExpressionType = "and"
QueryEditorOperatorExpressionTypeFunction QueryEditorOperatorExpressionType = "function"
QueryEditorOperatorExpressionTypeFunctionParameter QueryEditorOperatorExpressionType = "functionParameter"
QueryEditorOperatorExpressionTypeGroupBy QueryEditorOperatorExpressionType = "groupBy"
QueryEditorOperatorExpressionTypeOperator QueryEditorOperatorExpressionType = "operator"
QueryEditorOperatorExpressionTypeOr QueryEditorOperatorExpressionType = "or"
QueryEditorOperatorExpressionTypeProperty QueryEditorOperatorExpressionType = "property"
)
// Defines values for QueryEditorPropertyExpressionType.
const (
QueryEditorPropertyExpressionTypeAnd QueryEditorPropertyExpressionType = "and"
QueryEditorPropertyExpressionTypeFunction QueryEditorPropertyExpressionType = "function"
QueryEditorPropertyExpressionTypeFunctionParameter QueryEditorPropertyExpressionType = "functionParameter"
QueryEditorPropertyExpressionTypeGroupBy QueryEditorPropertyExpressionType = "groupBy"
QueryEditorPropertyExpressionTypeOperator QueryEditorPropertyExpressionType = "operator"
QueryEditorPropertyExpressionTypeOr QueryEditorPropertyExpressionType = "or"
QueryEditorPropertyExpressionTypeProperty QueryEditorPropertyExpressionType = "property"
)
// Defines values for QueryEditorPropertyType.
@ -214,83 +105,14 @@ const (
QueryEditorPropertyTypeString QueryEditorPropertyType = "string"
)
// Defines values for QueryEditorPropertyExpressionPropertyType.
const (
QueryEditorPropertyExpressionPropertyTypeString QueryEditorPropertyExpressionPropertyType = "string"
)
// Defines values for QueryEditorPropertyExpressionType.
const (
QueryEditorPropertyExpressionTypeProperty QueryEditorPropertyExpressionType = "property"
)
// Defines values for SQLExpressionFromParametersType.
const (
SQLExpressionFromParametersTypeFunctionParameter SQLExpressionFromParametersType = "functionParameter"
)
// Defines values for SQLExpressionFromPropertyType.
const (
SQLExpressionFromPropertyTypeString SQLExpressionFromPropertyType = "string"
)
// Defines values for SQLExpressionGroupByExpressionsParametersType.
const (
SQLExpressionGroupByExpressionsParametersTypeFunctionParameter SQLExpressionGroupByExpressionsParametersType = "functionParameter"
)
// Defines values for SQLExpressionGroupByExpressionsPropertyType.
const (
SQLExpressionGroupByExpressionsPropertyTypeString SQLExpressionGroupByExpressionsPropertyType = "string"
)
// Defines values for SQLExpressionGroupByType.
const (
SQLExpressionGroupByTypeAnd SQLExpressionGroupByType = "and"
SQLExpressionGroupByTypeOr SQLExpressionGroupByType = "or"
)
// Defines values for SQLExpressionOrderByParametersType.
const (
SQLExpressionOrderByParametersTypeFunctionParameter SQLExpressionOrderByParametersType = "functionParameter"
)
// Defines values for SQLExpressionOrderByType.
const (
SQLExpressionOrderByTypeFunction SQLExpressionOrderByType = "function"
)
// Defines values for SQLExpressionSelectParametersType.
const (
SQLExpressionSelectParametersTypeFunctionParameter SQLExpressionSelectParametersType = "functionParameter"
)
// Defines values for SQLExpressionSelectType.
const (
SQLExpressionSelectTypeFunction SQLExpressionSelectType = "function"
)
// Defines values for SQLExpressionWhereExpressionsParametersType.
const (
SQLExpressionWhereExpressionsParametersTypeFunctionParameter SQLExpressionWhereExpressionsParametersType = "functionParameter"
)
// Defines values for SQLExpressionWhereExpressionsPropertyType.
const (
SQLExpressionWhereExpressionsPropertyTypeString SQLExpressionWhereExpressionsPropertyType = "string"
)
// Defines values for SQLExpressionWhereType.
const (
SQLExpressionWhereTypeAnd SQLExpressionWhereType = "and"
SQLExpressionWhereTypeOr SQLExpressionWhereType = "or"
)
// Shape of a CloudWatch Annotation query
//
// TS type is CloudWatchDefaultQuery = Omit<CloudWatchLogsQuery, 'queryMode'> & CloudWatchMetricsQuery, declared in veneer
// #CloudWatchDefaultQuery: #CloudWatchLogsQuery & #CloudWatchMetricsQuery @cuetsy(kind="type")
// CloudWatchAnnotationQuery defines model for CloudWatchAnnotationQuery.
type CloudWatchAnnotationQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
MetricStat
// The ID of the AWS account to query for the metric, specifying `all` will query all accounts that the monitoring account is permitted to query.
AccountId *string `json:"accountId,omitempty"`
@ -312,8 +134,8 @@ type CloudWatchAnnotationQuery struct {
// TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"`
// The dimensions of the metric
Dimensions map[string]interface{} `json:"dimensions,omitempty"`
// A name/value pair that is part of the identity of a metric. For example, you can get statistics for a specific EC2 instance by specifying the InstanceId dimension when you search for metrics.
Dimensions *Dimensions `json:"dimensions,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
@ -333,10 +155,8 @@ type CloudWatchAnnotationQuery struct {
Period *string `json:"period,omitempty"`
// Enable matching on the prefix of the action name or alarm name, specify the prefixes with actionPrefix and/or alarmNamePrefix
PrefixMatching *bool `json:"prefixMatching,omitempty"`
// Whether a query is a Metrics, Logs, or Annotations query
QueryMode CloudWatchAnnotationQueryQueryMode `json:"queryMode"`
PrefixMatching *bool `json:"prefixMatching,omitempty"`
QueryMode CloudWatchQueryMode `json:"queryMode"`
// Specify the query flavor
// TODO make this required and give it a default
@ -357,14 +177,16 @@ type CloudWatchAnnotationQuery struct {
Statistics []string `json:"statistics,omitempty"`
}
// Whether a query is a Metrics, Logs, or Annotations query
type CloudWatchAnnotationQueryQueryMode string
// CloudWatchDataQuery defines model for CloudWatchDataQuery.
type CloudWatchDataQuery = map[string]interface{}
// Shape of a CloudWatch Logs query
// CloudWatchLogsQuery defines model for CloudWatchLogsQuery.
type CloudWatchLogsQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// 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
@ -384,22 +206,8 @@ type CloudWatchLogsQuery struct {
LogGroupNames []string `json:"logGroupNames,omitempty"`
// Log groups to query
LogGroups []struct {
// AccountId of the log group
AccountId *string `json:"accountId,omitempty"`
// Label of the log group
AccountLabel *string `json:"accountLabel,omitempty"`
// ARN of the log group
Arn string `json:"arn"`
// Name of the log group
Name string `json:"name"`
} `json:"logGroups,omitempty"`
// Whether a query is a Metrics, Logs, or Annotations query
QueryMode CloudWatchLogsQueryQueryMode `json:"queryMode"`
LogGroups []LogGroup `json:"logGroups,omitempty"`
QueryMode CloudWatchQueryMode `json:"queryMode"`
// Specify the query flavor
// TODO make this required and give it a default
@ -417,11 +225,14 @@ type CloudWatchLogsQuery struct {
StatsGroups []string `json:"statsGroups,omitempty"`
}
// Whether a query is a Metrics, Logs, or Annotations query
type CloudWatchLogsQueryQueryMode string
// Shape of a CloudWatch Metrics query
// CloudWatchMetricsQuery defines model for CloudWatchMetricsQuery.
type CloudWatchMetricsQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
MetricStat
// The ID of the AWS account to query for the metric, specifying `all` will query all accounts that the monitoring account is permitted to query.
AccountId *string `json:"accountId,omitempty"`
@ -435,8 +246,8 @@ type CloudWatchMetricsQuery struct {
// TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"`
// The dimensions of the metric
Dimensions map[string]interface{} `json:"dimensions,omitempty"`
// A name/value pair that is part of the identity of a metric. For example, you can get statistics for a specific EC2 instance by specifying the InstanceId dimension when you search for metrics.
Dimensions *Dimensions `json:"dimensions,omitempty"`
// Math expression query
Expression *string `json:"expression,omitempty"`
@ -453,25 +264,19 @@ type CloudWatchMetricsQuery struct {
Label *string `json:"label,omitempty"`
// Only show metrics that exactly match all defined dimension names.
MatchExact *bool `json:"matchExact,omitempty"`
// Whether to use the query builder or code editor to create the query
MetricEditorMode *CloudWatchMetricsQueryMetricEditorMode `json:"metricEditorMode,omitempty"`
MatchExact *bool `json:"matchExact,omitempty"`
MetricEditorMode *MetricEditorMode `json:"metricEditorMode,omitempty"`
// Name of the metric
MetricName *string `json:"metricName,omitempty"`
// Whether to use a metric search or metric query. Metric query is referred to as "Metrics Insights" in the AWS console.
MetricQueryType *CloudWatchMetricsQueryMetricQueryType `json:"metricQueryType,omitempty"`
MetricName *string `json:"metricName,omitempty"`
MetricQueryType *MetricQueryType `json:"metricQueryType,omitempty"`
// A namespace is a container for CloudWatch metrics. Metrics in different namespaces are isolated from each other, so that metrics from different applications are not mistakenly aggregated into the same statistics. For example, Amazon EC2 uses the AWS/EC2 namespace.
Namespace string `json:"namespace"`
// The length of time associated with a specific Amazon CloudWatch statistic. Can be specified by a number of seconds, 'auto', or as a duration string e.g. '15m' being 15 minutes
Period *string `json:"period,omitempty"`
// Whether a query is a Metrics, Logs, or Annotations query
QueryMode *CloudWatchMetricsQueryQueryMode `json:"queryMode,omitempty"`
Period *string `json:"period,omitempty"`
QueryMode *CloudWatchQueryMode `json:"queryMode,omitempty"`
// Specify the query flavor
// TODO make this required and give it a default
@ -483,51 +288,8 @@ type CloudWatchMetricsQuery struct {
RefId string `json:"refId"`
// AWS region to query for the metric
Region string `json:"region"`
// When the metric query type is `metricQueryType` is set to `Query` and the `metricEditorMode` is set to `Builder`, this field is used to build up an object representation of a SQL query.
Sql *struct {
// FROM part of the SQL expression
From *CloudWatchMetricsQuerySqlFrom `json:"from,omitempty"`
// GROUP BY part of the SQL expression
GroupBy *struct {
Expressions []CloudWatchMetricsQuerySqlGroupByExpressionsItem `json:"expressions"`
Type CloudWatchMetricsQuerySqlGroupByType `json:"type"`
} `json:"groupBy,omitempty"`
// LIMIT part of the SQL expression
Limit *int64 `json:"limit,omitempty"`
// ORDER BY part of the SQL expression
OrderBy *struct {
Name *string `json:"name,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type CloudWatchMetricsQuerySqlOrderByParametersType `json:"type"`
} `json:"parameters,omitempty"`
Type CloudWatchMetricsQuerySqlOrderByType `json:"type"`
} `json:"orderBy,omitempty"`
// The sort order of the SQL expression, `ASC` or `DESC`
OrderByDirection *string `json:"orderByDirection,omitempty"`
// SELECT part of the SQL expression
Select *struct {
Name *string `json:"name,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type CloudWatchMetricsQuerySqlSelectParametersType `json:"type"`
} `json:"parameters,omitempty"`
Type CloudWatchMetricsQuerySqlSelectType `json:"type"`
} `json:"select,omitempty"`
// WHERE part of the SQL expression
Where *struct {
Expressions []CloudWatchMetricsQuerySqlWhereExpressionsItem `json:"expressions"`
Type CloudWatchMetricsQuerySqlWhereType `json:"type"`
} `json:"where,omitempty"`
} `json:"sql,omitempty"`
Region string `json:"region"`
Sql *SQLExpression `json:"sql,omitempty"`
// When the metric query type is `metricQueryType` is set to `Query`, this field is used to specify the query string.
SqlExpression *string `json:"sqlExpression,omitempty"`
@ -539,113 +301,34 @@ type CloudWatchMetricsQuery struct {
Statistics []string `json:"statistics,omitempty"`
}
// Whether to use the query builder or code editor to create the query
type CloudWatchMetricsQueryMetricEditorMode int
// Whether to use a metric search or metric query. Metric query is referred to as "Metrics Insights" in the AWS console.
type CloudWatchMetricsQueryMetricQueryType int
// Whether a query is a Metrics, Logs, or Annotations query
type CloudWatchMetricsQueryQueryMode string
// CloudWatchMetricsQuerySqlFromParametersType defines model for CloudWatchMetricsQuery.Sql.From.Parameters.Type.
type CloudWatchMetricsQuerySqlFromParametersType string
// CloudWatchMetricsQuerySqlFromPropertyType defines model for CloudWatchMetricsQuery.Sql.From.Property.Type.
type CloudWatchMetricsQuerySqlFromPropertyType string
// FROM part of the SQL expression
type CloudWatchMetricsQuerySqlFrom struct {
Name *string `json:"name,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type CloudWatchMetricsQuerySqlFromParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type CloudWatchMetricsQuerySqlFromPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
}
// CloudWatchMetricsQuerySqlGroupByExpressionsParametersType defines model for CloudWatchMetricsQuery.Sql.GroupBy.Expressions.Parameters.Type.
type CloudWatchMetricsQuerySqlGroupByExpressionsParametersType string
// CloudWatchMetricsQuerySqlGroupByExpressionsPropertyType defines model for CloudWatchMetricsQuery.Sql.GroupBy.Expressions.Property.Type.
type CloudWatchMetricsQuerySqlGroupByExpressionsPropertyType string
// CloudWatchMetricsQuerySqlGroupByExpressionsItem defines model for CloudWatchMetricsQuery.sql.groupBy.expressions.Item.
type CloudWatchMetricsQuerySqlGroupByExpressionsItem struct {
Expressions []interface{} `json:"expressions,omitempty"`
Name *string `json:"name,omitempty"`
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
Operator *struct {
Name *string `json:"name,omitempty"`
Value *interface{} `json:"value,omitempty"`
} `json:"operator,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type CloudWatchMetricsQuerySqlGroupByExpressionsParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type CloudWatchMetricsQuerySqlGroupByExpressionsPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
}
// CloudWatchMetricsQuerySqlGroupByType defines model for CloudWatchMetricsQuery.Sql.GroupBy.Type.
type CloudWatchMetricsQuerySqlGroupByType string
// CloudWatchMetricsQuerySqlOrderByParametersType defines model for CloudWatchMetricsQuery.Sql.OrderBy.Parameters.Type.
type CloudWatchMetricsQuerySqlOrderByParametersType string
// CloudWatchMetricsQuerySqlOrderByType defines model for CloudWatchMetricsQuery.Sql.OrderBy.Type.
type CloudWatchMetricsQuerySqlOrderByType string
// CloudWatchMetricsQuerySqlSelectParametersType defines model for CloudWatchMetricsQuery.Sql.Select.Parameters.Type.
type CloudWatchMetricsQuerySqlSelectParametersType string
// CloudWatchMetricsQuerySqlSelectType defines model for CloudWatchMetricsQuery.Sql.Select.Type.
type CloudWatchMetricsQuerySqlSelectType string
// CloudWatchMetricsQuerySqlWhereExpressionsParametersType defines model for CloudWatchMetricsQuery.Sql.Where.Expressions.Parameters.Type.
type CloudWatchMetricsQuerySqlWhereExpressionsParametersType string
// CloudWatchMetricsQuerySqlWhereExpressionsPropertyType defines model for CloudWatchMetricsQuery.Sql.Where.Expressions.Property.Type.
type CloudWatchMetricsQuerySqlWhereExpressionsPropertyType string
// CloudWatchMetricsQuerySqlWhereExpressionsItem defines model for CloudWatchMetricsQuery.sql.where.expressions.Item.
type CloudWatchMetricsQuerySqlWhereExpressionsItem struct {
Expressions []interface{} `json:"expressions,omitempty"`
Name *string `json:"name,omitempty"`
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
Operator *struct {
Name *string `json:"name,omitempty"`
Value *interface{} `json:"value,omitempty"`
} `json:"operator,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type CloudWatchMetricsQuerySqlWhereExpressionsParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type CloudWatchMetricsQuerySqlWhereExpressionsPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
}
// CloudWatchMetricsQuerySqlWhereType defines model for CloudWatchMetricsQuery.Sql.Where.Type.
type CloudWatchMetricsQuerySqlWhereType string
// CloudWatchQueryMode defines model for CloudWatchQueryMode.
type CloudWatchQueryMode string
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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"`
// 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"`
}
// A name/value pair that is part of the identity of a metric. For example, you can get statistics for a specific EC2 instance by specifying the InstanceId dimension when you search for metrics.
type Dimensions map[string]interface{}
@ -675,8 +358,8 @@ type MetricStat struct {
// The ID of the AWS account to query for the metric, specifying `all` will query all accounts that the monitoring account is permitted to query.
AccountId *string `json:"accountId,omitempty"`
// The dimensions of the metric
Dimensions map[string]interface{} `json:"dimensions,omitempty"`
// A name/value pair that is part of the identity of a metric. For example, you can get statistics for a specific EC2 instance by specifying the InstanceId dimension when you search for metrics.
Dimensions *Dimensions `json:"dimensions,omitempty"`
// Only show metrics that exactly match all defined dimension names.
MatchExact *bool `json:"matchExact,omitempty"`
@ -702,112 +385,23 @@ type MetricStat struct {
// QueryEditorArrayExpression defines model for QueryEditorArrayExpression.
type QueryEditorArrayExpression struct {
Expressions []QueryEditorArrayExpressionExpressionsItem `json:"expressions"`
Type QueryEditorArrayExpressionType `json:"type"`
}
// QueryEditorArrayExpressionExpressionsParametersType defines model for QueryEditorArrayExpression.Expressions.Parameters.Type.
type QueryEditorArrayExpressionExpressionsParametersType string
// QueryEditorArrayExpressionExpressionsPropertyType defines model for QueryEditorArrayExpression.Expressions.Property.Type.
type QueryEditorArrayExpressionExpressionsPropertyType string
// QueryEditorArrayExpressionExpressionsItem defines model for QueryEditorArrayExpression.expressions.Item.
type QueryEditorArrayExpressionExpressionsItem struct {
Expressions []interface{} `json:"expressions,omitempty"`
Name *string `json:"name,omitempty"`
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
Operator *struct {
Name *string `json:"name,omitempty"`
Value *interface{} `json:"value,omitempty"`
} `json:"operator,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type QueryEditorArrayExpressionExpressionsParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type QueryEditorArrayExpressionExpressionsPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
Expressions []interface{} `json:"expressions"`
Type QueryEditorArrayExpressionType `json:"type"`
}
// QueryEditorArrayExpressionType defines model for QueryEditorArrayExpression.Type.
type QueryEditorArrayExpressionType string
// QueryEditorExpression defines model for QueryEditorExpression.
type QueryEditorExpression struct {
Expressions []QueryEditorExpressionExpressionsItem `json:"expressions,omitempty"`
Name *string `json:"name,omitempty"`
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
Operator *struct {
Name *string `json:"name,omitempty"`
Value *interface{} `json:"value,omitempty"`
} `json:"operator,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type QueryEditorExpressionParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type QueryEditorExpressionPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
}
// QueryEditorExpressionExpressionsParametersType defines model for QueryEditorExpression.Expressions.Parameters.Type.
type QueryEditorExpressionExpressionsParametersType string
// QueryEditorExpressionExpressionsPropertyType defines model for QueryEditorExpression.Expressions.Property.Type.
type QueryEditorExpressionExpressionsPropertyType string
// QueryEditorExpressionExpressionsItem defines model for QueryEditorExpression.expressions.Item.
type QueryEditorExpressionExpressionsItem struct {
Name *string `json:"name,omitempty"`
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
Operator *struct {
Name *string `json:"name,omitempty"`
Value *interface{} `json:"value,omitempty"`
} `json:"operator,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type QueryEditorExpressionExpressionsParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type QueryEditorExpressionExpressionsPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
}
// QueryEditorExpressionParametersType defines model for QueryEditorExpression.Parameters.Type.
type QueryEditorExpressionParametersType string
// QueryEditorExpressionPropertyType defines model for QueryEditorExpression.Property.Type.
type QueryEditorExpressionPropertyType string
// QueryEditorExpressionType defines model for QueryEditorExpressionType.
type QueryEditorExpressionType string
// QueryEditorFunctionExpression defines model for QueryEditorFunctionExpression.
type QueryEditorFunctionExpression struct {
Name *string `json:"name,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type QueryEditorFunctionExpressionParametersType `json:"type"`
} `json:"parameters,omitempty"`
Type QueryEditorFunctionExpressionType `json:"type"`
Name *string `json:"name,omitempty"`
Parameters []QueryEditorFunctionParameterExpression `json:"parameters,omitempty"`
Type QueryEditorFunctionExpressionType `json:"type"`
}
// QueryEditorFunctionExpressionParametersType defines model for QueryEditorFunctionExpression.Parameters.Type.
type QueryEditorFunctionExpressionParametersType string
// QueryEditorFunctionExpressionType defines model for QueryEditorFunctionExpression.Type.
type QueryEditorFunctionExpressionType string
@ -822,16 +416,10 @@ type QueryEditorFunctionParameterExpressionType string
// QueryEditorGroupByExpression defines model for QueryEditorGroupByExpression.
type QueryEditorGroupByExpression struct {
Property struct {
Name *string `json:"name,omitempty"`
Type QueryEditorGroupByExpressionPropertyType `json:"type"`
} `json:"property"`
Type QueryEditorGroupByExpressionType `json:"type"`
Property QueryEditorProperty `json:"property"`
Type QueryEditorGroupByExpressionType `json:"type"`
}
// QueryEditorGroupByExpressionPropertyType defines model for QueryEditorGroupByExpression.Property.Type.
type QueryEditorGroupByExpressionPropertyType string
// QueryEditorGroupByExpressionType defines model for QueryEditorGroupByExpression.Type.
type QueryEditorGroupByExpressionType string
@ -843,21 +431,12 @@ type QueryEditorOperator struct {
// QueryEditorOperatorExpression defines model for QueryEditorOperatorExpression.
type QueryEditorOperatorExpression struct {
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
Operator struct {
Name *string `json:"name,omitempty"`
Value *interface{} `json:"value,omitempty"`
} `json:"operator"`
Property struct {
Name *string `json:"name,omitempty"`
Type QueryEditorOperatorExpressionPropertyType `json:"type"`
} `json:"property"`
Type QueryEditorOperatorExpressionType `json:"type"`
// TS type is QueryEditorOperator<T extends QueryEditorOperatorValueType>, extended in veneer
Operator QueryEditorOperator `json:"operator"`
Property QueryEditorProperty `json:"property"`
Type QueryEditorOperatorExpressionType `json:"type"`
}
// QueryEditorOperatorExpressionPropertyType defines model for QueryEditorOperatorExpression.Property.Type.
type QueryEditorOperatorExpressionPropertyType string
// QueryEditorOperatorExpressionType defines model for QueryEditorOperatorExpression.Type.
type QueryEditorOperatorExpressionType string
@ -867,159 +446,30 @@ type QueryEditorProperty struct {
Type QueryEditorPropertyType `json:"type"`
}
// QueryEditorPropertyType defines model for QueryEditorProperty.Type.
type QueryEditorPropertyType string
// QueryEditorPropertyExpression defines model for QueryEditorPropertyExpression.
type QueryEditorPropertyExpression struct {
Property struct {
Name *string `json:"name,omitempty"`
Type QueryEditorPropertyExpressionPropertyType `json:"type"`
} `json:"property"`
Type QueryEditorPropertyExpressionType `json:"type"`
Property QueryEditorProperty `json:"property"`
Type QueryEditorPropertyExpressionType `json:"type"`
}
// QueryEditorPropertyExpressionPropertyType defines model for QueryEditorPropertyExpression.Property.Type.
type QueryEditorPropertyExpressionPropertyType string
// QueryEditorPropertyExpressionType defines model for QueryEditorPropertyExpression.Type.
type QueryEditorPropertyExpressionType string
// QueryEditorPropertyType defines model for QueryEditorPropertyType.
type QueryEditorPropertyType string
// SQLExpression defines model for SQLExpression.
type SQLExpression struct {
// FROM part of the SQL expression
From *SQLExpressionFrom `json:"from,omitempty"`
// GROUP BY part of the SQL expression
GroupBy *struct {
Expressions []SQLExpressionGroupByExpressionsItem `json:"expressions"`
Type SQLExpressionGroupByType `json:"type"`
} `json:"groupBy,omitempty"`
From *interface{} `json:"from,omitempty"`
GroupBy *QueryEditorArrayExpression `json:"groupBy,omitempty"`
// LIMIT part of the SQL expression
Limit *int64 `json:"limit,omitempty"`
// ORDER BY part of the SQL expression
OrderBy *struct {
Name *string `json:"name,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type SQLExpressionOrderByParametersType `json:"type"`
} `json:"parameters,omitempty"`
Type SQLExpressionOrderByType `json:"type"`
} `json:"orderBy,omitempty"`
Limit *int64 `json:"limit,omitempty"`
OrderBy *QueryEditorFunctionExpression `json:"orderBy,omitempty"`
// The sort order of the SQL expression, `ASC` or `DESC`
OrderByDirection *string `json:"orderByDirection,omitempty"`
// SELECT part of the SQL expression
Select *struct {
Name *string `json:"name,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type SQLExpressionSelectParametersType `json:"type"`
} `json:"parameters,omitempty"`
Type SQLExpressionSelectType `json:"type"`
} `json:"select,omitempty"`
// WHERE part of the SQL expression
Where *struct {
Expressions []SQLExpressionWhereExpressionsItem `json:"expressions"`
Type SQLExpressionWhereType `json:"type"`
} `json:"where,omitempty"`
OrderByDirection *string `json:"orderByDirection,omitempty"`
Select *QueryEditorFunctionExpression `json:"select,omitempty"`
Where *QueryEditorArrayExpression `json:"where,omitempty"`
}
// SQLExpressionFromParametersType defines model for SQLExpression.From.Parameters.Type.
type SQLExpressionFromParametersType string
// SQLExpressionFromPropertyType defines model for SQLExpression.From.Property.Type.
type SQLExpressionFromPropertyType string
// FROM part of the SQL expression
type SQLExpressionFrom struct {
Name *string `json:"name,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type SQLExpressionFromParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type SQLExpressionFromPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
}
// SQLExpressionGroupByExpressionsParametersType defines model for SQLExpression.GroupBy.Expressions.Parameters.Type.
type SQLExpressionGroupByExpressionsParametersType string
// SQLExpressionGroupByExpressionsPropertyType defines model for SQLExpression.GroupBy.Expressions.Property.Type.
type SQLExpressionGroupByExpressionsPropertyType string
// SQLExpressionGroupByExpressionsItem defines model for SQLExpression.GroupBy.Expressions.Item.
type SQLExpressionGroupByExpressionsItem struct {
Expressions []interface{} `json:"expressions,omitempty"`
Name *string `json:"name,omitempty"`
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
Operator *struct {
Name *string `json:"name,omitempty"`
Value *interface{} `json:"value,omitempty"`
} `json:"operator,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type SQLExpressionGroupByExpressionsParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type SQLExpressionGroupByExpressionsPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
}
// SQLExpressionGroupByType defines model for SQLExpression.GroupBy.Type.
type SQLExpressionGroupByType string
// SQLExpressionOrderByParametersType defines model for SQLExpression.OrderBy.Parameters.Type.
type SQLExpressionOrderByParametersType string
// SQLExpressionOrderByType defines model for SQLExpression.OrderBy.Type.
type SQLExpressionOrderByType string
// SQLExpressionSelectParametersType defines model for SQLExpression.Select.Parameters.Type.
type SQLExpressionSelectParametersType string
// SQLExpressionSelectType defines model for SQLExpression.Select.Type.
type SQLExpressionSelectType string
// SQLExpressionWhereExpressionsParametersType defines model for SQLExpression.Where.Expressions.Parameters.Type.
type SQLExpressionWhereExpressionsParametersType string
// SQLExpressionWhereExpressionsPropertyType defines model for SQLExpression.Where.Expressions.Property.Type.
type SQLExpressionWhereExpressionsPropertyType string
// SQLExpressionWhereExpressionsItem defines model for SQLExpression.Where.Expressions.Item.
type SQLExpressionWhereExpressionsItem struct {
Expressions []interface{} `json:"expressions,omitempty"`
Name *string `json:"name,omitempty"`
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer
Operator *struct {
Name *string `json:"name,omitempty"`
Value *interface{} `json:"value,omitempty"`
} `json:"operator,omitempty"`
Parameters []struct {
Name *string `json:"name,omitempty"`
Type SQLExpressionWhereExpressionsParametersType `json:"type"`
} `json:"parameters,omitempty"`
Property *struct {
Name *string `json:"name,omitempty"`
Type SQLExpressionWhereExpressionsPropertyType `json:"type"`
} `json:"property,omitempty"`
Type *interface{} `json:"type,omitempty"`
union json.RawMessage
}
// SQLExpressionWhereType defines model for SQLExpression.Where.Type.
type SQLExpressionWhereType string

View File

@ -27,13 +27,13 @@ type (
)
const (
MetricEditorModeBuilder = dataquery.CloudWatchMetricsQueryMetricEditorModeN0
MetricEditorModeRaw = dataquery.CloudWatchMetricsQueryMetricEditorModeN1
MetricEditorModeBuilder = dataquery.MetricEditorModeN0
MetricEditorModeRaw = dataquery.MetricEditorModeN1
)
const (
MetricQueryTypeSearch = dataquery.CloudWatchMetricsQueryMetricQueryTypeN0
MetricQueryTypeQuery = dataquery.CloudWatchMetricsQueryMetricQueryTypeN1
MetricQueryTypeSearch = dataquery.MetricQueryTypeN0
MetricQueryTypeQuery = dataquery.MetricQueryTypeN1
)
const (
@ -67,8 +67,8 @@ type CloudWatchQuery struct {
MatchExact bool
UsedExpression string
TimezoneUTCOffset string
MetricQueryType dataquery.CloudWatchMetricsQueryMetricQueryType
MetricEditorMode dataquery.CloudWatchMetricsQueryMetricEditorMode
MetricQueryType dataquery.MetricQueryType
MetricEditorMode dataquery.MetricEditorMode
AccountId *string
}
@ -303,9 +303,12 @@ func (q *CloudWatchQuery) validateAndSetDefaults(refId string, metricsDataQuery
return err
}
q.Dimensions, err = parseDimensions(metricsDataQuery.Dimensions)
if err != nil {
return fmt.Errorf("failed to parse dimensions: %v", err)
q.Dimensions = map[string][]string{}
if metricsDataQuery.Dimensions != nil {
q.Dimensions, err = parseDimensions(*metricsDataQuery.Dimensions)
if err != nil {
return fmt.Errorf("failed to parse dimensions: %v", err)
}
}
if crossAccountQueryingEnabled {

View File

@ -7,9 +7,10 @@ import (
"testing"
"time"
"github.com/grafana/kindsys"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
"github.com/grafana/kindsys"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -590,11 +591,11 @@ func Test_ParseMetricDataQueries_periods(t *testing.T) {
}
func Test_ParseMetricDataQueries_query_type_and_metric_editor_mode_and_GMD_query_api_mode(t *testing.T) {
const dummyTestEditorMode dataquery.CloudWatchMetricsQueryMetricEditorMode = 99
const dummyTestEditorMode dataquery.MetricEditorMode = 99
testCases := map[string]struct {
extraDataQueryJson string
expectedMetricQueryType dataquery.CloudWatchMetricsQueryMetricQueryType
expectedMetricEditorMode dataquery.CloudWatchMetricsQueryMetricEditorMode
expectedMetricQueryType dataquery.MetricQueryType
expectedMetricEditorMode dataquery.MetricEditorMode
expectedGMDApiMode GMDApiMode
}{
"no metric query type, no metric editor mode, no expression": {
@ -901,7 +902,7 @@ func Test_migrateAliasToDynamicLabel_single_query_preserves_old_alias_and_create
Namespace: "ec2",
MetricName: kindsys.Ptr("CPUUtilization"),
Alias: kindsys.Ptr(tc.inputAlias),
Dimensions: map[string]interface{}{
Dimensions: &dataquery.Dimensions{
"InstanceId": []interface{}{"test"},
},
Statistic: &average,

View File

@ -269,15 +269,15 @@ type queryDimensions struct {
}
type queryParameters struct {
MetricQueryType dataquery.CloudWatchMetricsQueryMetricQueryType `json:"metricQueryType"`
MetricEditorMode dataquery.CloudWatchMetricsQueryMetricEditorMode `json:"metricEditorMode"`
Dimensions queryDimensions `json:"dimensions"`
Expression string `json:"expression"`
Label *string `json:"label"`
Statistic string `json:"statistic"`
Period string `json:"period"`
MatchExact bool `json:"matchExact"`
MetricName string `json:"metricName"`
MetricQueryType dataquery.MetricQueryType `json:"metricQueryType"`
MetricEditorMode dataquery.MetricEditorMode `json:"metricEditorMode"`
Dimensions queryDimensions `json:"dimensions"`
Expression string `json:"expression"`
Label *string `json:"label"`
Statistic string `json:"statistic"`
Period string `json:"period"`
MatchExact bool `json:"matchExact"`
MetricName string `json:"metricName"`
}
var queryId = "query id"
@ -286,11 +286,11 @@ func newTestQuery(t testing.TB, p queryParameters) json.RawMessage {
t.Helper()
tsq := struct {
Type string `json:"type"`
MetricQueryType dataquery.CloudWatchMetricsQueryMetricQueryType `json:"metricQueryType"`
MetricEditorMode dataquery.CloudWatchMetricsQueryMetricEditorMode `json:"metricEditorMode"`
Namespace string `json:"namespace"`
MetricName string `json:"metricName"`
Type string `json:"type"`
MetricQueryType dataquery.MetricQueryType `json:"metricQueryType"`
MetricEditorMode dataquery.MetricEditorMode `json:"metricEditorMode"`
Namespace string `json:"namespace"`
MetricName string `json:"metricName"`
Dimensions struct {
InstanceID []string `json:"InstanceId,omitempty"`
} `json:"dimensions"`

File diff suppressed because it is too large Load Diff

View File

@ -9,12 +9,6 @@
package dataquery
// Defines values for EditorMode.
const (
EditorModeBuilder EditorMode = "builder"
EditorModeCode EditorMode = "code"
)
// Defines values for LokiQueryDirection.
const (
LokiQueryDirectionBackward LokiQueryDirection = "backward"
@ -41,14 +35,44 @@ const (
SupportingQueryTypeLogsVolume SupportingQueryType = "logsVolume"
)
// LokiDataQuery defines model for LokiDataQuery.
type LokiDataQuery struct {
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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"`
EditorMode *EditorMode `json:"editorMode,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"`
// 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"`
}
// LokiDataQuery defines model for LokiDataQuery.
type LokiDataQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// 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"`
EditorMode *QueryEditorMode `json:"editorMode,omitempty"`
// The LogQL query.
Expr string `json:"expr"`
@ -83,9 +107,6 @@ type LokiDataQuery struct {
Resolution *int64 `json:"resolution,omitempty"`
}
// EditorMode defines model for LokiDataQuery.EditorMode.
type EditorMode string
// LokiQueryDirection defines model for LokiQueryDirection.
type LokiQueryDirection string

View File

@ -16,8 +16,38 @@ const (
ParcaQueryTypeProfile ParcaQueryType = "profile"
)
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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"`
// 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"`
}
// ParcaDataQuery defines model for ParcaDataQuery.
type ParcaDataQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// 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

View File

@ -16,8 +16,38 @@ const (
PhlareQueryTypeProfile PhlareQueryType = "profile"
)
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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"`
// 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"`
}
// GrafanaPyroscopeDataQuery defines model for GrafanaPyroscopeDataQuery.
type GrafanaPyroscopeDataQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// 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

View File

@ -16,47 +16,60 @@ const (
PromQueryFormatTimeSeries PromQueryFormat = "time_series"
)
// Defines values for EditorMode.
const (
EditorModeBuilder EditorMode = "builder"
EditorModeCode EditorMode = "code"
)
// Defines values for Format.
const (
FormatHeatmap Format = "heatmap"
FormatTable Format = "table"
FormatTimeSeries Format = "time_series"
)
// Defines values for QueryEditorMode.
const (
QueryEditorModeBuilder QueryEditorMode = "builder"
QueryEditorModeCode QueryEditorMode = "code"
)
// PromQueryFormat defines model for PromQueryFormat.
type PromQueryFormat string
// PrometheusDataQuery defines model for PrometheusDataQuery.
type PrometheusDataQuery struct {
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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"`
// Specifies which editor is being used to prepare the query. It can be "code" or "builder"
EditorMode *EditorMode `json:"editorMode,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"`
// 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"`
}
// PromQueryFormat defines model for PromQueryFormat.
type PromQueryFormat string
// PrometheusDataQuery defines model for PrometheusDataQuery.
type PrometheusDataQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// 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"`
EditorMode *QueryEditorMode `json:"editorMode,omitempty"`
// Execute an additional query to identify interesting raw samples relevant for the given expr
Exemplar *bool `json:"exemplar,omitempty"`
// The actual expression/query that will be evaluated by Prometheus
Expr string `json:"expr"`
// Query format to determine how to display data points in panel. It can be "time_series", "table", "heatmap"
Format *Format `json:"format,omitempty"`
Expr string `json:"expr"`
Format *PromQueryFormat `json:"format,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
@ -86,11 +99,5 @@ type PrometheusDataQuery struct {
RefId string `json:"refId"`
}
// Specifies which editor is being used to prepare the query. It can be "code" or "builder"
type EditorMode string
// Query format to determine how to display data points in panel. It can be "time_series", "table", "heatmap"
type Format string
// QueryEditorMode defines model for QueryEditorMode.
type QueryEditorMode string

View File

@ -9,13 +9,6 @@
package dataquery
// Defines values for TempoQueryFiltersScope.
const (
TempoQueryFiltersScopeResource TempoQueryFiltersScope = "resource"
TempoQueryFiltersScopeSpan TempoQueryFiltersScope = "span"
TempoQueryFiltersScopeUnscoped TempoQueryFiltersScope = "unscoped"
)
// Defines values for TempoQueryType.
const (
TempoQueryTypeClear TempoQueryType = "clear"
@ -27,13 +20,6 @@ const (
TempoQueryTypeUpload TempoQueryType = "upload"
)
// Defines values for TraceqlFilterScope.
const (
TraceqlFilterScopeResource TraceqlFilterScope = "resource"
TraceqlFilterScopeSpan TraceqlFilterScope = "span"
TraceqlFilterScopeUnscoped TraceqlFilterScope = "unscoped"
)
// Defines values for TraceqlSearchScope.
const (
TraceqlSearchScopeResource TraceqlSearchScope = "resource"
@ -41,35 +27,47 @@ const (
TraceqlSearchScopeUnscoped TraceqlSearchScope = "unscoped"
)
// TempoDataQuery defines model for TempoDataQuery.
type TempoDataQuery = map[string]interface{}
// TempoQuery defines model for TempoQuery.
type TempoQuery struct {
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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"`
Filters []struct {
// Uniquely identify the filter, will not be used in the query generation
Id string `json:"id"`
// The operator that connects the tag to the value, for example: =, >, !=, =~
Operator *string `json:"operator,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"`
// The scope of the filter, can either be unscoped/all scopes, resource or span
Scope *TempoQueryFiltersScope `json:"scope,omitempty"`
// Specify the query flavor
// TODO make this required and give it a default
QueryType *string `json:"queryType,omitempty"`
// The tag for the search filter, for example: .http.status_code, .service.name, status
Tag *string `json:"tag,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"`
}
// The value for the search filter
Value *interface{} `json:"value,omitempty"`
// TempoDataQuery defines model for TempoDataQuery.
type TempoDataQuery = map[string]interface{}
// The type of the value, used for example to check whether we need to wrap the value in quotes when generating the query
ValueType *string `json:"valueType,omitempty"`
} `json:"filters"`
// TempoQuery defines model for TempoQuery.
type TempoQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// 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"`
Filters []TraceqlFilter `json:"filters"`
// 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
@ -110,9 +108,6 @@ type TempoQuery struct {
SpanName *string `json:"spanName,omitempty"`
}
// The scope of the filter, can either be unscoped/all scopes, resource or span
type TempoQueryFiltersScope string
// TempoQueryType search = Loki search, nativeSearch = Tempo search for backwards compatibility
type TempoQueryType string
@ -124,8 +119,8 @@ type TraceqlFilter struct {
// The operator that connects the tag to the value, for example: =, >, !=, =~
Operator *string `json:"operator,omitempty"`
// The scope of the filter, can either be unscoped/all scopes, resource or span
Scope *TraceqlFilterScope `json:"scope,omitempty"`
// Scope static fields are pre-set in the UI, dynamic fields are added by the user
Scope *TraceqlSearchScope `json:"scope,omitempty"`
// The tag for the search filter, for example: .http.status_code, .service.name, status
Tag *string `json:"tag,omitempty"`
@ -137,8 +132,5 @@ type TraceqlFilter struct {
ValueType *string `json:"valueType,omitempty"`
}
// The scope of the filter, can either be unscoped/all scopes, resource or span
type TraceqlFilterScope string
// TraceqlSearchScope static fields are pre-set in the UI, dynamic fields are added by the user
type TraceqlSearchScope string

View File

@ -30,53 +30,6 @@ const (
ErrorTypeServerPanic ErrorType = "server_panic"
)
// Defines values for NodesType.
const (
NodesTypeRandom NodesType = "random"
NodesTypeRandomEdges NodesType = "random edges"
NodesTypeResponse NodesType = "response"
)
// Defines values for ScenarioId.
const (
ScenarioIdAnnotations ScenarioId = "annotations"
ScenarioIdArrow ScenarioId = "arrow"
ScenarioIdCsvContent ScenarioId = "csv_content"
ScenarioIdCsvFile ScenarioId = "csv_file"
ScenarioIdCsvMetricValues ScenarioId = "csv_metric_values"
ScenarioIdDatapointsOutsideRange ScenarioId = "datapoints_outside_range"
ScenarioIdExponentialHeatmapBucketData ScenarioId = "exponential_heatmap_bucket_data"
ScenarioIdFlameGraph ScenarioId = "flame_graph"
ScenarioIdGrafanaApi ScenarioId = "grafana_api"
ScenarioIdLinearHeatmapBucketData ScenarioId = "linear_heatmap_bucket_data"
ScenarioIdLive ScenarioId = "live"
ScenarioIdLogs ScenarioId = "logs"
ScenarioIdManualEntry ScenarioId = "manual_entry"
ScenarioIdNoDataPoints ScenarioId = "no_data_points"
ScenarioIdNodeGraph ScenarioId = "node_graph"
ScenarioIdPredictableCsvWave ScenarioId = "predictable_csv_wave"
ScenarioIdPredictablePulse ScenarioId = "predictable_pulse"
ScenarioIdRandomWalk ScenarioId = "random_walk"
ScenarioIdRandomWalkTable ScenarioId = "random_walk_table"
ScenarioIdRandomWalkWithError ScenarioId = "random_walk_with_error"
ScenarioIdRawFrame ScenarioId = "raw_frame"
ScenarioIdServerError500 ScenarioId = "server_error_500"
ScenarioIdSimulation ScenarioId = "simulation"
ScenarioIdSlowQuery ScenarioId = "slow_query"
ScenarioIdStreamingClient ScenarioId = "streaming_client"
ScenarioIdTableStatic ScenarioId = "table_static"
ScenarioIdTrace ScenarioId = "trace"
ScenarioIdUsa ScenarioId = "usa"
ScenarioIdVariablesQuery ScenarioId = "variables-query"
)
// Defines values for StreamType.
const (
StreamTypeFetch StreamType = "fetch"
StreamTypeLogs StreamType = "logs"
StreamTypeSignal StreamType = "signal"
)
// Defines values for TestDataQueryType.
const (
TestDataQueryTypeAnnotations TestDataQueryType = "annotations"
@ -118,6 +71,31 @@ type CSVWave struct {
ValuesCSV *string `json:"valuesCSV,omitempty"`
}
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// 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"`
// 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"`
}
// NodesQuery defines model for NodesQuery.
type NodesQuery struct {
Count *int64 `json:"count,omitempty"`
@ -172,95 +150,35 @@ type StreamingQueryType string
// TestDataDataQuery defines model for TestDataDataQuery.
type TestDataDataQuery struct {
Alias *string `json:"alias,omitempty"`
Channel *string `json:"channel,omitempty"`
CsvContent *string `json:"csvContent,omitempty"`
CsvFileName *string `json:"csvFileName,omitempty"`
CsvWave []struct {
Labels *string `json:"labels,omitempty"`
Name *string `json:"name,omitempty"`
TimeStep *int64 `json:"timeStep,omitempty"`
ValuesCSV *string `json:"valuesCSV,omitempty"`
} `json:"csvWave,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"`
ErrorType *ErrorType `json:"errorType,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"`
Labels *string `json:"labels,omitempty"`
LevelColumn *bool `json:"levelColumn,omitempty"`
Lines *int64 `json:"lines,omitempty"`
Nodes *struct {
Count *int64 `json:"count,omitempty"`
Type *NodesType `json:"type,omitempty"`
} `json:"nodes,omitempty"`
Points [][]interface{} `json:"points,omitempty"`
PulseWave *struct {
OffCount *int64 `json:"offCount,omitempty"`
OffValue *float64 `json:"offValue,omitempty"`
OnCount *int64 `json:"onCount,omitempty"`
OnValue *float64 `json:"onValue,omitempty"`
TimeStep *int64 `json:"timeStep,omitempty"`
} `json:"pulseWave,omitempty"`
// Specify the query flavor
// TODO make this required and give it a default
QueryType *string `json:"queryType,omitempty"`
RawFrameContent *string `json:"rawFrameContent,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"`
ScenarioId *ScenarioId `json:"scenarioId,omitempty"`
SeriesCount *int32 `json:"seriesCount,omitempty"`
Sim *struct {
Config map[string]interface{} `json:"config,omitempty"`
Key struct {
Tick float64 `json:"tick"`
Type string `json:"type"`
Uid *string `json:"uid,omitempty"`
} `json:"key"`
Last *bool `json:"last,omitempty"`
Stream *bool `json:"stream,omitempty"`
} `json:"sim,omitempty"`
SpanCount *int32 `json:"spanCount,omitempty"`
Stream *struct {
Bands *int32 `json:"bands,omitempty"`
Noise int32 `json:"noise"`
Speed int32 `json:"speed"`
Spread int32 `json:"spread"`
Type StreamType `json:"type"`
Url *string `json:"url,omitempty"`
} `json:"stream,omitempty"`
StringInput *string `json:"stringInput,omitempty"`
Usa *struct {
Fields []string `json:"fields,omitempty"`
Mode *string `json:"mode,omitempty"`
Period *string `json:"period,omitempty"`
States []string `json:"states,omitempty"`
} `json:"usa,omitempty"`
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
Alias *string `json:"alias,omitempty"`
Channel *string `json:"channel,omitempty"`
CsvContent *string `json:"csvContent,omitempty"`
CsvFileName *string `json:"csvFileName,omitempty"`
CsvWave []CSVWave `json:"csvWave,omitempty"`
ErrorType *ErrorType `json:"errorType,omitempty"`
Labels *string `json:"labels,omitempty"`
LevelColumn *bool `json:"levelColumn,omitempty"`
Lines *int64 `json:"lines,omitempty"`
Nodes *NodesQuery `json:"nodes,omitempty"`
Points [][]interface{} `json:"points,omitempty"`
PulseWave *PulseWaveQuery `json:"pulseWave,omitempty"`
RawFrameContent *string `json:"rawFrameContent,omitempty"`
ScenarioId *TestDataQueryType `json:"scenarioId,omitempty"`
SeriesCount *int32 `json:"seriesCount,omitempty"`
Sim *SimulationQuery `json:"sim,omitempty"`
SpanCount *int32 `json:"spanCount,omitempty"`
Stream *StreamingQuery `json:"stream,omitempty"`
StringInput *string `json:"stringInput,omitempty"`
Usa *USAQuery `json:"usa,omitempty"`
}
// ErrorType defines model for TestDataDataQuery.ErrorType.
type ErrorType string
// NodesType defines model for TestDataDataQuery.Nodes.Type.
type NodesType string
// ScenarioId defines model for TestDataDataQuery.ScenarioId.
type ScenarioId string
// StreamType defines model for TestDataDataQuery.Stream.Type.
type StreamType string
// TestDataQueryType defines model for TestDataQueryType.
type TestDataQueryType string