From 05e662469e69ff3096065698523e643d6fdb8f39 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Fri, 27 Aug 2021 11:30:25 +0200 Subject: [PATCH] Fix missing quantile in `latency_microseconds_total` metrics The quantile has to be added manually since a couple of prometheus client releases and we missed that. Adding an integration test to ensure that the quantile exist in the future. Signed-off-by: Sascha Grunert --- server/metrics/metrics.go | 7 ++++--- test/metrics.bats | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) 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" \