Migrate Workhorse route matchers to use route_id instead of route
In https://gitlab.com/gitlab-com/runbooks/-/blob/f9cd633fceff4a5ed1eacb796c271538b2f969f9/metrics-catalog/services/web.jsonnet#L111-131, the ugly regexp is route is used for Workhorse metrics, but Workhorse now offers a much friendly route_id that can be used instead. This is especially important now because the route values are going to be changing.
Related links:
Months ago I think I started on this, but then I ran into conflicts and got sidetracked:
diff --git a/reference-architectures/get-hybrid/src/services/webservice.jsonnet b/reference-architectures/get-hybrid/src/services/webservice.jsonnet
index aaca4df8b..c83d1bfe1 100644
--- a/reference-architectures/get-hybrid/src/services/webservice.jsonnet
+++ b/reference-architectures/get-hybrid/src/services/webservice.jsonnet
@@ -82,28 +82,28 @@ metricsCatalog.serviceDefinition({
},
local workhorseSelector = {
- route: {
+ route_id: {
ne: workhorseRoutes.escapeForLiterals(|||
- ^/-/health$
- ^/-/(readiness|liveness)$
+ ^health$
+ ^liveness$
|||),
},
},
// Routes associated with api traffic
- local apiRoutes = ['^\\\\^/api/.*'],
+ local apiRoutes = ['^api'],
// Routes associated with git traffic
local gitRouteRegexps = workhorseRoutes.escapeForRegexp(|||
- ^/.+\.git/git-receive-pack\z
- ^/.+\.git/git-upload-pack\z
- ^/.+\.git/gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z
- ^/.+\.git/info/refs\z
+ ^git_receive_pack\z
+ ^git_upload_pack\z
+ ^git_lfs_objects\z
+ ^git_info_refs\z
|||),
- local nonAPIWorkhorseSelector = workhorseSelector { route+: { nre+: apiRoutes, noneOf: gitRouteRegexps } },
- local apiWorkhorseSelector = workhorseSelector { route+: { re+: apiRoutes } },
- local gitWorkhorseSelector = { route: { oneOf: gitRouteRegexps } },
+ local nonAPIWorkhorseSelector = workhorseSelector { route_id+: { nre+: apiRoutes, noneOf: gitRouteRegexps } },
+ local apiWorkhorseSelector = workhorseSelector { route_id+: { re+: apiRoutes } },
+ local gitWorkhorseSelector = { route_id: { oneOf: gitRouteRegexps } },
workhorse: {
userImpacting: true,
@@ -119,11 +119,16 @@ metricsCatalog.serviceDefinition({
selector=nonAPIWorkhorseSelector {
// In addition to excluding all git and API traffic, exclude
// these routes from apdex as they have variable durations
- route+: {
+ route_id+: {
ne+: workhorseRoutes.escapeForLiterals(|||
+<<<<<<< HEAD
^/([^/]+/){1,}[^/]+/uploads\z
^/-/cable\z
^/v2/.+/containers/.+/blobs/sha256:[a-z0-9]+\z
+=======
+ ^project_uploads\z
+ ^action_cable\z
+>>>>>>> eeb90b831 (Use newly-introduced Workhorse route_id instead of route)
|||),
},
},
@@ -143,7 +148,7 @@ metricsCatalog.serviceDefinition({
},
),
- significantLabels: ['route', 'code'],
+ significantLabels: ['route', 'route_id', 'code'],
toolingLinks: [],
},
@@ -175,7 +180,7 @@ metricsCatalog.serviceDefinition({
},
),
- significantLabels: ['route', 'code'],
+ significantLabels: ['route', 'route_id', 'code'],
toolingLinks: [],
},
@@ -195,8 +200,8 @@ metricsCatalog.serviceDefinition({
histogram='gitlab_workhorse_http_request_duration_seconds_bucket',
selector={
// We only use the info-refs endpoint, not long-duration clone endpoints
- route: workhorseRoutes.escapeForLiterals(|||
- ^/.+\.git/info/refs\z
+ route_id: workhorseRoutes.escapeForLiterals(|||
+ ^git_info_refs\z
|||),
},
satisfiedThreshold=10
@@ -214,7 +219,7 @@ metricsCatalog.serviceDefinition({
},
),
- significantLabels: ['route', 'code'],
+ significantLabels: ['route', 'route_id', 'code'],
toolingLinks: [],
},
Edited by Stan Hu