Skip to content

Commit

Permalink
Merge pull request #126237 from cici37/promoteMetrics
Browse files Browse the repository at this point in the history
Promote metrics for VAP and CRD validation rules to beta.
  • Loading branch information
k8s-ci-robot authored Jul 22, 2024
2 parents 0caeba5 + 1e5062c commit 887def0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func newValidationAdmissionMetrics() *ValidatingAdmissionPolicyMetrics {
Subsystem: metricsSubsystem,
Name: "check_total",
Help: "Validation admission policy check total, labeled by policy and further identified by binding and enforcement action taken.",
StabilityLevel: metrics.ALPHA,
StabilityLevel: metrics.BETA,
},
[]string{"policy", "policy_binding", "error_type", "enforcement_action"},
)
Expand All @@ -81,7 +81,7 @@ func newValidationAdmissionMetrics() *ValidatingAdmissionPolicyMetrics {
// around 760ms, so that bucket should only ever have the slowest CEL expressions
// in it
Buckets: []float64{0.0000005, 0.001, 0.01, 0.1, 1.0},
StabilityLevel: metrics.ALPHA,
StabilityLevel: metrics.BETA,
},
[]string{"policy", "policy_binding", "error_type", "enforcement_action"},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestNoUtils(t *testing.T) {
{
desc: "observe policy admission",
want: `
# HELP apiserver_validating_admission_policy_check_duration_seconds [ALPHA] Validation admission latency for individual validation expressions in seconds, labeled by policy and further including binding and enforcement action taken.
# HELP apiserver_validating_admission_policy_check_duration_seconds [BETA] Validation admission latency for individual validation expressions in seconds, labeled by policy and further including binding and enforcement action taken.
# TYPE apiserver_validating_admission_policy_check_duration_seconds histogram
apiserver_validating_admission_policy_check_duration_seconds_bucket{enforcement_action="allow",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com",le="0.0000005"} 0
apiserver_validating_admission_policy_check_duration_seconds_bucket{enforcement_action="allow",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com",le="0.001"} 0
Expand All @@ -53,7 +53,7 @@ func TestNoUtils(t *testing.T) {
apiserver_validating_admission_policy_check_duration_seconds_bucket{enforcement_action="allow",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com",le="+Inf"} 1
apiserver_validating_admission_policy_check_duration_seconds_sum{enforcement_action="allow",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com"} 10
apiserver_validating_admission_policy_check_duration_seconds_count{enforcement_action="allow",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com"} 1
# HELP apiserver_validating_admission_policy_check_total [ALPHA] Validation admission policy check total, labeled by policy and further identified by binding and enforcement action taken.
# HELP apiserver_validating_admission_policy_check_total [BETA] Validation admission policy check total, labeled by policy and further identified by binding and enforcement action taken.
# TYPE apiserver_validating_admission_policy_check_total counter
apiserver_validating_admission_policy_check_total{enforcement_action="allow",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com"} 1
`,
Expand All @@ -64,7 +64,7 @@ func TestNoUtils(t *testing.T) {
{
desc: "observe policy rejection",
want: `
# HELP apiserver_validating_admission_policy_check_duration_seconds [ALPHA] Validation admission latency for individual validation expressions in seconds, labeled by policy and further including binding and enforcement action taken.
# HELP apiserver_validating_admission_policy_check_duration_seconds [BETA] Validation admission latency for individual validation expressions in seconds, labeled by policy and further including binding and enforcement action taken.
# TYPE apiserver_validating_admission_policy_check_duration_seconds histogram
apiserver_validating_admission_policy_check_duration_seconds_bucket{enforcement_action="deny",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com",le="0.0000005"} 0
apiserver_validating_admission_policy_check_duration_seconds_bucket{enforcement_action="deny",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com",le="0.001"} 0
Expand All @@ -74,7 +74,7 @@ func TestNoUtils(t *testing.T) {
apiserver_validating_admission_policy_check_duration_seconds_bucket{enforcement_action="deny",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com",le="+Inf"} 1
apiserver_validating_admission_policy_check_duration_seconds_sum{enforcement_action="deny",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com"} 10
apiserver_validating_admission_policy_check_duration_seconds_count{enforcement_action="deny",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com"} 1
# HELP apiserver_validating_admission_policy_check_total [ALPHA] Validation admission policy check total, labeled by policy and further identified by binding and enforcement action taken.
# HELP apiserver_validating_admission_policy_check_total [BETA] Validation admission policy check total, labeled by policy and further identified by binding and enforcement action taken.
# TYPE apiserver_validating_admission_policy_check_total counter
apiserver_validating_admission_policy_check_total{enforcement_action="deny",error_type="invalid_error",policy="policy.example.com",policy_binding="binding.example.com"} 1
`,
Expand Down
4 changes: 2 additions & 2 deletions staging/src/k8s.io/apiserver/pkg/cel/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ func newCelMetrics() *CelMetrics {
Subsystem: subsystem,
Name: "compilation_duration_seconds",
Help: "CEL compilation time in seconds.",
StabilityLevel: metrics.ALPHA,
StabilityLevel: metrics.BETA,
}),
evaluationTime: metrics.NewHistogram(&metrics.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "evaluation_duration_seconds",
Help: "CEL evaluation time in seconds.",
StabilityLevel: metrics.ALPHA,
StabilityLevel: metrics.BETA,
}),
}

Expand Down
42 changes: 42 additions & 0 deletions test/instrumentation/testdata/stable-metrics-list.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
- name: compilation_duration_seconds
subsystem: cel
namespace: apiserver
help: CEL compilation time in seconds.
type: Histogram
stabilityLevel: BETA
- name: evaluation_duration_seconds
subsystem: cel
namespace: apiserver
help: CEL evaluation time in seconds.
type: Histogram
stabilityLevel: BETA
- name: current_executing_requests
subsystem: flowcontrol
namespace: apiserver
Expand Down Expand Up @@ -80,6 +92,36 @@
- 10
- 15
- 30
- name: check_duration_seconds
subsystem: validating_admission_policy
namespace: apiserver
help: Validation admission latency for individual validation expressions in seconds,
labeled by policy and further including binding and enforcement action taken.
type: Histogram
stabilityLevel: BETA
labels:
- enforcement_action
- error_type
- policy
- policy_binding
buckets:
- 5e-07
- 0.001
- 0.01
- 0.1
- 1
- name: check_total
subsystem: validating_admission_policy
namespace: apiserver
help: Validation admission policy check total, labeled by policy and further identified
by binding and enforcement action taken.
type: Counter
stabilityLevel: BETA
labels:
- enforcement_action
- error_type
- policy
- policy_binding
- name: disabled_metrics_total
help: The count of disabled metrics.
type: Counter
Expand Down

0 comments on commit 887def0

Please sign in to comment.