From 62649daec81b3f1703e82b2565295cd83ef2a9ce Mon Sep 17 00:00:00 2001 From: justinsb Date: Mon, 1 Jul 2024 10:56:04 -0400 Subject: [PATCH] monitoringdashboard: alertPolicyNames should be refs --- .../v1beta1/monitoringdashboard_types.go | 6 +- .../v1beta1/zz_generated.deepcopy.go | 6 +- ...ards.monitoring.cnrm.cloud.google.com.yaml | 152 ++++++++++++--- .../v1beta1/monitoringdashboard_types.go | 4 +- .../v1beta1/zz_generated.deepcopy.go | 6 +- .../dashboard_generated.mappings.go | 19 +- .../direct/monitoring/dashboard_mappings.go | 23 +++ pkg/controller/direct/monitoring/refs.go | 15 ++ ...ated_export_monitoringdashboardfull.golden | 5 +- ...object_monitoringdashboardfull.golden.yaml | 5 +- .../monitoringdashboardfull/_http.log | 18 +- .../monitoringdashboardfull/create.yaml | 5 +- .../monitoringdashboardmosaiclayout/_http.log | 8 +- .../monitoring/monitoringdashboard.md | 184 +++++++++++++++--- tests/e2e/normalize.go | 14 +- 15 files changed, 362 insertions(+), 108 deletions(-) diff --git a/apis/monitoring/v1beta1/monitoringdashboard_types.go b/apis/monitoring/v1beta1/monitoringdashboard_types.go index d6eac80630..cad88da809 100644 --- a/apis/monitoring/v1beta1/monitoringdashboard_types.go +++ b/apis/monitoring/v1beta1/monitoringdashboard_types.go @@ -601,10 +601,8 @@ type IncidentList struct { // The resource type and labels are used for filtering. MonitoredResources []MonitoredResource `json:"monitoredResources,omitempty"` - // Optional. A list of alert policy names to filter the incident list by. - // Don't include the project ID prefix in the policy name. For - // example, use `alertPolicies/utilization`. - PolicyNames []string `json:"policyNames,omitempty"` + // Optional. A list of alert policies to filter the incident list by. + PolicyRefs []refs.MonitoringAlertPolicyRef `json:"policyRefs,omitempty"` } // +kcc:proto=google.api.MonitoredResource diff --git a/apis/monitoring/v1beta1/zz_generated.deepcopy.go b/apis/monitoring/v1beta1/zz_generated.deepcopy.go index c5977df3a9..a1967d43d3 100644 --- a/apis/monitoring/v1beta1/zz_generated.deepcopy.go +++ b/apis/monitoring/v1beta1/zz_generated.deepcopy.go @@ -295,9 +295,9 @@ func (in *IncidentList) DeepCopyInto(out *IncidentList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.PolicyNames != nil { - in, out := &in.PolicyNames, &out.PolicyNames - *out = make([]string, len(*in)) + if in.PolicyRefs != nil { + in, out := &in.PolicyRefs, &out.PolicyRefs + *out = make([]refsv1beta1.MonitoringAlertPolicyRef, len(*in)) copy(*out, *in) } 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 e7163375e2..ea37ecab00 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 @@ -236,13 +236,39 @@ spec: type: string type: object type: array - policyNames: - description: Optional. A list of alert policy - names to filter the incident list by. Don't - include the project ID prefix in the policy - name. For example, use `alertPolicies/utilization`. + policyRefs: + description: Optional. A list of alert policies + to filter the incident list by. items: - type: string + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: The MonitoringAlertPolicy link + in the form "projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]", + when not managed by KCC. + type: string + name: + description: The `name` field of a `MonitoringAlertPolicy` + resource. + type: string + namespace: + description: The `namespace` field of a + `MonitoringAlertPolicy` resource. + type: string + type: object type: array type: object logsPanel: @@ -3191,13 +3217,39 @@ spec: type: string type: object type: array - policyNames: - description: Optional. A list of alert policy names - to filter the incident list by. Don't include the - project ID prefix in the policy name. For example, - use `alertPolicies/utilization`. + policyRefs: + description: Optional. A list of alert policies to filter + the incident list by. items: - type: string + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: The MonitoringAlertPolicy link in + the form "projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]", + when not managed by KCC. + type: string + name: + description: The `name` field of a `MonitoringAlertPolicy` + resource. + type: string + namespace: + description: The `namespace` field of a `MonitoringAlertPolicy` + resource. + type: string + type: object type: array type: object logsPanel: @@ -5978,13 +6030,39 @@ spec: type: string type: object type: array - policyNames: - description: Optional. A list of alert policy names - to filter the incident list by. Don't include - the project ID prefix in the policy name. For - example, use `alertPolicies/utilization`. + policyRefs: + description: Optional. A list of alert policies + to filter the incident list by. items: - type: string + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: The MonitoringAlertPolicy link + in the form "projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]", + when not managed by KCC. + type: string + name: + description: The `name` field of a `MonitoringAlertPolicy` + resource. + type: string + namespace: + description: The `namespace` field of a `MonitoringAlertPolicy` + resource. + type: string + type: object type: array type: object logsPanel: @@ -8914,13 +8992,39 @@ spec: type: string type: object type: array - policyNames: - description: Optional. A list of alert policy - names to filter the incident list by. Don't - include the project ID prefix in the policy - name. For example, use `alertPolicies/utilization`. + policyRefs: + description: Optional. A list of alert policies + to filter the incident list by. items: - type: string + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: The MonitoringAlertPolicy link + in the form "projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]", + when not managed by KCC. + type: string + name: + description: The `name` field of a `MonitoringAlertPolicy` + resource. + type: string + namespace: + description: The `namespace` field of a + `MonitoringAlertPolicy` resource. + type: string + type: object type: array type: object logsPanel: diff --git a/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go b/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go index 0d94af48bb..d72820a84c 100644 --- a/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go +++ b/pkg/clients/generated/apis/monitoring/v1beta1/monitoringdashboard_types.go @@ -228,9 +228,9 @@ type DashboardIncidentList struct { // +optional MonitoredResources []DashboardMonitoredResources `json:"monitoredResources,omitempty"` - /* Optional. A list of alert policy names to filter the incident list by. Don't include the project ID prefix in the policy name. For example, use `alertPolicies/utilization`. */ + /* Optional. A list of alert policies to filter the incident list by. */ // +optional - PolicyNames []string `json:"policyNames,omitempty"` + PolicyRefs []v1alpha1.ResourceRef `json:"policyRefs,omitempty"` } type DashboardLogsPanel struct { 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 7420560bdc..6222ef6190 100644 --- a/pkg/clients/generated/apis/monitoring/v1beta1/zz_generated.deepcopy.go +++ b/pkg/clients/generated/apis/monitoring/v1beta1/zz_generated.deepcopy.go @@ -870,9 +870,9 @@ func (in *DashboardIncidentList) DeepCopyInto(out *DashboardIncidentList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.PolicyNames != nil { - in, out := &in.PolicyNames, &out.PolicyNames - *out = make([]string, len(*in)) + if in.PolicyRefs != nil { + in, out := &in.PolicyRefs, &out.PolicyRefs + *out = make([]v1alpha1.ResourceRef, len(*in)) copy(*out, *in) } return diff --git a/pkg/controller/direct/monitoring/dashboard_generated.mappings.go b/pkg/controller/direct/monitoring/dashboard_generated.mappings.go index 26cd484e20..2498767d2e 100644 --- a/pkg/controller/direct/monitoring/dashboard_generated.mappings.go +++ b/pkg/controller/direct/monitoring/dashboard_generated.mappings.go @@ -151,24 +151,7 @@ func GridLayout_ToProto(mapCtx *MapContext, in *krm.GridLayout) *pb.GridLayout { out.Widgets = Slice_ToProto(mapCtx, in.Widgets, Widget_ToProto) return out } -func IncidentList_FromProto(mapCtx *MapContext, in *pb.IncidentList) *krm.IncidentList { - if in == nil { - return nil - } - out := &krm.IncidentList{} - out.MonitoredResources = Slice_FromProto(mapCtx, in.MonitoredResources, MonitoredResource_FromProto) - out.PolicyNames = in.PolicyNames - return out -} -func IncidentList_ToProto(mapCtx *MapContext, in *krm.IncidentList) *pb.IncidentList { - if in == nil { - return nil - } - out := &pb.IncidentList{} - out.MonitoredResources = Slice_ToProto(mapCtx, in.MonitoredResources, MonitoredResource_ToProto) - out.PolicyNames = in.PolicyNames - return out -} + func LogsPanel_FromProto(mapCtx *MapContext, in *pb.LogsPanel) *krm.LogsPanel { if in == nil { return nil diff --git a/pkg/controller/direct/monitoring/dashboard_mappings.go b/pkg/controller/direct/monitoring/dashboard_mappings.go index 5f4266b8f7..d75e06563e 100644 --- a/pkg/controller/direct/monitoring/dashboard_mappings.go +++ b/pkg/controller/direct/monitoring/dashboard_mappings.go @@ -249,3 +249,26 @@ func DashboardFilter_StringValue_ToProto(mapCtx *MapContext, in *string) *pb.Das out.StringValue = *in return out } + +func IncidentList_FromProto(mapCtx *MapContext, in *pb.IncidentList) *krm.IncidentList { + if in == nil { + return nil + } + out := &krm.IncidentList{} + out.MonitoredResources = Slice_FromProto(mapCtx, in.MonitoredResources, MonitoredResource_FromProto) + for _, policyName := range in.PolicyNames { + out.PolicyRefs = append(out.PolicyRefs, refs.MonitoringAlertPolicyRef{External: policyName}) + } + return out +} +func IncidentList_ToProto(mapCtx *MapContext, in *krm.IncidentList) *pb.IncidentList { + if in == nil { + return nil + } + out := &pb.IncidentList{} + out.MonitoredResources = Slice_ToProto(mapCtx, in.MonitoredResources, MonitoredResource_ToProto) + for _, policyRef := range in.PolicyRefs { + out.PolicyNames = append(out.PolicyNames, policyRef.External) + } + return out +} diff --git a/pkg/controller/direct/monitoring/refs.go b/pkg/controller/direct/monitoring/refs.go index 81dbc41549..317de60622 100644 --- a/pkg/controller/direct/monitoring/refs.go +++ b/pkg/controller/direct/monitoring/refs.go @@ -196,6 +196,21 @@ func (r *refNormalizer) VisitField(path string, v any) error { } } + if alertChart, ok := v.(*krm.IncidentList); ok { + for i, policyRef := range alertChart.PolicyRefs { + if ref, err := normalizeMonitoringAlertPolicyRef(r.ctx, r.kube, r.src, r.project, &policyRef); err != nil { + return err + } else { + prefix := fmt.Sprintf("projects/%s/", r.project.ProjectID) + if !strings.HasPrefix(ref.External, prefix) { + return fmt.Errorf("resolve alertPolicy (%q) in incidentList was not in same project", ref.External) + } + ref.External = strings.TrimPrefix(ref.External, prefix) + alertChart.PolicyRefs[i] = *ref + } + } + } + if projectRef, ok := v.(*refs.ProjectRef); ok { if ref, err := normalizeProjectRef(r.ctx, r.kube, r.src, projectRef); err != nil { return err 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 98420ae296..72939a72ef 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 @@ -122,9 +122,8 @@ spec: project_id: my-project zone: us-central1-a type: gce_instance - policyNames: - - foo - - bar + policyRefs: + - external: alertPolicies/${alertPolicyID} title: IncidentList Widget dashboardFilters: - filterType: RESOURCE_LABEL 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 df8731e21c..e455072c00 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 @@ -129,9 +129,8 @@ spec: project_id: my-project zone: us-central1-a type: gce_instance - policyNames: - - foo - - bar + policyRefs: + - name: monitoringalertpolicy-${uniqueId} title: IncidentList Widget dashboardFilters: - filterType: RESOURCE_LABEL 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 4c4d7b0374..04cf8766d3 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 @@ -380,8 +380,7 @@ x-goog-request-params: parent=projects%2F${projectId} } ], "policyNames": [ - "foo", - "bar" + "alertPolicies/${alertPolicyID}" ] }, "title": "IncidentList Widget" @@ -607,8 +606,7 @@ X-Xss-Protection: 0 } ], "policyNames": [ - "foo", - "bar" + "alertPolicies/${alertPolicyID}" ] }, "title": "IncidentList Widget" @@ -842,8 +840,7 @@ X-Xss-Protection: 0 } ], "policyNames": [ - "foo", - "bar" + "alertPolicies/${alertPolicyID}" ] }, "title": "IncidentList Widget" @@ -1065,8 +1062,7 @@ x-goog-request-params: dashboard.name=projects%2F${projectId}%2Fdashboards%2Fmon } ], "policyNames": [ - "foo", - "bar" + "alertPolicies/${alertPolicyID}" ] }, "title": "IncidentList Widget" @@ -1293,8 +1289,7 @@ X-Xss-Protection: 0 } ], "policyNames": [ - "foo", - "bar" + "alertPolicies/${alertPolicyID}" ] }, "title": "IncidentList Widget" @@ -1528,8 +1523,7 @@ X-Xss-Protection: 0 } ], "policyNames": [ - "foo", - "bar" + "alertPolicies/${alertPolicyID}" ] }, "title": "IncidentList Widget" 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 881770349d..3b8719f9bb 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 @@ -150,6 +150,5 @@ spec: project_id: my-project instance_id: "12345678901234" zone: "us-central1-a" - policyNames: - - foo - - bar + policyRefs: + - name: monitoringalertpolicy-${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardmosaiclayout/_http.log b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardmosaiclayout/_http.log index 914132427c..1355b42646 100644 --- a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardmosaiclayout/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardmosaiclayout/_http.log @@ -297,7 +297,7 @@ X-Xss-Protection: 0 "widget": { "text": { "content": "CollapsibleGroup content", - "format": "MARKDOWN", + "format": 1, "style": {} } }, @@ -370,7 +370,7 @@ X-Xss-Protection: 0 "widget": { "text": { "content": "CollapsibleGroup content", - "format": "MARKDOWN", + "format": 1, "style": {} } }, @@ -496,7 +496,7 @@ X-Xss-Protection: 0 "widget": { "text": { "content": "CollapsibleGroup content", - "format": "MARKDOWN", + "format": 1, "style": {} } }, @@ -569,7 +569,7 @@ X-Xss-Protection: 0 "widget": { "text": { "content": "CollapsibleGroup content", - "format": "MARKDOWN", + "format": 1, "style": {} } }, 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 4ef7636aa5..d80aee1380 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 @@ -105,8 +105,10 @@ columnLayout: - labels: string: string type: string - policyNames: - - string + policyRefs: + - external: string + name: string + namespace: string logsPanel: filter: string resourceNames: @@ -417,8 +419,10 @@ gridLayout: - labels: string: string type: string - policyNames: - - string + policyRefs: + - external: string + name: string + namespace: string logsPanel: filter: string resourceNames: @@ -725,8 +729,10 @@ mosaicLayout: - labels: string: string type: string - policyNames: - - string + policyRefs: + - external: string + name: string + namespace: string logsPanel: filter: string resourceNames: @@ -1041,8 +1047,10 @@ rowLayout: - labels: string: string type: string - policyNames: - - string + policyRefs: + - external: string + name: string + namespace: string logsPanel: filter: string resourceNames: @@ -1647,24 +1655,54 @@ rowLayout: -

columnLayout.columns[].widgets[].incidentList.policyNames

+

columnLayout.columns[].widgets[].incidentList.policyRefs

Optional

-

list (string)

-

{% verbatim %}Optional. A list of alert policy names to filter the incident list by. Don't include the project ID prefix in the policy name. For example, use `alertPolicies/utilization`.{% endverbatim %}

+

list (object)

+

{% verbatim %}Optional. A list of alert policies to filter the incident list by.{% endverbatim %}

-

columnLayout.columns[].widgets[].incidentList.policyNames[]

+

columnLayout.columns[].widgets[].incidentList.policyRefs[]

Optional

-

string

+

object

{% verbatim %}{% endverbatim %}

+ + +

columnLayout.columns[].widgets[].incidentList.policyRefs[].external

+

Optional

+ + +

string

+

{% verbatim %}The MonitoringAlertPolicy link in the form "projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]", when not managed by KCC.{% endverbatim %}

+ + + + +

columnLayout.columns[].widgets[].incidentList.policyRefs[].name

+

Optional

+ + +

string

+

{% verbatim %}The `name` field of a `MonitoringAlertPolicy` resource.{% endverbatim %}

+ + + + +

columnLayout.columns[].widgets[].incidentList.policyRefs[].namespace

+

Optional

+ + +

string

+

{% verbatim %}The `namespace` field of a `MonitoringAlertPolicy` resource.{% endverbatim %}

+ +

columnLayout.columns[].widgets[].logsPanel

@@ -5714,24 +5752,54 @@ rowLayout: -

gridLayout.widgets[].incidentList.policyNames

+

gridLayout.widgets[].incidentList.policyRefs

Optional

-

list (string)

-

{% verbatim %}Optional. A list of alert policy names to filter the incident list by. Don't include the project ID prefix in the policy name. For example, use `alertPolicies/utilization`.{% endverbatim %}

+

list (object)

+

{% verbatim %}Optional. A list of alert policies to filter the incident list by.{% endverbatim %}

-

gridLayout.widgets[].incidentList.policyNames[]

+

gridLayout.widgets[].incidentList.policyRefs[]

Optional

-

string

+

object

{% verbatim %}{% endverbatim %}

+ + +

gridLayout.widgets[].incidentList.policyRefs[].external

+

Optional

+ + +

string

+

{% verbatim %}The MonitoringAlertPolicy link in the form "projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]", when not managed by KCC.{% endverbatim %}

+ + + + +

gridLayout.widgets[].incidentList.policyRefs[].name

+

Optional

+ + +

string

+

{% verbatim %}The `name` field of a `MonitoringAlertPolicy` resource.{% endverbatim %}

+ + + + +

gridLayout.widgets[].incidentList.policyRefs[].namespace

+

Optional

+ + +

string

+

{% verbatim %}The `namespace` field of a `MonitoringAlertPolicy` resource.{% endverbatim %}

+ +

gridLayout.widgets[].logsPanel

@@ -9731,24 +9799,54 @@ rowLayout: -

mosaicLayout.tiles[].widget.incidentList.policyNames

+

mosaicLayout.tiles[].widget.incidentList.policyRefs

Optional

-

list (string)

-

{% verbatim %}Optional. A list of alert policy names to filter the incident list by. Don't include the project ID prefix in the policy name. For example, use `alertPolicies/utilization`.{% endverbatim %}

+

list (object)

+

{% verbatim %}Optional. A list of alert policies to filter the incident list by.{% endverbatim %}

-

mosaicLayout.tiles[].widget.incidentList.policyNames[]

+

mosaicLayout.tiles[].widget.incidentList.policyRefs[]

Optional

-

string

+

object

{% verbatim %}{% endverbatim %}

+ + +

mosaicLayout.tiles[].widget.incidentList.policyRefs[].external

+

Optional

+ + +

string

+

{% verbatim %}The MonitoringAlertPolicy link in the form "projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]", when not managed by KCC.{% endverbatim %}

+ + + + +

mosaicLayout.tiles[].widget.incidentList.policyRefs[].name

+

Optional

+ + +

string

+

{% verbatim %}The `name` field of a `MonitoringAlertPolicy` resource.{% endverbatim %}

+ + + + +

mosaicLayout.tiles[].widget.incidentList.policyRefs[].namespace

+

Optional

+ + +

string

+

{% verbatim %}The `namespace` field of a `MonitoringAlertPolicy` resource.{% endverbatim %}

+ +

mosaicLayout.tiles[].widget.logsPanel

@@ -13838,24 +13936,54 @@ rowLayout: -

rowLayout.rows[].widgets[].incidentList.policyNames

+

rowLayout.rows[].widgets[].incidentList.policyRefs

Optional

-

list (string)

-

{% verbatim %}Optional. A list of alert policy names to filter the incident list by. Don't include the project ID prefix in the policy name. For example, use `alertPolicies/utilization`.{% endverbatim %}

+

list (object)

+

{% verbatim %}Optional. A list of alert policies to filter the incident list by.{% endverbatim %}

-

rowLayout.rows[].widgets[].incidentList.policyNames[]

+

rowLayout.rows[].widgets[].incidentList.policyRefs[]

Optional

-

string

+

object

{% verbatim %}{% endverbatim %}

+ + +

rowLayout.rows[].widgets[].incidentList.policyRefs[].external

+

Optional

+ + +

string

+

{% verbatim %}The MonitoringAlertPolicy link in the form "projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]", when not managed by KCC.{% endverbatim %}

+ + + + +

rowLayout.rows[].widgets[].incidentList.policyRefs[].name

+

Optional

+ + +

string

+

{% verbatim %}The `name` field of a `MonitoringAlertPolicy` resource.{% endverbatim %}

+ + + + +

rowLayout.rows[].widgets[].incidentList.policyRefs[].namespace

+

Optional

+ + +

string

+

{% verbatim %}The `namespace` field of a `MonitoringAlertPolicy` resource.{% endverbatim %}

+ +

rowLayout.rows[].widgets[].logsPanel

diff --git a/tests/e2e/normalize.go b/tests/e2e/normalize.go index 26f7db4e4f..4389a0fefc 100644 --- a/tests/e2e/normalize.go +++ b/tests/e2e/normalize.go @@ -110,7 +110,19 @@ func normalizeKRMObject(u *unstructured.Unstructured, project testgcp.GCPProject visitor.stringTransforms = append(visitor.stringTransforms, func(path string, s string) string { if strings.HasSuffix(path, ".alertChart.alertPolicyRef.external") { tokens := strings.Split(s, "/") - if len(tokens) > 2 { + if len(tokens) >= 2 { + switch tokens[len(tokens)-2] { + case "alertPolicies": + s = strings.ReplaceAll(s, tokens[len(tokens)-1], "${alertPolicyID}") + } + } + } + return s + }) + visitor.stringTransforms = append(visitor.stringTransforms, func(path string, s string) string { + if strings.HasSuffix(path, ".policyRefs[].external") { + tokens := strings.Split(s, "/") + if len(tokens) >= 2 { switch tokens[len(tokens)-2] { case "alertPolicies": s = strings.ReplaceAll(s, tokens[len(tokens)-1], "${alertPolicyID}")