diff --git a/pkg/metrics/admissionrequests/admissionRequests.go b/pkg/metrics/admissionrequests/admissionRequests.go index d9ad22afa6..bd114065ba 100644 --- a/pkg/metrics/admissionrequests/admissionRequests.go +++ b/pkg/metrics/admissionrequests/admissionRequests.go @@ -7,11 +7,10 @@ import ( ) func (pm PromMetrics) registerAdmissionRequestsMetric( - resourceName, resourceKind, resourceNamespace string, + resourceKind, resourceNamespace string, resourceRequestOperation metrics.ResourceRequestOperation, ) error { pm.AdmissionRequests.With(prom.Labels{ - "resource_name": resourceName, "resource_kind": resourceKind, "resource_namespace": resourceNamespace, "resource_request_operation": string(resourceRequestOperation), @@ -23,7 +22,7 @@ func (pm PromMetrics) ProcessEngineResponses(engineResponses []*response.EngineR if len(engineResponses) == 0 { return nil } - resourceName, resourceNamespace, resourceKind := engineResponses[0].PolicyResponse.Resource.Name, engineResponses[0].PolicyResponse.Resource.Namespace, engineResponses[0].PolicyResponse.Resource.Kind + resourceNamespace, resourceKind := engineResponses[0].PolicyResponse.Resource.Namespace, engineResponses[0].PolicyResponse.Resource.Kind totalValidateRulesCount, totalMutateRulesCount, totalGenerateRulesCount := 0, 0, 0 for _, e := range engineResponses { validateRulesCount, mutateRulesCount, generateRulesCount := 0, 0, 0 @@ -49,5 +48,5 @@ func (pm PromMetrics) ProcessEngineResponses(engineResponses []*response.EngineR if totalValidateRulesCount+totalMutateRulesCount+totalGenerateRulesCount == 0 { return nil } - return pm.registerAdmissionRequestsMetric(resourceName, resourceKind, resourceNamespace, resourceRequestOperation) + return pm.registerAdmissionRequestsMetric(resourceKind, resourceNamespace, resourceRequestOperation) } diff --git a/pkg/metrics/admissionreviewduration/admissionReviewDuration.go b/pkg/metrics/admissionreviewduration/admissionReviewDuration.go index 92d0a232c0..5cab35b9df 100644 --- a/pkg/metrics/admissionreviewduration/admissionReviewDuration.go +++ b/pkg/metrics/admissionreviewduration/admissionReviewDuration.go @@ -7,12 +7,11 @@ import ( ) func (pm PromMetrics) registerAdmissionReviewDurationMetric( - resourceName, resourceKind, resourceNamespace string, + resourceKind, resourceNamespace string, resourceRequestOperation metrics.ResourceRequestOperation, admissionRequestLatency float64, ) error { pm.AdmissionReviewDuration.With(prom.Labels{ - "resource_name": resourceName, "resource_kind": resourceKind, "resource_namespace": resourceNamespace, "resource_request_operation": string(resourceRequestOperation), @@ -24,7 +23,7 @@ func (pm PromMetrics) ProcessEngineResponses(engineResponses []*response.EngineR if len(engineResponses) == 0 { return nil } - resourceName, resourceNamespace, resourceKind := engineResponses[0].PolicyResponse.Resource.Name, engineResponses[0].PolicyResponse.Resource.Namespace, engineResponses[0].PolicyResponse.Resource.Kind + resourceNamespace, resourceKind := engineResponses[0].PolicyResponse.Resource.Namespace, engineResponses[0].PolicyResponse.Resource.Kind totalValidateRulesCount, totalMutateRulesCount, totalGenerateRulesCount := 0, 0, 0 for _, e := range engineResponses { validateRulesCount, mutateRulesCount, generateRulesCount := 0, 0, 0 @@ -51,5 +50,5 @@ func (pm PromMetrics) ProcessEngineResponses(engineResponses []*response.EngineR return nil } admissionReviewLatencyDurationInSeconds := float64(admissionReviewLatencyDuration) / float64(1000*1000*1000) - return pm.registerAdmissionReviewDurationMetric(resourceName, resourceKind, resourceNamespace, resourceRequestOperation, admissionReviewLatencyDurationInSeconds) + return pm.registerAdmissionReviewDurationMetric(resourceKind, resourceNamespace, resourceRequestOperation, admissionReviewLatencyDurationInSeconds) } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 7e88d76cd5..e300932222 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -25,7 +25,7 @@ func NewPromConfig() *PromConfig { policyResultsLabels := []string{ "policy_validation_mode", "policy_type", "policy_background_mode", "policy_name", "policy_namespace", - "resource_name", "resource_kind", "resource_namespace", "resource_request_operation", + "resource_kind", "resource_namespace", "resource_request_operation", "rule_name", "rule_result", "rule_type", "rule_execution_cause", } policyResultsMetric := prom.NewCounterVec( @@ -60,7 +60,7 @@ func NewPromConfig() *PromConfig { policyExecutionDurationLabels := []string{ "policy_validation_mode", "policy_type", "policy_background_mode", "policy_name", "policy_namespace", - "resource_name", "resource_kind", "resource_namespace", "resource_request_operation", + "resource_kind", "resource_namespace", "resource_request_operation", "rule_name", "rule_result", "rule_type", "rule_execution_cause", "generate_rule_latency_type", } policyExecutionDurationMetric := prom.NewHistogramVec( @@ -72,7 +72,7 @@ func NewPromConfig() *PromConfig { ) admissionReviewDurationLabels := []string{ - "resource_name", "resource_kind", "resource_namespace", "resource_request_operation", + "resource_kind", "resource_namespace", "resource_request_operation", } admissionReviewDurationMetric := prom.NewHistogramVec( prom.HistogramOpts{ @@ -83,7 +83,7 @@ func NewPromConfig() *PromConfig { ) admissionRequestsLabels := []string{ - "resource_name", "resource_kind", "resource_namespace", "resource_request_operation", + "resource_kind", "resource_namespace", "resource_request_operation", } admissionRequestsMetric := prom.NewCounterVec( prom.CounterOpts{ diff --git a/pkg/metrics/policyexecutionduration/policyExecutionDuration.go b/pkg/metrics/policyexecutionduration/policyExecutionDuration.go index 0b88c8761c..c690ef7fc9 100644 --- a/pkg/metrics/policyexecutionduration/policyExecutionDuration.go +++ b/pkg/metrics/policyexecutionduration/policyExecutionDuration.go @@ -12,7 +12,7 @@ func (pm PromMetrics) registerPolicyExecutionDurationMetric( policyType metrics.PolicyType, policyBackgroundMode metrics.PolicyBackgroundMode, policyNamespace, policyName string, - resourceName, resourceKind, resourceNamespace string, + resourceKind, resourceNamespace string, resourceRequestOperation metrics.ResourceRequestOperation, ruleName string, ruleResult metrics.RuleResult, @@ -33,7 +33,6 @@ func (pm PromMetrics) registerPolicyExecutionDurationMetric( "policy_background_mode": string(policyBackgroundMode), "policy_namespace": policyNamespace, "policy_name": policyName, - "resource_name": resourceName, "resource_kind": resourceKind, "resource_namespace": resourceNamespace, "resource_request_operation": string(resourceRequestOperation), @@ -65,7 +64,6 @@ func (pm PromMetrics) ProcessEngineResponse(policy kyverno.ClusterPolicy, engine resourceSpec := engineResponse.PolicyResponse.Resource - resourceName := resourceSpec.Name resourceKind := resourceSpec.Kind resourceNamespace := resourceSpec.Namespace @@ -86,7 +84,7 @@ func (pm PromMetrics) ProcessEngineResponse(policy kyverno.ClusterPolicy, engine policyType, policyBackgroundMode, policyNamespace, policyName, - resourceName, resourceKind, resourceNamespace, + resourceKind, resourceNamespace, resourceRequestOperation, ruleName, ruleResult, diff --git a/pkg/metrics/policyresults/policyResults.go b/pkg/metrics/policyresults/policyResults.go index c0a2440002..82e0266534 100644 --- a/pkg/metrics/policyresults/policyResults.go +++ b/pkg/metrics/policyresults/policyResults.go @@ -12,7 +12,7 @@ func (pm PromMetrics) registerPolicyResultsMetric( policyType metrics.PolicyType, policyBackgroundMode metrics.PolicyBackgroundMode, policyNamespace, policyName string, - resourceName, resourceKind, resourceNamespace string, + resourceKind, resourceNamespace string, resourceRequestOperation metrics.ResourceRequestOperation, ruleName string, ruleResult metrics.RuleResult, @@ -28,7 +28,6 @@ func (pm PromMetrics) registerPolicyResultsMetric( "policy_background_mode": string(policyBackgroundMode), "policy_namespace": policyNamespace, "policy_name": policyName, - "resource_name": resourceName, "resource_kind": resourceKind, "resource_namespace": resourceNamespace, "resource_request_operation": string(resourceRequestOperation), @@ -59,7 +58,6 @@ func (pm PromMetrics) ProcessEngineResponse(policy kyverno.ClusterPolicy, engine resourceSpec := engineResponse.PolicyResponse.Resource - resourceName := resourceSpec.Name resourceKind := resourceSpec.Kind resourceNamespace := resourceSpec.Namespace @@ -78,7 +76,7 @@ func (pm PromMetrics) ProcessEngineResponse(policy kyverno.ClusterPolicy, engine policyType, policyBackgroundMode, policyNamespace, policyName, - resourceName, resourceKind, resourceNamespace, + resourceKind, resourceNamespace, resourceRequestOperation, ruleName, ruleResult,