diff --git a/server/metrics/metrics.go b/server/metrics/metrics.go index 25e0676efe3..bd2d7330833 100644 --- a/server/metrics/metrics.go +++ b/server/metrics/metrics.go @@ -71,9 +71,10 @@ func New(config *libconfig.MetricsConfig) *Metrics { ), metricOperationsLatencyTotal: prometheus.NewSummaryVec( prometheus.SummaryOpts{ - Subsystem: collectors.Subsystem, - Name: collectors.OperationsLatencyTotal.String(), - Help: "Latency in microseconds of CRI-O operations. Broken down by operation type.", + Subsystem: collectors.Subsystem, + Name: collectors.OperationsLatencyTotal.String(), + Help: "Latency in microseconds of CRI-O operations. Broken down by operation type.", + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }, []string{"operation_type"}, ), diff --git a/test/metrics.bats b/test/metrics.bats index 4a9e2523b06..fdab166ba74 100644 --- a/test/metrics.bats +++ b/test/metrics.bats @@ -34,6 +34,21 @@ function teardown() { curl -sf "http://localhost:$PORT/metrics" | grep crio_operations } +@test "metrics with operations quantile" { + # start crio with custom port + PORT=$(free_port) + CONTAINER_ENABLE_METRICS=true CONTAINER_METRICS_PORT=$PORT start_crio + + for ((i = 0; i < 100; i++)); do + crictl version + done + + # get metrics + curl -sf "http://localhost:$PORT/metrics" | grep 'container_runtime_crio_operations_latency_microseconds_total{operation_type="Version",quantile="0.5"}' + curl -sf "http://localhost:$PORT/metrics" | grep 'container_runtime_crio_operations_latency_microseconds_total{operation_type="Version",quantile="0.9"}' + curl -sf "http://localhost:$PORT/metrics" | grep 'container_runtime_crio_operations_latency_microseconds_total{operation_type="Version",quantile="0.99"}' +} + @test "secure metrics with random port" { openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \ -subj "/C=US/ST=State/L=City/O=Org/CN=Name" \