From 7a1fc246853a02f0bea28722aec186700f0618be Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 2 Feb 2021 10:37:21 -0500 Subject: [PATCH] Fix regex for ondemand instances It appears we renamed `/ondemand/` to `/ondemandvm/` at some point and, as a result, have not been stripping hostnames from that endpoint's metrics. This has caused issues with metrics collection due a very high cardinality. --- lib/vmpooler/metrics/promstats/collector_middleware.rb | 2 +- spec/unit/collector_middleware_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/vmpooler/metrics/promstats/collector_middleware.rb b/lib/vmpooler/metrics/promstats/collector_middleware.rb index 540b1e60a..c7e8325bb 100644 --- a/lib/vmpooler/metrics/promstats/collector_middleware.rb +++ b/lib/vmpooler/metrics/promstats/collector_middleware.rb @@ -113,7 +113,7 @@ def strip_hostnames_from_path(path) # Similarly, request IDs are also stripped from the /ondemand path. path .gsub(%r{/vm/.+$}, '/vm') - .gsub(%r{/ondemand/.+$}, '/ondemand') + .gsub(%r{/ondemandvm/.+$}, '/ondemandvm') .gsub(%r{/token/.+$}, '/token') .gsub(%r{/lib/.+$}, '/lib') .gsub(%r{/img/.+$}, '/img') diff --git a/spec/unit/collector_middleware_spec.rb b/spec/unit/collector_middleware_spec.rb index 5244c2559..704ac5aa2 100644 --- a/spec/unit/collector_middleware_spec.rb +++ b/spec/unit/collector_middleware_spec.rb @@ -72,14 +72,14 @@ it 'normalizes paths containing /ondemandvm by ' do expect(Benchmark).to receive(:realtime).and_yield.and_return(0.3) - get '/foo/ondemand/bar/fatman' + get '/foo/ondemandvm/bar/fatman' metric = :http_server_requests_total - labels = { method: 'get', path: '/foo/ondemand', code: '200' } + labels = { method: 'get', path: '/foo/ondemandvm', code: '200' } expect(registry.get(metric).get(labels: labels)).to eql(1.0) metric = :http_server_request_duration_seconds - labels = { method: 'get', path: '/foo/ondemand' } + labels = { method: 'get', path: '/foo/ondemandvm' } expect(registry.get(metric).get(labels: labels)).to include("0.1" => 0, "0.5" => 1) end