diff --git a/pkg/metrics/policyexecutionduration/policyExecutionDuration.go b/pkg/metrics/policyexecutionduration/policyExecutionDuration.go index 747831b17e..af2eb046ee 100644 --- a/pkg/metrics/policyexecutionduration/policyExecutionDuration.go +++ b/pkg/metrics/policyexecutionduration/policyExecutionDuration.go @@ -48,10 +48,12 @@ func registerPolicyExecutionDurationMetric( //policy - policy related data //engineResponse - resource and rule related data func ProcessEngineResponse(m *metrics.MetricsConfig, policy kyvernov1.PolicyInterface, engineResponse response.EngineResponse, executionCause metrics.RuleExecutionCause, generateRuleLatencyType string, resourceRequestOperation metrics.ResourceRequestOperation) error { - name, namespace, policyType, backgroundMode, validationMode, err := metrics.GetPolicyInfos(policy) + name, namespace, policyType, backgroundMode, _, _ := metrics.GetPolicyInfos(policy) + validationMode, err := metrics.ParsePolicyValidationMode(engineResponse.GetValidationFailureAction()) if err != nil { return err } + resourceSpec := engineResponse.PolicyResponse.Resource resourceKind := resourceSpec.Kind resourceNamespace := resourceSpec.Namespace diff --git a/pkg/metrics/policyresults/policyResults.go b/pkg/metrics/policyresults/policyResults.go index d10248959e..6af75e9cd2 100644 --- a/pkg/metrics/policyresults/policyResults.go +++ b/pkg/metrics/policyresults/policyResults.go @@ -43,10 +43,12 @@ func registerPolicyResultsMetric( //policy - policy related data //engineResponse - resource and rule related data func ProcessEngineResponse(m *metrics.MetricsConfig, policy kyvernov1.PolicyInterface, engineResponse response.EngineResponse, executionCause metrics.RuleExecutionCause, resourceRequestOperation metrics.ResourceRequestOperation) error { - name, namespace, policyType, backgroundMode, validationMode, err := metrics.GetPolicyInfos(policy) + name, namespace, policyType, backgroundMode, _, _ := metrics.GetPolicyInfos(policy) + validationMode, err := metrics.ParsePolicyValidationMode(engineResponse.GetValidationFailureAction()) if err != nil { return err } + resourceSpec := engineResponse.PolicyResponse.Resource resourceKind := resourceSpec.Kind resourceNamespace := resourceSpec.Namespace