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
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/dataplane/sdata v0.0.6
github.com/grafana/go-mssqldb v0.9.1 github.com/grafana/go-mssqldb v0.9.1
github.com/grafana/kindsys v0.0.0-20230508162304-452481b63482 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/ory/fosite v0.44.1-0.20230317114349-45a6785cc54f
github.com/redis/go-redis/v9 v9.0.2 github.com/redis/go-redis/v9 v9.0.2
github.com/weaveworks/common v0.0.0-20230208133027-16871410fca4 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/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 h1:HWKhE0vR6LoEiE+Is8CSZOgaB//D1yqb2ntkass9Fd4=
github.com/grafana/sqlds/v2 v2.3.10/go.mod h1:c6ibxnxRVGxV/0YkEgvy7QpQH/lyifFyV7K/14xvdIs= 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-20230524160113-4e9d6e28a640 h1:kFCq4pmBB61xzTHen/TNttd5hNlkeqGfqU9usmCc81U=
github.com/grafana/thema v0.0.0-20230523123227-db9596a7096e/go.mod h1:Pn9nfzCk7nV0mvNgwusgCjCROZP6nm4GpwTnmEhLT24= 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 h1:I9dh1MXGX0wGyxdV/Sl7+ugnki4Dfsy8lv2s5Yf887o=
github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6/go.mod h1:ZkJLEYLoVyg7amJK/5r779bHyzs2AU8f8VMiP6BM7uY= 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= 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{ Config: &openapi.Config{
Group: decl.SchemaInterface.IsGroup(), Group: decl.SchemaInterface.IsGroup(),
Config: &copenapi.Config{ Config: &copenapi.Config{
ExpandReferences: true, MaxCycleDepth: 10,
MaxCycleDepth: 10,
}, },
SplitSchema: true,
}, },
PackageName: slotname, PackageName: slotname,
ApplyFuncs: []dstutil.ApplyFunc{corecodegen.PrefixDropper(decl.Lineage.Name())}, ApplyFuncs: []dstutil.ApplyFunc{corecodegen.PrefixDropper(decl.Lineage.Name())},

View File

@@ -9,10 +9,6 @@
package dataquery package dataquery
import (
"encoding/json"
)
// Defines values for AppInsightsGroupByQueryKind. // Defines values for AppInsightsGroupByQueryKind.
const ( const (
AppInsightsGroupByQueryKindAppInsightsGroupByQuery AppInsightsGroupByQueryKind = "AppInsightsGroupByQuery" AppInsightsGroupByQueryKindAppInsightsGroupByQuery AppInsightsGroupByQueryKind = "AppInsightsGroupByQuery"
@@ -23,27 +19,6 @@ const (
AppInsightsMetricNameQueryKindAppInsightsMetricNameQuery AppInsightsMetricNameQueryKind = "AppInsightsMetricNameQuery" 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. // Defines values for AzureQueryType.
const ( const (
AzureQueryTypeAzureLogAnalytics AzureQueryType = "Azure Log Analytics" AzureQueryTypeAzureLogAnalytics AzureQueryType = "Azure Log Analytics"
@@ -60,13 +35,6 @@ const (
AzureQueryTypeGrafanaTemplateVariableFunction AzureQueryType = "Grafana Template Variable Function" 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. // Defines values for GrafanaTemplateVariableQueryType.
const ( const (
GrafanaTemplateVariableQueryTypeAppInsightsGroupByQuery GrafanaTemplateVariableQueryType = "AppInsightsGroupByQuery" GrafanaTemplateVariableQueryTypeAppInsightsGroupByQuery GrafanaTemplateVariableQueryType = "AppInsightsGroupByQuery"
@@ -129,10 +97,10 @@ const (
// AppInsightsGroupByQuery defines model for AppInsightsGroupByQuery. // AppInsightsGroupByQuery defines model for AppInsightsGroupByQuery.
type AppInsightsGroupByQuery struct { type AppInsightsGroupByQuery struct {
Kind AppInsightsGroupByQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
MetricName string `json:"metricName"` Kind AppInsightsGroupByQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"` MetricName string `json:"metricName"`
AdditionalProperties map[string]interface{} `json:"-"` RawQuery *string `json:"rawQuery,omitempty"`
} }
// AppInsightsGroupByQueryKind defines model for AppInsightsGroupByQuery.Kind. // AppInsightsGroupByQueryKind defines model for AppInsightsGroupByQuery.Kind.
@@ -140,9 +108,9 @@ type AppInsightsGroupByQueryKind string
// AppInsightsMetricNameQuery defines model for AppInsightsMetricNameQuery. // AppInsightsMetricNameQuery defines model for AppInsightsMetricNameQuery.
type AppInsightsMetricNameQuery struct { type AppInsightsMetricNameQuery struct {
Kind AppInsightsMetricNameQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
RawQuery *string `json:"rawQuery,omitempty"` Kind AppInsightsMetricNameQueryKind `json:"kind"`
AdditionalProperties map[string]interface{} `json:"-"` RawQuery *string `json:"rawQuery,omitempty"`
} }
// AppInsightsMetricNameQueryKind defines model for AppInsightsMetricNameQuery.Kind. // AppInsightsMetricNameQueryKind defines model for AppInsightsMetricNameQuery.Kind.
@@ -157,18 +125,13 @@ type AzureLogsQuery struct {
Resource *string `json:"resource,omitempty"` Resource *string `json:"resource,omitempty"`
// Array of resource URIs to be queried. // Array of resource URIs to be queried.
Resources []string `json:"resources,omitempty"` Resources []string `json:"resources,omitempty"`
ResultFormat *ResultFormat `json:"resultFormat,omitempty"`
// Specifies the format results should be returned as.
ResultFormat *AzureLogsQueryResultFormat `json:"resultFormat,omitempty"`
// Workspace ID. This was removed in Grafana 8, but remains for backwards compat // Workspace ID. This was removed in Grafana 8, but remains for backwards compat
Workspace *string `json:"workspace,omitempty"` Workspace *string `json:"workspace,omitempty"`
} }
// Specifies the format results should be returned as.
type AzureLogsQueryResultFormat string
// AzureMetricDimension defines model for AzureMetricDimension. // AzureMetricDimension defines model for AzureMetricDimension.
type AzureMetricDimension struct { type AzureMetricDimension struct {
// Name of Dimension to be filtered on. // Name of Dimension to be filtered on.
@@ -205,19 +168,7 @@ type AzureMetricQuery struct {
DimensionFilter *string `json:"dimensionFilter,omitempty"` DimensionFilter *string `json:"dimensionFilter,omitempty"`
// Filters to reduce the set of data returned. Dimensions that can be filtered on are defined by the metric. // Filters to reduce the set of data returned. Dimensions that can be filtered on are defined by the metric.
DimensionFilters []struct { DimensionFilters []AzureMetricDimension `json:"dimensionFilters,omitempty"`
// 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 // @deprecated Use metricNamespace instead
MetricDefinition *string `json:"metricDefinition,omitempty"` MetricDefinition *string `json:"metricDefinition,omitempty"`
@@ -243,13 +194,7 @@ type AzureMetricQuery struct {
ResourceUri *string `json:"resourceUri,omitempty"` ResourceUri *string `json:"resourceUri,omitempty"`
// Array of resource URIs to be queried. // Array of resource URIs to be queried.
Resources []struct { Resources []AzureMonitorResource `json:"resources,omitempty"`
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. // The granularity of data points to be queried. Defaults to auto.
TimeGrain *string `json:"timeGrain,omitempty"` TimeGrain *string `json:"timeGrain,omitempty"`
@@ -266,163 +211,20 @@ type AzureMonitorDataQuery = map[string]interface{}
// AzureMonitorQuery defines model for AzureMonitorQuery. // AzureMonitorQuery defines model for AzureMonitorQuery.
type AzureMonitorQuery struct { type AzureMonitorQuery struct {
// Azure Monitor Logs sub-query properties. // DataQuery These are the common properties available to all queries in all datasources.
AzureLogAnalytics *struct { // Specific implementations will *extend* this interface, adding the required
// KQL query to be executed. // properties for the given context.
Query *string `json:"query,omitempty"` DataQuery
// @deprecated Use resources instead // Azure Monitor Logs sub-query properties
Resource *string `json:"resource,omitempty"` AzureLogAnalytics *AzureLogsQuery `json:"azureLogAnalytics,omitempty"`
AzureMonitor *AzureMetricQuery `json:"azureMonitor,omitempty"`
AzureResourceGraph *AzureResourceGraphQuery `json:"azureResourceGraph,omitempty"`
// Array of resource URIs to be queried. // Application Insights Traces sub-query properties
Resources []string `json:"resources,omitempty"` AzureTraces *AzureTracesQuery `json:"azureTraces,omitempty"`
GrafanaTemplateVariableFn *interface{} `json:"grafanaTemplateVariableFn,omitempty"`
// Specifies the format results should be returned as. Namespace *string `json:"namespace,omitempty"`
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"`
// Azure Monitor query type. // Azure Monitor query type.
// queryType: #AzureQueryType // queryType: #AzureQueryType
@@ -439,25 +241,6 @@ type AzureMonitorQuery struct {
Subscriptions []string `json:"subscriptions,omitempty"` 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. // AzureMonitorResource defines model for AzureMonitorResource.
type AzureMonitorResource struct { type AzureMonitorResource struct {
MetricNamespace *string `json:"metricNamespace,omitempty"` MetricNamespace *string `json:"metricNamespace,omitempty"`
@@ -494,16 +277,7 @@ type AzureTracesFilter struct {
// Application Insights Traces sub-query properties // Application Insights Traces sub-query properties
type AzureTracesQuery struct { type AzureTracesQuery struct {
// Filters for property values. // Filters for property values.
Filters []struct { Filters []AzureTracesFilter `json:"filters,omitempty"`
// 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. // Operation ID. Used only for Traces queries.
OperationId *string `json:"operationId,omitempty"` OperationId *string `json:"operationId,omitempty"`
@@ -512,49 +286,55 @@ type AzureTracesQuery struct {
Query *string `json:"query,omitempty"` Query *string `json:"query,omitempty"`
// Array of resource URIs to be queried. // Array of resource URIs to be queried.
Resources []string `json:"resources,omitempty"` Resources []string `json:"resources,omitempty"`
ResultFormat *ResultFormat `json:"resultFormat,omitempty"`
// Specifies the format results should be returned as.
ResultFormat *AzureTracesQueryResultFormat `json:"resultFormat,omitempty"`
// Types of events to filter by. // Types of events to filter by.
TraceTypes []string `json:"traceTypes,omitempty"` TraceTypes []string `json:"traceTypes,omitempty"`
} }
// Specifies the format results should be returned as.
type AzureTracesQueryResultFormat string
// BaseGrafanaTemplateVariableQuery defines model for BaseGrafanaTemplateVariableQuery. // BaseGrafanaTemplateVariableQuery defines model for BaseGrafanaTemplateVariableQuery.
type BaseGrafanaTemplateVariableQuery struct { type BaseGrafanaTemplateVariableQuery struct {
RawQuery *string `json:"rawQuery,omitempty"` RawQuery *string `json:"rawQuery,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
} }
// GrafanaTemplateVariableQuery defines model for GrafanaTemplateVariableQuery. // These are the common properties available to all queries in all datasources.
type GrafanaTemplateVariableQuery struct { // Specific implementations will *extend* this interface, adding the required
Kind *interface{} `json:"kind,omitempty"` // properties for the given context.
MetricName *string `json:"metricName,omitempty"` type DataQuery struct {
MetricNamespace *string `json:"metricNamespace,omitempty"` // For mixed data sources the selected datasource is on the query level.
RawQuery *string `json:"rawQuery,omitempty"` // For non mixed scenarios this is undefined.
ResourceGroup *string `json:"resourceGroup,omitempty"` // TODO find a better way to do this ^ that's friendly to schema
ResourceName *string `json:"resourceName,omitempty"` // TODO this shouldn't be unknown but DataSourceRef | null
Subscription *string `json:"subscription,omitempty"` Datasource *interface{} `json:"datasource,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
union json.RawMessage // 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. // GrafanaTemplateVariableQueryType defines model for GrafanaTemplateVariableQueryType.
type GrafanaTemplateVariableQueryType string type GrafanaTemplateVariableQueryType string
// @deprecated Use MetricNamespaceQuery instead // MetricDefinitionsQuery defines model for MetricDefinitionsQuery.
type MetricDefinitionsQuery struct { type MetricDefinitionsQuery struct {
Kind MetricDefinitionsQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
MetricNamespace *string `json:"metricNamespace,omitempty"` Kind MetricDefinitionsQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"` MetricNamespace *string `json:"metricNamespace,omitempty"`
ResourceGroup string `json:"resourceGroup"` RawQuery *string `json:"rawQuery,omitempty"`
ResourceName *string `json:"resourceName,omitempty"` ResourceGroup string `json:"resourceGroup"`
Subscription string `json:"subscription"` ResourceName *string `json:"resourceName,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"` Subscription string `json:"subscription"`
} }
// MetricDefinitionsQueryKind defines model for MetricDefinitionsQuery.Kind. // MetricDefinitionsQueryKind defines model for MetricDefinitionsQuery.Kind.
@@ -562,13 +342,13 @@ type MetricDefinitionsQueryKind string
// MetricNamesQuery defines model for MetricNamesQuery. // MetricNamesQuery defines model for MetricNamesQuery.
type MetricNamesQuery struct { type MetricNamesQuery struct {
Kind MetricNamesQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
MetricNamespace string `json:"metricNamespace"` Kind MetricNamesQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"` MetricNamespace string `json:"metricNamespace"`
ResourceGroup string `json:"resourceGroup"` RawQuery *string `json:"rawQuery,omitempty"`
ResourceName string `json:"resourceName"` ResourceGroup string `json:"resourceGroup"`
Subscription string `json:"subscription"` ResourceName string `json:"resourceName"`
AdditionalProperties map[string]interface{} `json:"-"` Subscription string `json:"subscription"`
} }
// MetricNamesQueryKind defines model for MetricNamesQuery.Kind. // MetricNamesQueryKind defines model for MetricNamesQuery.Kind.
@@ -576,13 +356,13 @@ type MetricNamesQueryKind string
// MetricNamespaceQuery defines model for MetricNamespaceQuery. // MetricNamespaceQuery defines model for MetricNamespaceQuery.
type MetricNamespaceQuery struct { type MetricNamespaceQuery struct {
Kind MetricNamespaceQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
MetricNamespace *string `json:"metricNamespace,omitempty"` Kind MetricNamespaceQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"` MetricNamespace *string `json:"metricNamespace,omitempty"`
ResourceGroup string `json:"resourceGroup"` RawQuery *string `json:"rawQuery,omitempty"`
ResourceName *string `json:"resourceName,omitempty"` ResourceGroup string `json:"resourceGroup"`
Subscription string `json:"subscription"` ResourceName *string `json:"resourceName,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"` Subscription string `json:"subscription"`
} }
// MetricNamespaceQueryKind defines model for MetricNamespaceQuery.Kind. // MetricNamespaceQueryKind defines model for MetricNamespaceQuery.Kind.
@@ -590,10 +370,10 @@ type MetricNamespaceQueryKind string
// ResourceGroupsQuery defines model for ResourceGroupsQuery. // ResourceGroupsQuery defines model for ResourceGroupsQuery.
type ResourceGroupsQuery struct { type ResourceGroupsQuery struct {
Kind ResourceGroupsQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
RawQuery *string `json:"rawQuery,omitempty"` Kind ResourceGroupsQueryKind `json:"kind"`
Subscription string `json:"subscription"` RawQuery *string `json:"rawQuery,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"` Subscription string `json:"subscription"`
} }
// ResourceGroupsQueryKind defines model for ResourceGroupsQuery.Kind. // ResourceGroupsQueryKind defines model for ResourceGroupsQuery.Kind.
@@ -601,12 +381,12 @@ type ResourceGroupsQueryKind string
// ResourceNamesQuery defines model for ResourceNamesQuery. // ResourceNamesQuery defines model for ResourceNamesQuery.
type ResourceNamesQuery struct { type ResourceNamesQuery struct {
Kind ResourceNamesQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
MetricNamespace string `json:"metricNamespace"` Kind ResourceNamesQueryKind `json:"kind"`
RawQuery *string `json:"rawQuery,omitempty"` MetricNamespace string `json:"metricNamespace"`
ResourceGroup string `json:"resourceGroup"` RawQuery *string `json:"rawQuery,omitempty"`
Subscription string `json:"subscription"` ResourceGroup string `json:"resourceGroup"`
AdditionalProperties map[string]interface{} `json:"-"` Subscription string `json:"subscription"`
} }
// ResourceNamesQueryKind defines model for ResourceNamesQuery.Kind. // ResourceNamesQueryKind defines model for ResourceNamesQuery.Kind.
@@ -617,9 +397,9 @@ type ResultFormat string
// SubscriptionsQuery defines model for SubscriptionsQuery. // SubscriptionsQuery defines model for SubscriptionsQuery.
type SubscriptionsQuery struct { type SubscriptionsQuery struct {
Kind SubscriptionsQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
RawQuery *string `json:"rawQuery,omitempty"` Kind SubscriptionsQueryKind `json:"kind"`
AdditionalProperties map[string]interface{} `json:"-"` RawQuery *string `json:"rawQuery,omitempty"`
} }
// SubscriptionsQueryKind defines model for SubscriptionsQuery.Kind. // SubscriptionsQueryKind defines model for SubscriptionsQuery.Kind.
@@ -627,9 +407,9 @@ type SubscriptionsQueryKind string
// UnknownQuery defines model for UnknownQuery. // UnknownQuery defines model for UnknownQuery.
type UnknownQuery struct { type UnknownQuery struct {
Kind UnknownQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
RawQuery *string `json:"rawQuery,omitempty"` Kind UnknownQueryKind `json:"kind"`
AdditionalProperties map[string]interface{} `json:"-"` RawQuery *string `json:"rawQuery,omitempty"`
} }
// UnknownQueryKind defines model for UnknownQuery.Kind. // UnknownQueryKind defines model for UnknownQuery.Kind.
@@ -637,10 +417,10 @@ type UnknownQueryKind string
// WorkspacesQuery defines model for WorkspacesQuery. // WorkspacesQuery defines model for WorkspacesQuery.
type WorkspacesQuery struct { type WorkspacesQuery struct {
Kind WorkspacesQueryKind `json:"kind"` BaseGrafanaTemplateVariableQuery
RawQuery *string `json:"rawQuery,omitempty"` Kind WorkspacesQueryKind `json:"kind"`
Subscription string `json:"subscription"` RawQuery *string `json:"rawQuery,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"` Subscription string `json:"subscription"`
} }
// WorkspacesQueryKind defines model for WorkspacesQuery.Kind. // 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 { if azureTracesTarget.ResultFormat == nil {
resultFormat = types.Table resultFormat = types.Table
} else { } else {
resultFormat = string(*azureTracesTarget.ResultFormat) resultFormat = *azureTracesTarget.ResultFormat
if resultFormat == "" { if resultFormat == "" {
resultFormat = types.Table resultFormat = types.Table
} }
@@ -351,7 +351,7 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, logger l
return dataResponse return dataResponse
} }
traceIdVariable := "${__data.fields.traceID}" traceIdVariable := "${__data.fields.traceID}"
resultFormat := dataquery.AzureMonitorQueryAzureTracesResultFormatTrace resultFormat := dataquery.ResultFormatTrace
queryJSONModel.AzureTraces.ResultFormat = &resultFormat queryJSONModel.AzureTraces.ResultFormat = &resultFormat
queryJSONModel.AzureTraces.Query = &query.TraceExploreQuery queryJSONModel.AzureTraces.Query = &query.TraceExploreQuery
if queryJSONModel.AzureTraces.OperationId == nil || *queryJSONModel.AzureTraces.OperationId == "" { 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) logsQueryType := string(dataquery.AzureQueryTypeAzureLogAnalytics)
logsJSONModel := dataquery.AzureMonitorQuery{ logsJSONModel := dataquery.AzureMonitorQuery{
AzureLogAnalytics: &struct { DataQuery: dataquery.DataQuery{
Query *string "json:\"query,omitempty\"" QueryType: &logsQueryType,
Resource *string "json:\"resource,omitempty\"" },
Resources []string "json:\"resources,omitempty\"" AzureLogAnalytics: &dataquery.AzureLogsQuery{
ResultFormat *dataquery.AzureMonitorQueryAzureLogAnalyticsResultFormat "json:\"resultFormat,omitempty\"" Query: &query.TraceLogsExploreQuery,
Workspace *string "json:\"workspace,omitempty\"" Resources: []string{queryJSONModel.AzureTraces.Resources[0]},
}{
Resources: []string{queryJSONModel.AzureTraces.Resources[0]},
Query: &query.TraceLogsExploreQuery,
}, },
QueryType: &logsQueryType,
} }
if query.ResultFormat == string(dataquery.AzureMonitorQueryAzureTracesResultFormatTable) { if query.ResultFormat == string(dataquery.ResultFormatTable) {
AddCustomDataLink(*frame, data.DataLink{ AddCustomDataLink(*frame, data.DataLink{
Title: "Explore Trace: ${__data.fields.traceID}", Title: "Explore Trace: ${__data.fields.traceID}",
URL: "", URL: "",

View File

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

View File

@@ -9,10 +9,6 @@
package dataquery package dataquery
import (
"encoding/json"
)
// Defines values for AlignmentTypes. // Defines values for AlignmentTypes.
const ( const (
AlignmentTypesALIGNCOUNT AlignmentTypes = "ALIGN_COUNT" AlignmentTypesALIGNCOUNT AlignmentTypes = "ALIGN_COUNT"
@@ -36,28 +32,6 @@ const (
AlignmentTypesALIGNSUM AlignmentTypes = "ALIGN_SUM" 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. // Defines values for MetricFindQueryTypes.
const ( const (
MetricFindQueryTypesAggregations MetricFindQueryTypes = "aggregations" MetricFindQueryTypesAggregations MetricFindQueryTypes = "aggregations"
@@ -83,21 +57,6 @@ const (
MetricKindMETRICKINDUNSPECIFIED MetricKind = "METRIC_KIND_UNSPECIFIED" 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. // Defines values for PreprocessorType.
const ( const (
PreprocessorTypeDelta PreprocessorType = "delta" PreprocessorTypeDelta PreprocessorType = "delta"
@@ -113,13 +72,6 @@ const (
QueryTypeTimeSeriesQuery QueryType = "timeSeriesQuery" QueryTypeTimeSeriesQuery QueryType = "timeSeriesQuery"
) )
// Defines values for TimeSeriesListPreprocessor.
const (
TimeSeriesListPreprocessorDelta TimeSeriesListPreprocessor = "delta"
TimeSeriesListPreprocessorNone TimeSeriesListPreprocessor = "none"
TimeSeriesListPreprocessorRate TimeSeriesListPreprocessor = "rate"
)
// Defines values for ValueTypes. // Defines values for ValueTypes.
const ( const (
ValueTypesBOOL ValueTypes = "BOOL" ValueTypesBOOL ValueTypes = "BOOL"
@@ -136,58 +88,45 @@ type AlignmentTypes string
// Annotation sub-query properties. // Annotation sub-query properties.
type AnnotationQuery struct { type AnnotationQuery struct {
// Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto. // TimeSeriesList Time Series List sub-query properties.
AlignmentPeriod *string `json:"alignmentPeriod,omitempty"` TimeSeriesList
// Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
CrossSeriesReducer string `json:"crossSeriesReducer"`
// Array of filters to query data by. Labels that can be filtered on are defined by the metric.
Filters []string `json:"filters,omitempty"`
// Array of labels to group data by.
GroupBys []string `json:"groupBys,omitempty"`
// Alignment function to be used. Defaults to ALIGN_MEAN.
PerSeriesAligner *string `json:"perSeriesAligner,omitempty"`
// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
Preprocessor *AnnotationQueryPreprocessor `json:"preprocessor,omitempty"`
// GCP project to execute the query against.
ProjectName string `json:"projectName"`
// Only present if a preprocessor is selected. Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
SecondaryAlignmentPeriod *string `json:"secondaryAlignmentPeriod,omitempty"`
// Only present if a preprocessor is selected. Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
SecondaryCrossSeriesReducer *string `json:"secondaryCrossSeriesReducer,omitempty"`
// Only present if a preprocessor is selected. Array of labels to group data by.
SecondaryGroupBys []string `json:"secondaryGroupBys,omitempty"`
// Only present if a preprocessor is selected. Alignment function to be used. Defaults to ALIGN_MEAN.
SecondaryPerSeriesAligner *string `json:"secondaryPerSeriesAligner,omitempty"`
// Annotation text. // Annotation text.
Text *string `json:"text,omitempty"` Text *string `json:"text,omitempty"`
// Annotation title. // Annotation title.
Title *string `json:"title,omitempty"` 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. // CloudMonitoringQuery defines model for CloudMonitoringQuery.
type CloudMonitoringQuery struct { 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. // Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.
AliasBy *string `json:"aliasBy,omitempty"` 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 mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined. // For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema // 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) // the results from a hidden query may be used as the input to other queries (SSE etc)
Hide *bool `json:"hide,omitempty"` Hide *bool `json:"hide,omitempty"`
// Time interval in milliseconds.
IntervalMs *float32 `json:"intervalMs,omitempty"`
// Specify the query flavor // Specify the query flavor
// TODO make this required and give it a default // TODO make this required and give it a default
QueryType *string `json:"queryType,omitempty"` 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. // 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. // By default, the UI will assign A->Z; however setting meaningful names may be useful.
RefId string `json:"refId"` 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. // Query filter representation.
@@ -335,9 +169,9 @@ type GoogleCloudMonitoringDataQuery = map[string]interface{}
// @deprecated Use AnnotationQuery instead. Legacy annotation query properties for migration purposes. // @deprecated Use AnnotationQuery instead. Legacy annotation query properties for migration purposes.
type LegacyCloudMonitoringAnnotationQuery struct { type LegacyCloudMonitoringAnnotationQuery struct {
// Array of filters to query data by. Labels that can be filtered on are defined by the metric. // Array of filters to query data by. Labels that can be filtered on are defined by the metric.
Filters []string `json:"filters"` Filters []string `json:"filters"`
MetricKind LegacyCloudMonitoringAnnotationQueryMetricKind `json:"metricKind"` MetricKind MetricKind `json:"metricKind"`
MetricType string `json:"metricType"` MetricType string `json:"metricType"`
// GCP project to execute the query against. // GCP project to execute the query against.
ProjectName string `json:"projectName"` ProjectName string `json:"projectName"`
@@ -353,9 +187,6 @@ type LegacyCloudMonitoringAnnotationQuery struct {
ValueType string `json:"valueType"` ValueType string `json:"valueType"`
} }
// LegacyCloudMonitoringAnnotationQueryMetricKind defines model for LegacyCloudMonitoringAnnotationQuery.MetricKind.
type LegacyCloudMonitoringAnnotationQueryMetricKind string
// MetricFindQueryTypes defines model for MetricFindQueryTypes. // MetricFindQueryTypes defines model for MetricFindQueryTypes.
type MetricFindQueryTypes string type MetricFindQueryTypes string
@@ -381,15 +212,15 @@ type MetricQuery struct {
GraphPeriod *string `json:"graphPeriod,omitempty"` GraphPeriod *string `json:"graphPeriod,omitempty"`
// Array of labels to group data by. // Array of labels to group data by.
GroupBys []string `json:"groupBys,omitempty"` GroupBys []string `json:"groupBys,omitempty"`
MetricKind *MetricQueryMetricKind `json:"metricKind,omitempty"` MetricKind *MetricKind `json:"metricKind,omitempty"`
MetricType string `json:"metricType"` MetricType string `json:"metricType"`
// Alignment function to be used. Defaults to ALIGN_MEAN. // Alignment function to be used. Defaults to ALIGN_MEAN.
PerSeriesAligner *string `json:"perSeriesAligner,omitempty"` 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 // Types of pre-processor available. Defined by the metric.
Preprocessor *MetricQueryPreprocessor `json:"preprocessor,omitempty"` Preprocessor *PreprocessorType `json:"preprocessor,omitempty"`
// GCP project to execute the query against. // GCP project to execute the query against.
ProjectName string `json:"projectName"` ProjectName string `json:"projectName"`
@@ -400,12 +231,6 @@ type MetricQuery struct {
View *string `json:"view,omitempty"` View *string `json:"view,omitempty"`
} }
// MetricQueryMetricKind defines model for MetricQuery.MetricKind.
type MetricQueryMetricKind string
// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
type MetricQueryPreprocessor string
// Types of pre-processor available. Defined by the metric. // Types of pre-processor available. Defined by the metric.
type PreprocessorType string type PreprocessorType string
@@ -462,8 +287,8 @@ type TimeSeriesList struct {
// Alignment function to be used. Defaults to ALIGN_MEAN. // Alignment function to be used. Defaults to ALIGN_MEAN.
PerSeriesAligner *string `json:"perSeriesAligner,omitempty"` 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 // Types of pre-processor available. Defined by the metric.
Preprocessor *TimeSeriesListPreprocessor `json:"preprocessor,omitempty"` Preprocessor *PreprocessorType `json:"preprocessor,omitempty"`
// GCP project to execute the query against. // GCP project to execute the query against.
ProjectName string `json:"projectName"` ProjectName string `json:"projectName"`
@@ -481,13 +306,9 @@ type TimeSeriesList struct {
SecondaryPerSeriesAligner *string `json:"secondaryPerSeriesAligner,omitempty"` SecondaryPerSeriesAligner *string `json:"secondaryPerSeriesAligner,omitempty"`
// Data view, defaults to FULL. // Data view, defaults to FULL.
View *string `json:"view,omitempty"` View *string `json:"view,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
} }
// Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
type TimeSeriesListPreprocessor string
// Time Series sub-query properties. // Time Series sub-query properties.
type TimeSeriesQuery struct { type TimeSeriesQuery struct {
// To disable the graphPeriod, it should explictly be set to 'disabled'. // 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/aws/aws-sdk-go/service/cloudwatch"
"github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data" "github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
) )
type annotationEvent struct { type annotationEvent struct {
@@ -59,6 +60,12 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
if model.MetricName != nil { if model.MetricName != nil {
metricName = *model.MetricName metricName = *model.MetricName
} }
dimensions := dataquery.Dimensions{}
if model.Dimensions != nil {
dimensions = *model.Dimensions
}
if prefixMatching { if prefixMatching {
params := &cloudwatch.DescribeAlarmsInput{ params := &cloudwatch.DescribeAlarmsInput{
MaxRecords: aws.Int64(100), MaxRecords: aws.Int64(100),
@@ -69,14 +76,14 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
if err != nil { if err != nil {
return nil, fmt.Errorf("%v: %w", "failed to call cloudwatch:DescribeAlarms", err) 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 { } else {
if model.Region == "" || model.Namespace == "" || metricName == "" || statistic == "" { if model.Region == "" || model.Namespace == "" || metricName == "" || statistic == "" {
return result, errors.New("invalid annotations query") return result, errors.New("invalid annotations query")
} }
var qd []*cloudwatch.Dimension var qd []*cloudwatch.Dimension
for k, v := range model.Dimensions { for k, v := range dimensions {
if vv, ok := v.([]interface{}); ok { if vv, ok := v.([]interface{}); ok {
for _, vvv := range vv { for _, vvv := range vv {
if vvvv, ok := vvv.(string); ok { if vvvv, ok := vvv.(string); ok {

View File

@@ -9,105 +9,6 @@
package dataquery 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. // Defines values for CloudWatchQueryMode.
const ( const (
CloudWatchQueryModeAnnotations CloudWatchQueryMode = "Annotations" CloudWatchQueryModeAnnotations CloudWatchQueryMode = "Annotations"
@@ -127,42 +28,12 @@ const (
MetricQueryTypeN1 MetricQueryType = 1 MetricQueryTypeN1 MetricQueryType = 1
) )
// Defines values for QueryEditorArrayExpressionExpressionsParametersType.
const (
QueryEditorArrayExpressionExpressionsParametersTypeFunctionParameter QueryEditorArrayExpressionExpressionsParametersType = "functionParameter"
)
// Defines values for QueryEditorArrayExpressionExpressionsPropertyType.
const (
QueryEditorArrayExpressionExpressionsPropertyTypeString QueryEditorArrayExpressionExpressionsPropertyType = "string"
)
// Defines values for QueryEditorArrayExpressionType. // Defines values for QueryEditorArrayExpressionType.
const ( const (
QueryEditorArrayExpressionTypeAnd QueryEditorArrayExpressionType = "and" QueryEditorArrayExpressionTypeAnd QueryEditorArrayExpressionType = "and"
QueryEditorArrayExpressionTypeOr QueryEditorArrayExpressionType = "or" 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. // Defines values for QueryEditorExpressionType.
const ( const (
QueryEditorExpressionTypeAnd QueryEditorExpressionType = "and" QueryEditorExpressionTypeAnd QueryEditorExpressionType = "and"
@@ -174,39 +45,59 @@ const (
QueryEditorExpressionTypeProperty QueryEditorExpressionType = "property" QueryEditorExpressionTypeProperty QueryEditorExpressionType = "property"
) )
// Defines values for QueryEditorFunctionExpressionParametersType.
const (
QueryEditorFunctionExpressionParametersTypeFunctionParameter QueryEditorFunctionExpressionParametersType = "functionParameter"
)
// Defines values for QueryEditorFunctionExpressionType. // Defines values for QueryEditorFunctionExpressionType.
const ( 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. // Defines values for QueryEditorFunctionParameterExpressionType.
const ( const (
QueryEditorFunctionParameterExpressionTypeAnd QueryEditorFunctionParameterExpressionType = "and"
QueryEditorFunctionParameterExpressionTypeFunction QueryEditorFunctionParameterExpressionType = "function"
QueryEditorFunctionParameterExpressionTypeFunctionParameter QueryEditorFunctionParameterExpressionType = "functionParameter" QueryEditorFunctionParameterExpressionTypeFunctionParameter QueryEditorFunctionParameterExpressionType = "functionParameter"
) QueryEditorFunctionParameterExpressionTypeGroupBy QueryEditorFunctionParameterExpressionType = "groupBy"
QueryEditorFunctionParameterExpressionTypeOperator QueryEditorFunctionParameterExpressionType = "operator"
// Defines values for QueryEditorGroupByExpressionPropertyType. QueryEditorFunctionParameterExpressionTypeOr QueryEditorFunctionParameterExpressionType = "or"
const ( QueryEditorFunctionParameterExpressionTypeProperty QueryEditorFunctionParameterExpressionType = "property"
QueryEditorGroupByExpressionPropertyTypeString QueryEditorGroupByExpressionPropertyType = "string"
) )
// Defines values for QueryEditorGroupByExpressionType. // Defines values for QueryEditorGroupByExpressionType.
const ( const (
QueryEditorGroupByExpressionTypeGroupBy QueryEditorGroupByExpressionType = "groupBy" QueryEditorGroupByExpressionTypeAnd QueryEditorGroupByExpressionType = "and"
) QueryEditorGroupByExpressionTypeFunction QueryEditorGroupByExpressionType = "function"
QueryEditorGroupByExpressionTypeFunctionParameter QueryEditorGroupByExpressionType = "functionParameter"
// Defines values for QueryEditorOperatorExpressionPropertyType. QueryEditorGroupByExpressionTypeGroupBy QueryEditorGroupByExpressionType = "groupBy"
const ( QueryEditorGroupByExpressionTypeOperator QueryEditorGroupByExpressionType = "operator"
QueryEditorOperatorExpressionPropertyTypeString QueryEditorOperatorExpressionPropertyType = "string" QueryEditorGroupByExpressionTypeOr QueryEditorGroupByExpressionType = "or"
QueryEditorGroupByExpressionTypeProperty QueryEditorGroupByExpressionType = "property"
) )
// Defines values for QueryEditorOperatorExpressionType. // Defines values for QueryEditorOperatorExpressionType.
const ( 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. // Defines values for QueryEditorPropertyType.
@@ -214,83 +105,14 @@ const (
QueryEditorPropertyTypeString QueryEditorPropertyType = "string" QueryEditorPropertyTypeString QueryEditorPropertyType = "string"
) )
// Defines values for QueryEditorPropertyExpressionPropertyType. // CloudWatchAnnotationQuery defines model for CloudWatchAnnotationQuery.
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")
type CloudWatchAnnotationQuery struct { 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. // 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"` AccountId *string `json:"accountId,omitempty"`
@@ -312,8 +134,8 @@ type CloudWatchAnnotationQuery struct {
// TODO this shouldn't be unknown but DataSourceRef | null // TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"` Datasource *interface{} `json:"datasource,omitempty"`
// The dimensions of the metric // 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 map[string]interface{} `json:"dimensions,omitempty"` Dimensions *Dimensions `json:"dimensions,omitempty"`
// Hide true if query is disabled (ie should not be returned to the dashboard) // 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 // 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"` 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 // 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"` PrefixMatching *bool `json:"prefixMatching,omitempty"`
QueryMode CloudWatchQueryMode `json:"queryMode"`
// Whether a query is a Metrics, Logs, or Annotations query
QueryMode CloudWatchAnnotationQueryQueryMode `json:"queryMode"`
// Specify the query flavor // Specify the query flavor
// TODO make this required and give it a default // TODO make this required and give it a default
@@ -357,14 +177,16 @@ type CloudWatchAnnotationQuery struct {
Statistics []string `json:"statistics,omitempty"` Statistics []string `json:"statistics,omitempty"`
} }
// Whether a query is a Metrics, Logs, or Annotations query
type CloudWatchAnnotationQueryQueryMode string
// CloudWatchDataQuery defines model for CloudWatchDataQuery. // CloudWatchDataQuery defines model for CloudWatchDataQuery.
type CloudWatchDataQuery = map[string]interface{} type CloudWatchDataQuery = map[string]interface{}
// Shape of a CloudWatch Logs query // CloudWatchLogsQuery defines model for CloudWatchLogsQuery.
type CloudWatchLogsQuery struct { 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 mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined. // For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema // 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"` LogGroupNames []string `json:"logGroupNames,omitempty"`
// Log groups to query // Log groups to query
LogGroups []struct { LogGroups []LogGroup `json:"logGroups,omitempty"`
// AccountId of the log group QueryMode CloudWatchQueryMode `json:"queryMode"`
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"`
// Specify the query flavor // Specify the query flavor
// TODO make this required and give it a default // TODO make this required and give it a default
@@ -417,11 +225,14 @@ type CloudWatchLogsQuery struct {
StatsGroups []string `json:"statsGroups,omitempty"` StatsGroups []string `json:"statsGroups,omitempty"`
} }
// Whether a query is a Metrics, Logs, or Annotations query // CloudWatchMetricsQuery defines model for CloudWatchMetricsQuery.
type CloudWatchLogsQueryQueryMode string
// Shape of a CloudWatch Metrics query
type CloudWatchMetricsQuery struct { 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. // 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"` AccountId *string `json:"accountId,omitempty"`
@@ -435,8 +246,8 @@ type CloudWatchMetricsQuery struct {
// TODO this shouldn't be unknown but DataSourceRef | null // TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"` Datasource *interface{} `json:"datasource,omitempty"`
// The dimensions of the metric // 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 map[string]interface{} `json:"dimensions,omitempty"` Dimensions *Dimensions `json:"dimensions,omitempty"`
// Math expression query // Math expression query
Expression *string `json:"expression,omitempty"` Expression *string `json:"expression,omitempty"`
@@ -453,25 +264,19 @@ type CloudWatchMetricsQuery struct {
Label *string `json:"label,omitempty"` Label *string `json:"label,omitempty"`
// Only show metrics that exactly match all defined dimension names. // Only show metrics that exactly match all defined dimension names.
MatchExact *bool `json:"matchExact,omitempty"` MatchExact *bool `json:"matchExact,omitempty"`
MetricEditorMode *MetricEditorMode `json:"metricEditorMode,omitempty"`
// Whether to use the query builder or code editor to create the query
MetricEditorMode *CloudWatchMetricsQueryMetricEditorMode `json:"metricEditorMode,omitempty"`
// Name of the metric // Name of the metric
MetricName *string `json:"metricName,omitempty"` MetricName *string `json:"metricName,omitempty"`
MetricQueryType *MetricQueryType `json:"metricQueryType,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"`
// 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. // 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"` 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 // 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"` Period *string `json:"period,omitempty"`
QueryMode *CloudWatchQueryMode `json:"queryMode,omitempty"`
// Whether a query is a Metrics, Logs, or Annotations query
QueryMode *CloudWatchMetricsQueryQueryMode `json:"queryMode,omitempty"`
// Specify the query flavor // Specify the query flavor
// TODO make this required and give it a default // TODO make this required and give it a default
@@ -483,51 +288,8 @@ type CloudWatchMetricsQuery struct {
RefId string `json:"refId"` RefId string `json:"refId"`
// AWS region to query for the metric // AWS region to query for the metric
Region string `json:"region"` Region string `json:"region"`
Sql *SQLExpression `json:"sql,omitempty"`
// 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"`
// When the metric query type is `metricQueryType` is set to `Query`, this field is used to specify the query string. // 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"` SqlExpression *string `json:"sqlExpression,omitempty"`
@@ -539,113 +301,34 @@ type CloudWatchMetricsQuery struct {
Statistics []string `json:"statistics,omitempty"` 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. // CloudWatchQueryMode defines model for CloudWatchQueryMode.
type CloudWatchQueryMode string 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. // 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{} 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. // 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"` AccountId *string `json:"accountId,omitempty"`
// The dimensions of the metric // 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 map[string]interface{} `json:"dimensions,omitempty"` Dimensions *Dimensions `json:"dimensions,omitempty"`
// Only show metrics that exactly match all defined dimension names. // Only show metrics that exactly match all defined dimension names.
MatchExact *bool `json:"matchExact,omitempty"` MatchExact *bool `json:"matchExact,omitempty"`
@@ -702,112 +385,23 @@ type MetricStat struct {
// QueryEditorArrayExpression defines model for QueryEditorArrayExpression. // QueryEditorArrayExpression defines model for QueryEditorArrayExpression.
type QueryEditorArrayExpression struct { type QueryEditorArrayExpression struct {
Expressions []QueryEditorArrayExpressionExpressionsItem `json:"expressions"` Expressions []interface{} `json:"expressions"`
Type QueryEditorArrayExpressionType `json:"type"` 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
} }
// QueryEditorArrayExpressionType defines model for QueryEditorArrayExpression.Type. // QueryEditorArrayExpressionType defines model for QueryEditorArrayExpression.Type.
type QueryEditorArrayExpressionType string 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. // QueryEditorExpressionType defines model for QueryEditorExpressionType.
type QueryEditorExpressionType string type QueryEditorExpressionType string
// QueryEditorFunctionExpression defines model for QueryEditorFunctionExpression. // QueryEditorFunctionExpression defines model for QueryEditorFunctionExpression.
type QueryEditorFunctionExpression struct { type QueryEditorFunctionExpression struct {
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
Parameters []struct { Parameters []QueryEditorFunctionParameterExpression `json:"parameters,omitempty"`
Name *string `json:"name,omitempty"` Type QueryEditorFunctionExpressionType `json:"type"`
Type QueryEditorFunctionExpressionParametersType `json:"type"`
} `json:"parameters,omitempty"`
Type QueryEditorFunctionExpressionType `json:"type"`
} }
// QueryEditorFunctionExpressionParametersType defines model for QueryEditorFunctionExpression.Parameters.Type.
type QueryEditorFunctionExpressionParametersType string
// QueryEditorFunctionExpressionType defines model for QueryEditorFunctionExpression.Type. // QueryEditorFunctionExpressionType defines model for QueryEditorFunctionExpression.Type.
type QueryEditorFunctionExpressionType string type QueryEditorFunctionExpressionType string
@@ -822,16 +416,10 @@ type QueryEditorFunctionParameterExpressionType string
// QueryEditorGroupByExpression defines model for QueryEditorGroupByExpression. // QueryEditorGroupByExpression defines model for QueryEditorGroupByExpression.
type QueryEditorGroupByExpression struct { type QueryEditorGroupByExpression struct {
Property struct { Property QueryEditorProperty `json:"property"`
Name *string `json:"name,omitempty"` Type QueryEditorGroupByExpressionType `json:"type"`
Type QueryEditorGroupByExpressionPropertyType `json:"type"`
} `json:"property"`
Type QueryEditorGroupByExpressionType `json:"type"`
} }
// QueryEditorGroupByExpressionPropertyType defines model for QueryEditorGroupByExpression.Property.Type.
type QueryEditorGroupByExpressionPropertyType string
// QueryEditorGroupByExpressionType defines model for QueryEditorGroupByExpression.Type. // QueryEditorGroupByExpressionType defines model for QueryEditorGroupByExpression.Type.
type QueryEditorGroupByExpressionType string type QueryEditorGroupByExpressionType string
@@ -843,21 +431,12 @@ type QueryEditorOperator struct {
// QueryEditorOperatorExpression defines model for QueryEditorOperatorExpression. // QueryEditorOperatorExpression defines model for QueryEditorOperatorExpression.
type QueryEditorOperatorExpression struct { type QueryEditorOperatorExpression struct {
// TS type is operator: QueryEditorOperator<QueryEditorOperatorValueType>, extended in veneer // TS type is QueryEditorOperator<T extends QueryEditorOperatorValueType>, extended in veneer
Operator struct { Operator QueryEditorOperator `json:"operator"`
Name *string `json:"name,omitempty"` Property QueryEditorProperty `json:"property"`
Value *interface{} `json:"value,omitempty"` Type QueryEditorOperatorExpressionType `json:"type"`
} `json:"operator"`
Property struct {
Name *string `json:"name,omitempty"`
Type QueryEditorOperatorExpressionPropertyType `json:"type"`
} `json:"property"`
Type QueryEditorOperatorExpressionType `json:"type"`
} }
// QueryEditorOperatorExpressionPropertyType defines model for QueryEditorOperatorExpression.Property.Type.
type QueryEditorOperatorExpressionPropertyType string
// QueryEditorOperatorExpressionType defines model for QueryEditorOperatorExpression.Type. // QueryEditorOperatorExpressionType defines model for QueryEditorOperatorExpression.Type.
type QueryEditorOperatorExpressionType string type QueryEditorOperatorExpressionType string
@@ -867,159 +446,30 @@ type QueryEditorProperty struct {
Type QueryEditorPropertyType `json:"type"` Type QueryEditorPropertyType `json:"type"`
} }
// QueryEditorPropertyType defines model for QueryEditorProperty.Type.
type QueryEditorPropertyType string
// QueryEditorPropertyExpression defines model for QueryEditorPropertyExpression. // QueryEditorPropertyExpression defines model for QueryEditorPropertyExpression.
type QueryEditorPropertyExpression struct { type QueryEditorPropertyExpression struct {
Property struct { Property QueryEditorProperty `json:"property"`
Name *string `json:"name,omitempty"` Type QueryEditorPropertyExpressionType `json:"type"`
Type QueryEditorPropertyExpressionPropertyType `json:"type"`
} `json:"property"`
Type QueryEditorPropertyExpressionType `json:"type"`
} }
// QueryEditorPropertyExpressionPropertyType defines model for QueryEditorPropertyExpression.Property.Type.
type QueryEditorPropertyExpressionPropertyType string
// QueryEditorPropertyExpressionType defines model for QueryEditorPropertyExpression.Type. // QueryEditorPropertyExpressionType defines model for QueryEditorPropertyExpression.Type.
type QueryEditorPropertyExpressionType string type QueryEditorPropertyExpressionType string
// QueryEditorPropertyType defines model for QueryEditorPropertyType.
type QueryEditorPropertyType string
// SQLExpression defines model for SQLExpression. // SQLExpression defines model for SQLExpression.
type SQLExpression struct { type SQLExpression struct {
// FROM part of the SQL expression // FROM part of the SQL expression
From *SQLExpressionFrom `json:"from,omitempty"` From *interface{} `json:"from,omitempty"`
GroupBy *QueryEditorArrayExpression `json:"groupBy,omitempty"`
// GROUP BY part of the SQL expression
GroupBy *struct {
Expressions []SQLExpressionGroupByExpressionsItem `json:"expressions"`
Type SQLExpressionGroupByType `json:"type"`
} `json:"groupBy,omitempty"`
// LIMIT part of the SQL expression // LIMIT part of the SQL expression
Limit *int64 `json:"limit,omitempty"` Limit *int64 `json:"limit,omitempty"`
OrderBy *QueryEditorFunctionExpression `json:"orderBy,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"`
// The sort order of the SQL expression, `ASC` or `DESC` // The sort order of the SQL expression, `ASC` or `DESC`
OrderByDirection *string `json:"orderByDirection,omitempty"` OrderByDirection *string `json:"orderByDirection,omitempty"`
Select *QueryEditorFunctionExpression `json:"select,omitempty"`
// SELECT part of the SQL expression Where *QueryEditorArrayExpression `json:"where,omitempty"`
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"`
} }
// 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 ( const (
MetricEditorModeBuilder = dataquery.CloudWatchMetricsQueryMetricEditorModeN0 MetricEditorModeBuilder = dataquery.MetricEditorModeN0
MetricEditorModeRaw = dataquery.CloudWatchMetricsQueryMetricEditorModeN1 MetricEditorModeRaw = dataquery.MetricEditorModeN1
) )
const ( const (
MetricQueryTypeSearch = dataquery.CloudWatchMetricsQueryMetricQueryTypeN0 MetricQueryTypeSearch = dataquery.MetricQueryTypeN0
MetricQueryTypeQuery = dataquery.CloudWatchMetricsQueryMetricQueryTypeN1 MetricQueryTypeQuery = dataquery.MetricQueryTypeN1
) )
const ( const (
@@ -67,8 +67,8 @@ type CloudWatchQuery struct {
MatchExact bool MatchExact bool
UsedExpression string UsedExpression string
TimezoneUTCOffset string TimezoneUTCOffset string
MetricQueryType dataquery.CloudWatchMetricsQueryMetricQueryType MetricQueryType dataquery.MetricQueryType
MetricEditorMode dataquery.CloudWatchMetricsQueryMetricEditorMode MetricEditorMode dataquery.MetricEditorMode
AccountId *string AccountId *string
} }
@@ -303,9 +303,12 @@ func (q *CloudWatchQuery) validateAndSetDefaults(refId string, metricsDataQuery
return err return err
} }
q.Dimensions, err = parseDimensions(metricsDataQuery.Dimensions) q.Dimensions = map[string][]string{}
if err != nil { if metricsDataQuery.Dimensions != nil {
return fmt.Errorf("failed to parse dimensions: %v", err) q.Dimensions, err = parseDimensions(*metricsDataQuery.Dimensions)
if err != nil {
return fmt.Errorf("failed to parse dimensions: %v", err)
}
} }
if crossAccountQueryingEnabled { if crossAccountQueryingEnabled {

View File

@@ -7,9 +7,10 @@ import (
"testing" "testing"
"time" "time"
"github.com/grafana/kindsys"
"github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery" "github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
"github.com/grafana/kindsys"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "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) { 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 { testCases := map[string]struct {
extraDataQueryJson string extraDataQueryJson string
expectedMetricQueryType dataquery.CloudWatchMetricsQueryMetricQueryType expectedMetricQueryType dataquery.MetricQueryType
expectedMetricEditorMode dataquery.CloudWatchMetricsQueryMetricEditorMode expectedMetricEditorMode dataquery.MetricEditorMode
expectedGMDApiMode GMDApiMode expectedGMDApiMode GMDApiMode
}{ }{
"no metric query type, no metric editor mode, no expression": { "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", Namespace: "ec2",
MetricName: kindsys.Ptr("CPUUtilization"), MetricName: kindsys.Ptr("CPUUtilization"),
Alias: kindsys.Ptr(tc.inputAlias), Alias: kindsys.Ptr(tc.inputAlias),
Dimensions: map[string]interface{}{ Dimensions: &dataquery.Dimensions{
"InstanceId": []interface{}{"test"}, "InstanceId": []interface{}{"test"},
}, },
Statistic: &average, Statistic: &average,

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -9,12 +9,6 @@
package dataquery package dataquery
// Defines values for EditorMode.
const (
EditorModeBuilder EditorMode = "builder"
EditorModeCode EditorMode = "code"
)
// Defines values for LokiQueryDirection. // Defines values for LokiQueryDirection.
const ( const (
LokiQueryDirectionBackward LokiQueryDirection = "backward" LokiQueryDirectionBackward LokiQueryDirection = "backward"
@@ -41,14 +35,44 @@ const (
SupportingQueryTypeLogsVolume SupportingQueryType = "logsVolume" SupportingQueryTypeLogsVolume SupportingQueryType = "logsVolume"
) )
// LokiDataQuery defines model for LokiDataQuery. // These are the common properties available to all queries in all datasources.
type LokiDataQuery struct { // 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 mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined. // For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema // TODO find a better way to do this ^ that's friendly to schema
// TODO this shouldn't be unknown but DataSourceRef | null // TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"` 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. // The LogQL query.
Expr string `json:"expr"` Expr string `json:"expr"`
@@ -83,9 +107,6 @@ type LokiDataQuery struct {
Resolution *int64 `json:"resolution,omitempty"` Resolution *int64 `json:"resolution,omitempty"`
} }
// EditorMode defines model for LokiDataQuery.EditorMode.
type EditorMode string
// LokiQueryDirection defines model for LokiQueryDirection. // LokiQueryDirection defines model for LokiQueryDirection.
type LokiQueryDirection string type LokiQueryDirection string

View File

@@ -16,8 +16,38 @@ const (
ParcaQueryTypeProfile ParcaQueryType = "profile" 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. // ParcaDataQuery defines model for ParcaDataQuery.
type ParcaDataQuery struct { 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 mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined. // For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema // TODO find a better way to do this ^ that's friendly to schema

View File

@@ -16,8 +16,38 @@ const (
PhlareQueryTypeProfile PhlareQueryType = "profile" 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. // GrafanaPyroscopeDataQuery defines model for GrafanaPyroscopeDataQuery.
type GrafanaPyroscopeDataQuery struct { 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 mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined. // For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema // TODO find a better way to do this ^ that's friendly to schema

View File

@@ -16,47 +16,60 @@ const (
PromQueryFormatTimeSeries PromQueryFormat = "time_series" 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. // Defines values for QueryEditorMode.
const ( const (
QueryEditorModeBuilder QueryEditorMode = "builder" QueryEditorModeBuilder QueryEditorMode = "builder"
QueryEditorModeCode QueryEditorMode = "code" QueryEditorModeCode QueryEditorMode = "code"
) )
// PromQueryFormat defines model for PromQueryFormat. // These are the common properties available to all queries in all datasources.
type PromQueryFormat string // Specific implementations will *extend* this interface, adding the required
// properties for the given context.
// PrometheusDataQuery defines model for PrometheusDataQuery. type DataQuery struct {
type PrometheusDataQuery struct {
// For mixed data sources the selected datasource is on the query level. // For mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined. // For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema // TODO find a better way to do this ^ that's friendly to schema
// TODO this shouldn't be unknown but DataSourceRef | null // TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"` Datasource *interface{} `json:"datasource,omitempty"`
// Specifies which editor is being used to prepare the query. It can be "code" or "builder" // Hide true if query is disabled (ie should not be returned to the dashboard)
EditorMode *EditorMode `json:"editorMode,omitempty"` // 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 // Execute an additional query to identify interesting raw samples relevant for the given expr
Exemplar *bool `json:"exemplar,omitempty"` Exemplar *bool `json:"exemplar,omitempty"`
// The actual expression/query that will be evaluated by Prometheus // The actual expression/query that will be evaluated by Prometheus
Expr string `json:"expr"` Expr string `json:"expr"`
Format *PromQueryFormat `json:"format,omitempty"`
// Query format to determine how to display data points in panel. It can be "time_series", "table", "heatmap"
Format *Format `json:"format,omitempty"`
// Hide true if query is disabled (ie should not be returned to the dashboard) // 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 // 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"` 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. // QueryEditorMode defines model for QueryEditorMode.
type QueryEditorMode string type QueryEditorMode string

View File

@@ -9,13 +9,6 @@
package dataquery package dataquery
// Defines values for TempoQueryFiltersScope.
const (
TempoQueryFiltersScopeResource TempoQueryFiltersScope = "resource"
TempoQueryFiltersScopeSpan TempoQueryFiltersScope = "span"
TempoQueryFiltersScopeUnscoped TempoQueryFiltersScope = "unscoped"
)
// Defines values for TempoQueryType. // Defines values for TempoQueryType.
const ( const (
TempoQueryTypeClear TempoQueryType = "clear" TempoQueryTypeClear TempoQueryType = "clear"
@@ -27,13 +20,6 @@ const (
TempoQueryTypeUpload TempoQueryType = "upload" TempoQueryTypeUpload TempoQueryType = "upload"
) )
// Defines values for TraceqlFilterScope.
const (
TraceqlFilterScopeResource TraceqlFilterScope = "resource"
TraceqlFilterScopeSpan TraceqlFilterScope = "span"
TraceqlFilterScopeUnscoped TraceqlFilterScope = "unscoped"
)
// Defines values for TraceqlSearchScope. // Defines values for TraceqlSearchScope.
const ( const (
TraceqlSearchScopeResource TraceqlSearchScope = "resource" TraceqlSearchScopeResource TraceqlSearchScope = "resource"
@@ -41,35 +27,47 @@ const (
TraceqlSearchScopeUnscoped TraceqlSearchScope = "unscoped" TraceqlSearchScopeUnscoped TraceqlSearchScope = "unscoped"
) )
// TempoDataQuery defines model for TempoDataQuery. // These are the common properties available to all queries in all datasources.
type TempoDataQuery = map[string]interface{} // Specific implementations will *extend* this interface, adding the required
// properties for the given context.
// TempoQuery defines model for TempoQuery. type DataQuery struct {
type TempoQuery struct {
// For mixed data sources the selected datasource is on the query level. // For mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined. // For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema // TODO find a better way to do this ^ that's friendly to schema
// TODO this shouldn't be unknown but DataSourceRef | null // TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"` 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: =, >, !=, =~ // Hide true if query is disabled (ie should not be returned to the dashboard)
Operator *string `json:"operator,omitempty"` // 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 // Specify the query flavor
Scope *TempoQueryFiltersScope `json:"scope,omitempty"` // 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 // A unique identifier for the query within the list of targets.
Tag *string `json:"tag,omitempty"` // 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 // TempoDataQuery defines model for TempoDataQuery.
Value *interface{} `json:"value,omitempty"` 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 // TempoQuery defines model for TempoQuery.
ValueType *string `json:"valueType,omitempty"` type TempoQuery struct {
} `json:"filters"` // 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) // 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 // 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"` 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 // TempoQueryType search = Loki search, nativeSearch = Tempo search for backwards compatibility
type TempoQueryType string type TempoQueryType string
@@ -124,8 +119,8 @@ type TraceqlFilter struct {
// The operator that connects the tag to the value, for example: =, >, !=, =~ // The operator that connects the tag to the value, for example: =, >, !=, =~
Operator *string `json:"operator,omitempty"` Operator *string `json:"operator,omitempty"`
// The scope of the filter, can either be unscoped/all scopes, resource or span // Scope static fields are pre-set in the UI, dynamic fields are added by the user
Scope *TraceqlFilterScope `json:"scope,omitempty"` Scope *TraceqlSearchScope `json:"scope,omitempty"`
// The tag for the search filter, for example: .http.status_code, .service.name, status // The tag for the search filter, for example: .http.status_code, .service.name, status
Tag *string `json:"tag,omitempty"` Tag *string `json:"tag,omitempty"`
@@ -137,8 +132,5 @@ type TraceqlFilter struct {
ValueType *string `json:"valueType,omitempty"` 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 // TraceqlSearchScope static fields are pre-set in the UI, dynamic fields are added by the user
type TraceqlSearchScope string type TraceqlSearchScope string

View File

@@ -30,53 +30,6 @@ const (
ErrorTypeServerPanic ErrorType = "server_panic" 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. // Defines values for TestDataQueryType.
const ( const (
TestDataQueryTypeAnnotations TestDataQueryType = "annotations" TestDataQueryTypeAnnotations TestDataQueryType = "annotations"
@@ -118,6 +71,31 @@ type CSVWave struct {
ValuesCSV *string `json:"valuesCSV,omitempty"` 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. // NodesQuery defines model for NodesQuery.
type NodesQuery struct { type NodesQuery struct {
Count *int64 `json:"count,omitempty"` Count *int64 `json:"count,omitempty"`
@@ -172,95 +150,35 @@ type StreamingQueryType string
// TestDataDataQuery defines model for TestDataDataQuery. // TestDataDataQuery defines model for TestDataDataQuery.
type TestDataDataQuery struct { type TestDataDataQuery struct {
Alias *string `json:"alias,omitempty"` // DataQuery These are the common properties available to all queries in all datasources.
Channel *string `json:"channel,omitempty"` // Specific implementations will *extend* this interface, adding the required
CsvContent *string `json:"csvContent,omitempty"` // properties for the given context.
CsvFileName *string `json:"csvFileName,omitempty"` DataQuery
CsvWave []struct { Alias *string `json:"alias,omitempty"`
Labels *string `json:"labels,omitempty"` Channel *string `json:"channel,omitempty"`
Name *string `json:"name,omitempty"` CsvContent *string `json:"csvContent,omitempty"`
TimeStep *int64 `json:"timeStep,omitempty"` CsvFileName *string `json:"csvFileName,omitempty"`
ValuesCSV *string `json:"valuesCSV,omitempty"` CsvWave []CSVWave `json:"csvWave,omitempty"`
} `json:"csvWave,omitempty"` ErrorType *ErrorType `json:"errorType,omitempty"`
Labels *string `json:"labels,omitempty"`
// For mixed data sources the selected datasource is on the query level. LevelColumn *bool `json:"levelColumn,omitempty"`
// For non mixed scenarios this is undefined. Lines *int64 `json:"lines,omitempty"`
// TODO find a better way to do this ^ that's friendly to schema Nodes *NodesQuery `json:"nodes,omitempty"`
// TODO this shouldn't be unknown but DataSourceRef | null Points [][]interface{} `json:"points,omitempty"`
Datasource *interface{} `json:"datasource,omitempty"` PulseWave *PulseWaveQuery `json:"pulseWave,omitempty"`
ErrorType *ErrorType `json:"errorType,omitempty"` RawFrameContent *string `json:"rawFrameContent,omitempty"`
ScenarioId *TestDataQueryType `json:"scenarioId,omitempty"`
// Hide true if query is disabled (ie should not be returned to the dashboard) SeriesCount *int32 `json:"seriesCount,omitempty"`
// Note this does not always imply that the query should not be executed since Sim *SimulationQuery `json:"sim,omitempty"`
// the results from a hidden query may be used as the input to other queries (SSE etc) SpanCount *int32 `json:"spanCount,omitempty"`
Hide *bool `json:"hide,omitempty"` Stream *StreamingQuery `json:"stream,omitempty"`
Labels *string `json:"labels,omitempty"` StringInput *string `json:"stringInput,omitempty"`
LevelColumn *bool `json:"levelColumn,omitempty"` Usa *USAQuery `json:"usa,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"`
} }
// ErrorType defines model for TestDataDataQuery.ErrorType. // ErrorType defines model for TestDataDataQuery.ErrorType.
type ErrorType string 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. // TestDataQueryType defines model for TestDataQueryType.
type TestDataQueryType string type TestDataQueryType string