From a3f7f62d990d97e8faeb7af00109486a3ea7c65f Mon Sep 17 00:00:00 2001 From: justinsb Date: Fri, 28 Jun 2024 22:42:19 -0400 Subject: [PATCH] monitoring: add blankView --- .../v1beta1/monitoringdashboard_types.go | 7 +-- .../v1beta1/zz_generated.deepcopy.go | 21 +++++++++ ...ards.monitoring.cnrm.cloud.google.com.yaml | 20 +++++++++ docs/releasenotes/release-1.120.md | 1 + .../v1beta1/monitoringdashboard_types.go | 7 +++ .../v1beta1/zz_generated.deepcopy.go | 21 +++++++++ .../dashboard_generated.mappings.go | 6 ++- .../direct/monitoring/dashboard_mappings.go | 15 +++++++ .../direct/monitoring/roundtrip_test.go | 2 - ...ated_export_monitoringdashboardfull.golden | 1 + ...object_monitoringdashboardfull.golden.yaml | 1 + .../monitoringdashboardfull/_http.log | 6 +++ .../monitoringdashboardfull/create.yaml | 1 + .../monitoring/monitoringdashboard.md | 44 +++++++++++++++++++ 14 files changed, 146 insertions(+), 7 deletions(-) diff --git a/apis/monitoring/v1beta1/monitoringdashboard_types.go b/apis/monitoring/v1beta1/monitoringdashboard_types.go index cad88da809..2a72fdde3b 100644 --- a/apis/monitoring/v1beta1/monitoringdashboard_types.go +++ b/apis/monitoring/v1beta1/monitoringdashboard_types.go @@ -701,11 +701,9 @@ type Scorecard struct { // Will cause the scorecard to show a spark chart. SparkChartView *Scorecard_SparkChartView `json:"sparkChartView,omitempty"` - /*NOTYET // Will cause the `Scorecard` to show only the value, with no indicator to // its value relative to its thresholds. - BlankView *Empty `json:"blankView,omitempty"` - */ + BlankView *BlankView `json:"blankView,omitempty"` // The thresholds used to determine the state of the scorecard given the // time series' current value. For an actual value x, the scorecard is in a @@ -748,6 +746,9 @@ type Scorecard struct { Thresholds []Threshold `json:"thresholds,omitempty"` } +type BlankView struct { +} + // +kcc:proto=google.monitoring.dashboard.v1.Scorecard.GaugeView type Scorecard_GaugeView struct { // The lower bound for this gauge chart. The value of the chart should diff --git a/apis/monitoring/v1beta1/zz_generated.deepcopy.go b/apis/monitoring/v1beta1/zz_generated.deepcopy.go index a1967d43d3..7ed22f757d 100644 --- a/apis/monitoring/v1beta1/zz_generated.deepcopy.go +++ b/apis/monitoring/v1beta1/zz_generated.deepcopy.go @@ -81,6 +81,22 @@ func (in *AlertChart) DeepCopy() *AlertChart { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BlankView) DeepCopyInto(out *BlankView) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BlankView. +func (in *BlankView) DeepCopy() *BlankView { + if in == nil { + return nil + } + out := new(BlankView) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChartOptions) DeepCopyInto(out *ChartOptions) { *out = *in @@ -746,6 +762,11 @@ func (in *Scorecard) DeepCopyInto(out *Scorecard) { *out = new(Scorecard_SparkChartView) (*in).DeepCopyInto(*out) } + if in.BlankView != nil { + in, out := &in.BlankView, &out.BlankView + *out = new(BlankView) + **out = **in + } if in.Thresholds != nil { in, out := &in.Thresholds, &out.Thresholds *out = make([]Threshold, len(*in)) 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 ea37ecab00..1e353db09f 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 @@ -953,6 +953,11 @@ spec: scorecard: description: A scorecard summarizing time series data. properties: + blankView: + description: Will cause the `Scorecard` to show + only the value, with no indicator to its value + relative to its thresholds. + type: object gaugeView: description: Will cause the scorecard to show a gauge chart. @@ -3896,6 +3901,11 @@ spec: scorecard: description: A scorecard summarizing time series data. properties: + blankView: + description: Will cause the `Scorecard` to show only + the value, with no indicator to its value relative + to its thresholds. + type: object gaugeView: description: Will cause the scorecard to show a gauge chart. @@ -6732,6 +6742,11 @@ spec: scorecard: description: A scorecard summarizing time series data. properties: + blankView: + description: Will cause the `Scorecard` to show + only the value, with no indicator to its value + relative to its thresholds. + type: object gaugeView: description: Will cause the scorecard to show a gauge chart. @@ -9709,6 +9724,11 @@ spec: scorecard: description: A scorecard summarizing time series data. properties: + blankView: + description: Will cause the `Scorecard` to show + only the value, with no indicator to its value + relative to its thresholds. + type: object gaugeView: description: Will cause the scorecard to show a gauge chart. diff --git a/docs/releasenotes/release-1.120.md b/docs/releasenotes/release-1.120.md index 8b2ba839c5..7aa913649f 100644 --- a/docs/releasenotes/release-1.120.md +++ b/docs/releasenotes/release-1.120.md @@ -37,6 +37,7 @@ output fields from GCP APIs are in `status.observedState.*` * Added `singleViewGroup` widgets. * Added `timeSeriesTable` widgets. + * Added `blankView` to `scorecard` widgets. * Added `dataSets.targetAxis` and `y2Axis` fields to `xyChart` widgets. * Added `id` field to all widgets. * Added `prometheusQuery` and `outputFullDuration` to timeSeriesQuery. diff --git a/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go b/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go index d72820a84c..fa1c273c4e 100644 --- a/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go +++ b/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go @@ -100,6 +100,9 @@ type DashboardAlertChart struct { type DashboardBlank struct { } +type DashboardBlankView struct { +} + type DashboardChartOptions struct { /* The chart mode. */ // +optional @@ -351,6 +354,10 @@ type DashboardRows struct { } type DashboardScorecard struct { + /* Will cause the `Scorecard` to show only the value, with no indicator to its value relative to its thresholds. */ + // +optional + BlankView *DashboardBlankView `json:"blankView,omitempty"` + /* Will cause the scorecard to show a gauge chart. */ // +optional GaugeView *DashboardGaugeView `json:"gaugeView,omitempty"` 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 6222ef6190..42669036f6 100644 --- a/pkg/clients/generated/apis/monitoring/v1beta1/zz_generated.deepcopy.go +++ b/pkg/clients/generated/apis/monitoring/v1beta1/zz_generated.deepcopy.go @@ -575,6 +575,22 @@ func (in *DashboardBlank) DeepCopy() *DashboardBlank { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DashboardBlankView) DeepCopyInto(out *DashboardBlankView) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardBlankView. +func (in *DashboardBlankView) DeepCopy() *DashboardBlankView { + if in == nil { + return nil + } + out := new(DashboardBlankView) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DashboardChartOptions) DeepCopyInto(out *DashboardChartOptions) { *out = *in @@ -1178,6 +1194,11 @@ func (in *DashboardRows) DeepCopy() *DashboardRows { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DashboardScorecard) DeepCopyInto(out *DashboardScorecard) { *out = *in + if in.BlankView != nil { + in, out := &in.BlankView, &out.BlankView + *out = new(DashboardBlankView) + **out = **in + } if in.GaugeView != nil { in, out := &in.GaugeView, &out.GaugeView *out = new(DashboardGaugeView) diff --git a/pkg/controller/direct/monitoring/dashboard_generated.mappings.go b/pkg/controller/direct/monitoring/dashboard_generated.mappings.go index 2498767d2e..d5a73cc9a3 100644 --- a/pkg/controller/direct/monitoring/dashboard_generated.mappings.go +++ b/pkg/controller/direct/monitoring/dashboard_generated.mappings.go @@ -392,7 +392,7 @@ func Scorecard_FromProto(mapCtx *MapContext, in *pb.Scorecard) *krm.Scorecard { out.TimeSeriesQuery = TimeSeriesQuery_FromProto(mapCtx, in.GetTimeSeriesQuery()) out.GaugeView = Scorecard_GaugeView_FromProto(mapCtx, in.GetGaugeView()) out.SparkChartView = Scorecard_SparkChartView_FromProto(mapCtx, in.GetSparkChartView()) - // MISSING: BlankView + out.BlankView = BlankView_FromProto(mapCtx, in.GetBlankView()) out.Thresholds = Slice_FromProto(mapCtx, in.Thresholds, Threshold_FromProto) return out } @@ -408,7 +408,9 @@ func Scorecard_ToProto(mapCtx *MapContext, in *krm.Scorecard) *pb.Scorecard { if oneof := Scorecard_SparkChartView_ToProto(mapCtx, in.SparkChartView); oneof != nil { out.DataView = &pb.Scorecard_SparkChartView_{SparkChartView: oneof} } - // MISSING: BlankView + if oneof := BlankView_ToProto(mapCtx, in.BlankView); oneof != nil { + out.DataView = &pb.Scorecard_BlankView{BlankView: oneof} + } out.Thresholds = Slice_ToProto(mapCtx, in.Thresholds, Threshold_ToProto) return out } diff --git a/pkg/controller/direct/monitoring/dashboard_mappings.go b/pkg/controller/direct/monitoring/dashboard_mappings.go index d75e06563e..95cf5ca5a6 100644 --- a/pkg/controller/direct/monitoring/dashboard_mappings.go +++ b/pkg/controller/direct/monitoring/dashboard_mappings.go @@ -272,3 +272,18 @@ func IncidentList_ToProto(mapCtx *MapContext, in *krm.IncidentList) *pb.Incident } return out } + +func BlankView_FromProto(mapCtx *MapContext, in *emptypb.Empty) *krm.BlankView { + if in == nil { + return nil + } + out := &krm.BlankView{} + return out +} +func BlankView_ToProto(mapCtx *MapContext, in *krm.BlankView) *emptypb.Empty { + if in == nil { + return nil + } + out := &emptypb.Empty{} + return out +} diff --git a/pkg/controller/direct/monitoring/roundtrip_test.go b/pkg/controller/direct/monitoring/roundtrip_test.go index 65ba988db6..86a4c23cde 100644 --- a/pkg/controller/direct/monitoring/roundtrip_test.go +++ b/pkg/controller/direct/monitoring/roundtrip_test.go @@ -57,8 +57,6 @@ func FuzzMonitoringDashboardSpec(f *testing.F) { ".row_layout.rows[].widgets[]", } for _, widgetPath := range widgetPaths { - unimplementedFields.Insert(widgetPath + ".scorecard.blank_view") - unimplementedFields.Insert(widgetPath + ".pie_chart.data_sets[].time_series_query.time_series_filter.statistical_time_series_filter") unimplementedFields.Insert(widgetPath + ".pie_chart.data_sets[].time_series_query.time_series_filter.pick_time_series_filter.interval") unimplementedFields.Insert(widgetPath + ".pie_chart.data_sets[].time_series_query.time_series_filter_ratio.statistical_time_series_filter") 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 e1e0283fc9..62533c5f4e 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 @@ -62,6 +62,7 @@ spec: kind: Project title: Widget 4 - scorecard: + blankView: {} timeSeriesQuery: outputFullDuration: true prometheusQuery: sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} 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 e455072c00..4dca4a1286 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 @@ -69,6 +69,7 @@ spec: - external: projects/${projectId} title: Widget 4 - scorecard: + blankView: {} timeSeriesQuery: outputFullDuration: true prometheusQuery: sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} 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 291268578b..8b4acd4464 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 @@ -283,6 +283,7 @@ x-goog-request-params: parent=projects%2F${projectId} }, { "scorecard": { + "blankView": {}, "timeSeriesQuery": { "outputFullDuration": true, "prometheusQuery": "sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} / 60)" @@ -509,6 +510,7 @@ X-Xss-Protection: 0 }, { "scorecard": { + "blankView": {}, "timeSeriesQuery": { "outputFullDuration": true, "prometheusQuery": "sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} / 60)" @@ -744,6 +746,7 @@ X-Xss-Protection: 0 }, { "scorecard": { + "blankView": {}, "timeSeriesQuery": { "outputFullDuration": true, "prometheusQuery": "sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} / 60)" @@ -967,6 +970,7 @@ x-goog-request-params: dashboard.name=projects%2F${projectId}%2Fdashboards%2Fmon }, { "scorecard": { + "blankView": {}, "timeSeriesQuery": { "outputFullDuration": true, "prometheusQuery": "sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} / 60)" @@ -1194,6 +1198,7 @@ X-Xss-Protection: 0 }, { "scorecard": { + "blankView": {}, "timeSeriesQuery": { "outputFullDuration": true, "prometheusQuery": "sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} / 60)" @@ -1429,6 +1434,7 @@ X-Xss-Protection: 0 }, { "scorecard": { + "blankView": {}, "timeSeriesQuery": { "outputFullDuration": true, "prometheusQuery": "sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} / 60)" 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 3b8719f9bb..e692665d8f 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 @@ -83,6 +83,7 @@ spec: - external: "projects/${projectId}" - title: "Scorecard Widget" scorecard: + blankView: {} timeSeriesQuery: outputFullDuration: true prometheusQuery: "sum(mysql_global_status_uptime{${Cluster},${Location},${Namespace}} / 60)" 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 d80aee1380..ce1b1ee045 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 @@ -173,6 +173,7 @@ columnLayout: unitOverride: string showLabels: boolean scorecard: + blankView: {} gaugeView: lowerBound: float upperBound: float @@ -487,6 +488,7 @@ gridLayout: unitOverride: string showLabels: boolean scorecard: + blankView: {} gaugeView: lowerBound: float upperBound: float @@ -797,6 +799,7 @@ mosaicLayout: unitOverride: string showLabels: boolean scorecard: + blankView: {} gaugeView: lowerBound: float upperBound: float @@ -1115,6 +1118,7 @@ rowLayout: unitOverride: string showLabels: boolean scorecard: + blankView: {} gaugeView: lowerBound: float upperBound: float @@ -2564,6 +2568,16 @@ rowLayout:

{% verbatim %}A scorecard summarizing time series data.{% endverbatim %}

+ + +

columnLayout.columns[].widgets[].scorecard.blankView

+

Optional

+ + +

object

+

{% verbatim %}Will cause the `Scorecard` to show only the value, with no indicator to its value relative to its thresholds.{% endverbatim %}

+ +

columnLayout.columns[].widgets[].scorecard.gaugeView

@@ -6661,6 +6675,16 @@ rowLayout:

{% verbatim %}A scorecard summarizing time series data.{% endverbatim %}

+ + +

gridLayout.widgets[].scorecard.blankView

+

Optional

+ + +

object

+

{% verbatim %}Will cause the `Scorecard` to show only the value, with no indicator to its value relative to its thresholds.{% endverbatim %}

+ +

gridLayout.widgets[].scorecard.gaugeView

@@ -10708,6 +10732,16 @@ rowLayout:

{% verbatim %}A scorecard summarizing time series data.{% endverbatim %}

+ + +

mosaicLayout.tiles[].widget.scorecard.blankView

+

Optional

+ + +

object

+

{% verbatim %}Will cause the `Scorecard` to show only the value, with no indicator to its value relative to its thresholds.{% endverbatim %}

+ +

mosaicLayout.tiles[].widget.scorecard.gaugeView

@@ -14845,6 +14879,16 @@ rowLayout:

{% verbatim %}A scorecard summarizing time series data.{% endverbatim %}

+ + +

rowLayout.rows[].widgets[].scorecard.blankView

+

Optional

+ + +

object

+

{% verbatim %}Will cause the `Scorecard` to show only the value, with no indicator to its value relative to its thresholds.{% endverbatim %}

+ +

rowLayout.rows[].widgets[].scorecard.gaugeView