Skip to content

Commit

Permalink
monitoringdashboard: add dashboardFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsb committed Jun 28, 2024
1 parent b5a5611 commit 7f295d8
Show file tree
Hide file tree
Showing 13 changed files with 367 additions and 30 deletions.
2 changes: 1 addition & 1 deletion apis/monitoring/v1beta1/monitoringdashboard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,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"`
*/
Expand Down
7 changes: 7 additions & 0 deletions apis/monitoring/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,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
Expand Down
1 change: 1 addition & 0 deletions docs/releasenotes/release-1.120.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 26 additions & 29 deletions pkg/controller/direct/monitoring/dashboard_generated.mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -205,7 +202,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
}
Expand All @@ -229,7 +226,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
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/controller/direct/monitoring/dashboard_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ func TimeSeriesTable_ColumnSettings_FromProto(mapCtx *MapContext, in *pb.TimeSer
// We want to always output the visible field, i.e. `visible: false`
// We probably can automate this, because the visible field is required.
out.Visible = PtrTo(in.GetVisible())
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ spec:
resource.type="gce_instance"
metricVisualization: NUMBER
title: TimeSeriesTable Widget
dashboardFilters:
- filterType: RESOURCE_LABEL
labelKey: instance_id
stringValue: "3133577226154888113"
templateVariable: iid
- filterType: RESOURCE_LABEL
labelKey: zone
displayName: monitoringdashboard-full
projectRef:
external: ${projectId}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ spec:
resource.type="gce_instance"
metricVisualization: NUMBER
title: TimeSeriesTable Widget
dashboardFilters:
- filterType: RESOURCE_LABEL
labelKey: instance_id
stringValue: "3133577226154888113"
templateVariable: iid
- filterType: RESOURCE_LABEL
labelKey: zone
displayName: monitoringdashboard-full
projectRef:
external: ${projectId}
Expand Down
Loading

0 comments on commit 7f295d8

Please sign in to comment.