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 9a8cd9b commit b800718
Show file tree
Hide file tree
Showing 10 changed files with 124 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 @@ -815,10 +815,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 @@ -2295,6 +2295,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
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
9 changes: 9 additions & 0 deletions pkg/controller/direct/monitoring/dashboard_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,12 @@ func TimeSeriesQuery_PrometheusQuery_ToProto(mapCtx *MapContext, in *string) *pb
out.PrometheusQuery = *in
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 @@ -104,6 +104,13 @@ spec:
- v1
- v2
title: ErrorReporting 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 @@ -112,6 +112,13 @@ spec:
- v1
- v2
title: ErrorReporting 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
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,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}"
}
Expand Down Expand Up @@ -538,6 +550,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}"
Expand Down Expand Up @@ -728,6 +752,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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b800718

Please sign in to comment.