Skip to content

Commit

Permalink
Merge pull request #2189 from justinsb/monitoringdashboard_dashboardf…
Browse files Browse the repository at this point in the history
…ilters

monitoringdashboard: add dashboardFilters
  • Loading branch information
google-oss-prow[bot] authored Jun 28, 2024
2 parents f98f85c + 6914da3 commit 14966c3
Show file tree
Hide file tree
Showing 13 changed files with 284 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 @@ -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"`
*/
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 @@ -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
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 @@ -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
}
Expand All @@ -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
}
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 @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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}"
}
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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}"
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
Loading

0 comments on commit 14966c3

Please sign in to comment.