diff --git a/apis/monitoring/v1beta1/monitoringdashboard_types.go b/apis/monitoring/v1beta1/monitoringdashboard_types.go index 146cf98e95..d08a70712c 100644 --- a/apis/monitoring/v1beta1/monitoringdashboard_types.go +++ b/apis/monitoring/v1beta1/monitoringdashboard_types.go @@ -825,10 +825,10 @@ type MonitoringDashboardSpec struct { // arranged vertically. ColumnLayout *ColumnLayout `json:"columnLayout,omitempty"` - /*NOTYET // Filters to reduce the amount of data charted based on the filter criteria. DashboardFilters []DashboardFilter `json:"dashboardFilters,omitempty"` + /*NOTYET // Labels applied to the dashboard Labels []Dashboard_LabelsEntry `json:"labels,omitempty"` */ diff --git a/apis/monitoring/v1beta1/zz_generated.deepcopy.go b/apis/monitoring/v1beta1/zz_generated.deepcopy.go index c673669d0a..82139e7806 100644 --- a/apis/monitoring/v1beta1/zz_generated.deepcopy.go +++ b/apis/monitoring/v1beta1/zz_generated.deepcopy.go @@ -462,6 +462,13 @@ func (in *MonitoringDashboardSpec) DeepCopyInto(out *MonitoringDashboardSpec) { *out = new(ColumnLayout) (*in).DeepCopyInto(*out) } + if in.DashboardFilters != nil { + in, out := &in.DashboardFilters, &out.DashboardFilters + *out = make([]DashboardFilter, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_monitoringdashboards.monitoring.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_monitoringdashboards.monitoring.cnrm.cloud.google.com.yaml index a75d989f6e..dd684086a2 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_monitoringdashboards.monitoring.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_monitoringdashboards.monitoring.cnrm.cloud.google.com.yaml @@ -2984,6 +2984,29 @@ spec: type: object type: array type: object + dashboardFilters: + description: Filters to reduce the amount of data charted based on + the filter criteria. + items: + properties: + filterType: + description: The specified filter type + type: string + labelKey: + description: Required. The key for the label + type: string + stringValue: + description: A variable-length string value. + type: string + templateVariable: + description: The placeholder text that can be referenced in + a filter string or MQL query. If omitted, the dashboard filter + will be applied to all relevant widgets in the dashboard. + type: string + required: + - labelKey + type: object + type: array displayName: description: Required. The mutable, human-readable name. type: string diff --git a/docs/releasenotes/release-1.120.md b/docs/releasenotes/release-1.120.md index 335ac51e31..fc17ac5062 100644 --- a/docs/releasenotes/release-1.120.md +++ b/docs/releasenotes/release-1.120.md @@ -29,6 +29,7 @@ output fields from GCP APIs are in `status.observedState.*` * `MonitoringDashboard` + * Added `dashboardFilters` support. * Added `alertChart` widgets. * Added `collapsibleGroup` widgets. * Added `pieChart` widgets. diff --git a/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go b/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go index 6b820025af..df6198a2cb 100644 --- a/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go +++ b/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go @@ -136,6 +136,23 @@ type DashboardColumns struct { Widgets []DashboardWidgets `json:"widgets,omitempty"` } +type DashboardDashboardFilters struct { + /* The specified filter type */ + // +optional + FilterType *string `json:"filterType,omitempty"` + + /* Required. The key for the label */ + LabelKey string `json:"labelKey"` + + /* A variable-length string value. */ + // +optional + StringValue *string `json:"stringValue,omitempty"` + + /* The placeholder text that can be referenced in a filter string or MQL query. If omitted, the dashboard filter will be applied to all relevant widgets in the dashboard. */ + // +optional + TemplateVariable *string `json:"templateVariable,omitempty"` +} + type DashboardDataSets struct { /* A template string for naming `TimeSeries` in the resulting data set. This should be a string with interpolations of the form `${label_name}`, which will resolve to the label's value. */ // +optional @@ -810,6 +827,10 @@ type MonitoringDashboardSpec struct { // +optional ColumnLayout *DashboardColumnLayout `json:"columnLayout,omitempty"` + /* Filters to reduce the amount of data charted based on the filter criteria. */ + // +optional + DashboardFilters []DashboardDashboardFilters `json:"dashboardFilters,omitempty"` + /* Required. The mutable, human-readable name. */ DisplayName string `json:"displayName"` diff --git a/pkg/clients/generated/apis/monitoring/v1beta1/zz_generated.deepcopy.go b/pkg/clients/generated/apis/monitoring/v1beta1/zz_generated.deepcopy.go index ee47d9cde8..540aea3ee8 100644 --- a/pkg/clients/generated/apis/monitoring/v1beta1/zz_generated.deepcopy.go +++ b/pkg/clients/generated/apis/monitoring/v1beta1/zz_generated.deepcopy.go @@ -684,6 +684,37 @@ func (in *DashboardColumns) DeepCopy() *DashboardColumns { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DashboardDashboardFilters) DeepCopyInto(out *DashboardDashboardFilters) { + *out = *in + if in.FilterType != nil { + in, out := &in.FilterType, &out.FilterType + *out = new(string) + **out = **in + } + if in.StringValue != nil { + in, out := &in.StringValue, &out.StringValue + *out = new(string) + **out = **in + } + if in.TemplateVariable != nil { + in, out := &in.TemplateVariable, &out.TemplateVariable + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardDashboardFilters. +func (in *DashboardDashboardFilters) DeepCopy() *DashboardDashboardFilters { + if in == nil { + return nil + } + out := new(DashboardDashboardFilters) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DashboardDataSets) DeepCopyInto(out *DashboardDataSets) { *out = *in @@ -2170,6 +2201,13 @@ func (in *MonitoringDashboardSpec) DeepCopyInto(out *MonitoringDashboardSpec) { *out = new(DashboardColumnLayout) (*in).DeepCopyInto(*out) } + if in.DashboardFilters != nil { + in, out := &in.DashboardFilters, &out.DashboardFilters + *out = make([]DashboardDashboardFilters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.GridLayout != nil { in, out := &in.GridLayout, &out.GridLayout *out = new(DashboardGridLayout) diff --git a/pkg/controller/direct/monitoring/dashboard_generated.mappings.go b/pkg/controller/direct/monitoring/dashboard_generated.mappings.go index 9ed61ce43b..c5553ff97f 100644 --- a/pkg/controller/direct/monitoring/dashboard_generated.mappings.go +++ b/pkg/controller/direct/monitoring/dashboard_generated.mappings.go @@ -109,33 +109,30 @@ func ColumnLayout_Column_ToProto(mapCtx *MapContext, in *krm.ColumnLayout_Column out.Widgets = Slice_ToProto(mapCtx, in.Widgets, Widget_ToProto) return out } - -// func DashboardFilter_FromProto(mapCtx *MapContext, in *pb.DashboardFilter) *krm.DashboardFilter { -// if in == nil { -// return nil -// } -// out := &krm.DashboardFilter{} -// out.LabelKey = LazyPtr(in.GetLabelKey()) -// out.TemplateVariable = LazyPtr(in.GetTemplateVariable()) -// out.StringValue = LazyPtr(in.GetStringValue()) -// out.FilterType = Enum_FromProto(mapCtx, in.FilterType) -// return out -// } - -// func DashboardFilter_ToProto(mapCtx *MapContext, in *krm.DashboardFilter) *pb.DashboardFilter { -// if in == nil { -// return nil -// } -// out := &pb.DashboardFilter{} -// out.LabelKey = ValueOf(in.LabelKey) -// out.TemplateVariable = ValueOf(in.TemplateVariable) -// if oneof := DashboardFilter_StringValue_ToProto(mapCtx, in.StringValue); oneof != nil { -// out.DefaultValue = oneof -// } -// out.FilterType = Enum_ToProto[pb.DashboardFilter_FilterType](mapCtx, in.FilterType) -// return out -// } - +func DashboardFilter_FromProto(mapCtx *MapContext, in *pb.DashboardFilter) *krm.DashboardFilter { + if in == nil { + return nil + } + out := &krm.DashboardFilter{} + out.LabelKey = LazyPtr(in.GetLabelKey()) + out.TemplateVariable = LazyPtr(in.GetTemplateVariable()) + out.StringValue = LazyPtr(in.GetStringValue()) + out.FilterType = Enum_FromProto(mapCtx, in.FilterType) + return out +} +func DashboardFilter_ToProto(mapCtx *MapContext, in *krm.DashboardFilter) *pb.DashboardFilter { + if in == nil { + return nil + } + out := &pb.DashboardFilter{} + out.LabelKey = ValueOf(in.LabelKey) + out.TemplateVariable = ValueOf(in.TemplateVariable) + if oneof := DashboardFilter_StringValue_ToProto(mapCtx, in.StringValue); oneof != nil { + out.DefaultValue = oneof + } + out.FilterType = Enum_ToProto[pb.DashboardFilter_FilterType](mapCtx, in.FilterType) + return out +} func GridLayout_FromProto(mapCtx *MapContext, in *pb.GridLayout) *krm.GridLayout { if in == nil { return nil @@ -204,7 +201,7 @@ func MonitoringDashboardSpec_FromProto(mapCtx *MapContext, in *pb.Dashboard) *kr out.MosaicLayout = MosaicLayout_FromProto(mapCtx, in.GetMosaicLayout()) out.RowLayout = RowLayout_FromProto(mapCtx, in.GetRowLayout()) out.ColumnLayout = ColumnLayout_FromProto(mapCtx, in.GetColumnLayout()) - // MISSING: DashboardFilters + out.DashboardFilters = Slice_FromProto(mapCtx, in.DashboardFilters, DashboardFilter_FromProto) // MISSING: Labels return out } @@ -228,7 +225,7 @@ func MonitoringDashboardSpec_ToProto(mapCtx *MapContext, in *krm.MonitoringDashb if oneof := ColumnLayout_ToProto(mapCtx, in.ColumnLayout); oneof != nil { out.Layout = &pb.Dashboard_ColumnLayout{ColumnLayout: oneof} } - // MISSING: DashboardFilters + out.DashboardFilters = Slice_ToProto(mapCtx, in.DashboardFilters, DashboardFilter_ToProto) // MISSING: Labels return out } diff --git a/pkg/controller/direct/monitoring/dashboard_mappings.go b/pkg/controller/direct/monitoring/dashboard_mappings.go index 03ddb3d2a1..5f4266b8f7 100644 --- a/pkg/controller/direct/monitoring/dashboard_mappings.go +++ b/pkg/controller/direct/monitoring/dashboard_mappings.go @@ -240,3 +240,12 @@ func MonitoredResource_ToProto(mapCtx *MapContext, in *krm.MonitoredResource) *m out.Labels = in.Labels return out } + +func DashboardFilter_StringValue_ToProto(mapCtx *MapContext, in *string) *pb.DashboardFilter_StringValue { + if in == nil { + return nil + } + out := &pb.DashboardFilter_StringValue{} + out.StringValue = *in + return out +} diff --git a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_export_monitoringdashboardfull.golden b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_export_monitoringdashboardfull.golden index 217d7da053..95456d1ce5 100644 --- a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_export_monitoringdashboardfull.golden +++ b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_export_monitoringdashboardfull.golden @@ -131,6 +131,13 @@ spec: - foo - bar title: IncidentList Widget + dashboardFilters: + - filterType: RESOURCE_LABEL + labelKey: instance_id + stringValue: "3133577226154888113" + templateVariable: iid + - filterType: RESOURCE_LABEL + labelKey: zone displayName: monitoringdashboard-full projectRef: external: ${projectId} \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_object_monitoringdashboardfull.golden.yaml b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_object_monitoringdashboardfull.golden.yaml index 3419e0601c..a960fe2da2 100644 --- a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_object_monitoringdashboardfull.golden.yaml +++ b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_object_monitoringdashboardfull.golden.yaml @@ -139,6 +139,13 @@ spec: - foo - bar title: IncidentList Widget + dashboardFilters: + - filterType: RESOURCE_LABEL + labelKey: instance_id + stringValue: "3133577226154888113" + templateVariable: iid + - filterType: RESOURCE_LABEL + labelKey: zone displayName: monitoringdashboard-full projectRef: external: ${projectId} diff --git a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_http.log b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_http.log index 1e9b7c4108..3d280ff1e4 100644 --- a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_http.log @@ -403,6 +403,18 @@ x-goog-request-params: parent=projects%2F${projectId} } ] }, + "dashboardFilters": [ + { + "filterType": 1, + "labelKey": "instance_id", + "stringValue": "3133577226154888113", + "templateVariable": "iid" + }, + { + "filterType": 1, + "labelKey": "zone" + } + ], "displayName": "monitoringdashboard-full", "name": "projects/${projectId}/dashboards/monitoringdashboard-${uniqueId}" } @@ -632,6 +644,18 @@ X-Xss-Protection: 0 } ] }, + "dashboardFilters": [ + { + "filterType": "RESOURCE_LABEL", + "labelKey": "instance_id", + "stringValue": "3133577226154888113", + "templateVariable": "iid" + }, + { + "filterType": "RESOURCE_LABEL", + "labelKey": "zone" + } + ], "displayName": "monitoringdashboard-full", "etag": "abcdef0123A=", "name": "projects/${projectNumber}/dashboards/monitoringdashboard-${uniqueId}" @@ -869,6 +893,18 @@ X-Xss-Protection: 0 } ] }, + "dashboardFilters": [ + { + "filterType": "RESOURCE_LABEL", + "labelKey": "instance_id", + "stringValue": "3133577226154888113", + "templateVariable": "iid" + }, + { + "filterType": "RESOURCE_LABEL", + "labelKey": "zone" + } + ], "displayName": "monitoringdashboard-full", "etag": "abcdef0123A=", "name": "projects/${projectNumber}/dashboards/monitoringdashboard-${uniqueId}" @@ -1093,6 +1129,18 @@ x-goog-request-params: dashboard.name=projects%2F${projectId}%2Fdashboards%2Fmon } ] }, + "dashboardFilters": [ + { + "filterType": 1, + "labelKey": "instance_id", + "stringValue": "3133577226154888113", + "templateVariable": "iid" + }, + { + "filterType": 1, + "labelKey": "zone" + } + ], "displayName": "monitoringdashboard-full", "name": "projects/${projectId}/dashboards/monitoringdashboard-${uniqueId}" } @@ -1322,6 +1370,18 @@ X-Xss-Protection: 0 } ] }, + "dashboardFilters": [ + { + "filterType": "RESOURCE_LABEL", + "labelKey": "instance_id", + "stringValue": "3133577226154888113", + "templateVariable": "iid" + }, + { + "filterType": "RESOURCE_LABEL", + "labelKey": "zone" + } + ], "displayName": "monitoringdashboard-full", "etag": "abcdef0123A=", "name": "projects/${projectNumber}/dashboards/monitoringdashboard-${uniqueId}" @@ -1559,6 +1619,18 @@ X-Xss-Protection: 0 } ] }, + "dashboardFilters": [ + { + "filterType": "RESOURCE_LABEL", + "labelKey": "instance_id", + "stringValue": "3133577226154888113", + "templateVariable": "iid" + }, + { + "filterType": "RESOURCE_LABEL", + "labelKey": "zone" + } + ], "displayName": "monitoringdashboard-full", "etag": "abcdef0123A=", "name": "projects/${projectNumber}/dashboards/monitoringdashboard-${uniqueId}" diff --git a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/create.yaml b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/create.yaml index dd0bb817d4..a1e560cc1f 100644 --- a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/create.yaml +++ b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/create.yaml @@ -17,6 +17,13 @@ kind: MonitoringDashboard metadata: name: monitoringdashboard-${uniqueId} spec: + dashboardFilters: + - filterType: RESOURCE_LABEL + labelKey: instance_id + stringValue: "3133577226154888113" + templateVariable: iid + - filterType: RESOURCE_LABEL + labelKey: zone displayName: "monitoringdashboard-full" columnLayout: columns: diff --git a/scripts/generate-google3-docs/resource-reference/generated/resource-docs/monitoring/monitoringdashboard.md b/scripts/generate-google3-docs/resource-reference/generated/resource-docs/monitoring/monitoringdashboard.md index 71e301c5e5..227a57a235 100644 --- a/scripts/generate-google3-docs/resource-reference/generated/resource-docs/monitoring/monitoringdashboard.md +++ b/scripts/generate-google3-docs/resource-reference/generated/resource-docs/monitoring/monitoringdashboard.md @@ -380,6 +380,11 @@ columnLayout: yAxis: label: string scale: string +dashboardFilters: +- filterType: string + labelKey: string + stringValue: string + templateVariable: string displayName: string gridLayout: columns: integer @@ -5285,6 +5290,66 @@ rowLayout:

{% verbatim %}The axis scale. By default, a linear scale is used.{% endverbatim %}

+ + +

dashboardFilters

+

Optional

+ + +

list (object)

+

{% verbatim %}Filters to reduce the amount of data charted based on the filter criteria.{% endverbatim %}

+ + + + +

dashboardFilters[]

+

Optional

+ + +

object

+

{% verbatim %}{% endverbatim %}

+ + + + +

dashboardFilters[].filterType

+

Optional

+ + +

string

+

{% verbatim %}The specified filter type{% endverbatim %}

+ + + + +

dashboardFilters[].labelKey

+

Required*

+ + +

string

+

{% verbatim %}Required. The key for the label{% endverbatim %}

+ + + + +

dashboardFilters[].stringValue

+

Optional

+ + +

string

+

{% verbatim %}A variable-length string value.{% endverbatim %}

+ + + + +

dashboardFilters[].templateVariable

+

Optional

+ + +

string

+

{% verbatim %}The placeholder text that can be referenced in a filter string or MQL query. If omitted, the dashboard filter will be applied to all relevant widgets in the dashboard.{% endverbatim %}

+ +

displayName