diff --git a/bin/observe-cli-resources.json b/bin/observe-cli-resources.json index 3d7bcbd1ead..72bf07f49cd 100644 --- a/bin/observe-cli-resources.json +++ b/bin/observe-cli-resources.json @@ -1,5 +1,5 @@ { - "_comment": "Resources to keep in sync with the latest CLI version. Consumed by bin/update-observe.js, which fetches the live config for each resource and only patches the version-relevant fields (in-place: any X.Y.Z literal found in the name, raw SLI expression, or version filter is rewritten). For alerts and error projects, versionFilterColumn names the filter holding the CLI version.", + "_comment": "Resources that track the newest CLI release line. Consumed by bin/update-observe.js, which fetches the live config for each resource and only patches the version-relevant fields to match the line (bin/observe-version.js): versions in the name become X.Y.x, cli_version matchers in a raw SLI expression or histogram filters become the regex X[.]Y[.][0-9]+, and the version filter of an alert or error project starts with X.Y. SLIs also drop the job matcher on @shopify/(app|store):.*, and a traffic guard that multiplies becomes a filter. For alerts and error projects, versionFilterColumn names the filter holding the CLI version.", "endpoint": "https://shopify-monitoring.shopifycloud.com/query", "service": "cli", "resources": [ diff --git a/bin/observe-version.js b/bin/observe-version.js new file mode 100644 index 00000000000..ff3b4874f5d --- /dev/null +++ b/bin/observe-version.js @@ -0,0 +1,128 @@ +// The release-line forms bin/update-observe.js writes into the CLI's Observe resources. They track a +// minor's whole line, X.Y.x, so its patches need no Observe update: only a new minor or major moves them. + +const minorVersionPattern = /^(\d+)\.(\d+)\.0$/ + +// The SLI forms also make two changes that leave an SLI without them as it is. The SLOs no longer select commands +// by this job matcher, so the forms drop it and keep every other job matcher. +const staleJobFilter = {key: 'job', op: '=~', value: '@shopify/(app|store):.*'} +const staleJobMatcher = /job\s*=~\s*"@shopify\/\(app\|store\):\.\*"/.source +// The matcher with the comma that joins it to a neighbour, wherever it sits in a selector. +const staleJobMatcherInSelector = new RegExp( + `${staleJobMatcher}\\s*,\\s*|\\s*,\\s*${staleJobMatcher}|${staleJobMatcher}`, + 'g', +) +const isStaleJobFilter = (filter) => + filter.key === staleJobFilter.key && filter.op === staleJobFilter.op && filter.value === staleJobFilter.value + +// A traffic guard that multiplies, `ratio * on() (sum(rate(cli_commands_total{...}[w])) > n)`, keeps the rate's +// value, since a comparison without `bool` keeps its left side, so `1 - ratio * ...` counts errors a second rather +// than their share. The forms make it a filter, `and on()`, so the SLI is the ratio while the guard holds. +const multipliedTrafficGuard = + /\*(\s*on\(\)\s*\(\s*sum\(rate\(cli_commands_total\{[^}]*\}\s*\[\w+\]\)\)\s*>\s*[\d.]+\s*\))/g + +/** + * The release line a minor or major version starts, or undefined for a patch or anything else. + * + * @param {string} version + * @returns {{major: string, minor: string} | undefined} + */ +export function releaseLine(version) { + const match = minorVersionPattern.exec(version) + return match ? {major: match[1], minor: match[2]} : undefined +} + +/** + * Why update-observe takes no version but a minor or major, X.Y.0. A patch's line may still be pinned to one + * version, from before the resources tracked lines, so the reason says how to move them onto the line. + * + * @param {string} version + * @returns {string} + */ +export function versionRefusal(version) { + const patch = /^(\d+)\.(\d+)\.\d+$/.exec(version) + if (!patch) return `Version must be a minor or major release, X.Y.0 (got: ${version})` + const lineStart = `${patch[1]}.${patch[2]}.0` + return `${version} is a patch: the resources track the ${patch[1]}.${patch[2]} line, so it needs no update. Run this for a minor or major release, X.Y.0. If the resources still pin one version, run this once with --version=${lineStart}.` +} + +/** + * The PromQL regex that matches every version of a line: `[.]` keeps backslashes out of PromQL strings. + * + * @param {{major: string, minor: string}} line + * @returns {string} + */ +export function lineRegex(line) { + return `${line.major}[.]${line.minor}[.][0-9]+` +} + +/** + * A resource name with each version in it, such as `5.2.0`, `v4.9.4` or `5.1.x`, replaced by the line, + * `5.2.x`, keeping a leading `v`. + * + * @param {string} name + * @param {{major: string, minor: string}} line + * @returns {string} + */ +export function lineName(name, line) { + return name.replace( + /(? `${prefix}${line.major}.${line.minor}.x`, + ) +} + +/** + * A PromQL expression with each `cli_version` matcher, exact or a regex, matching the line instead. It also drops + * the stale job matcher and makes a multiplied traffic guard a filter. + * + * @param {string} expression + * @param {{major: string, minor: string}} line + * @returns {string} + */ +export function lineExpression(expression, line) { + return expression + .replace(staleJobMatcherInSelector, '') + .replace(multipliedTrafficGuard, 'and$1') + .replace(/cli_version\s*=~?\s*"[^"]*"/g, `cli_version=~"${lineRegex(line)}"`) +} + +/** + * A histogram SLI's metric filters with the `cli_version` filter matching the line, and without the stale job + * filter. + * + * @param {{key: string, op: string, value: string}[]} filters + * @param {{major: string, minor: string}} line + * @returns {{key: string, op: string, value: string}[]} + */ +export function lineHistogramFilters(filters, line) { + return filters + .filter((filter) => !isStaleJobFilter(filter)) + .map((filter) => + filter.key === 'cli_version' && ['=', '=~'].includes(filter.op) + ? {...filter, op: '=~', value: lineRegex(line)} + : filter, + ) +} + +/** + * An error filter, as alerts and error projects store it (JSON with nested filter groups), with the + * filters on `column` matching every version that starts with the line, `5.2.`. + * + * @param {string} filterJson + * @param {string} column + * @param {{major: string, minor: string}} line + * @returns {string} + */ +export function lineErrorFilters(filterJson, column, line) { + const patchGroup = (group) => ({ + ...group, + filters: + group.filters?.map((filter) => + filter.column === column && ['=', 'starts-with'].includes(filter.op) + ? {...filter, op: 'starts-with', value: `${line.major}.${line.minor}.`} + : filter, + ) ?? group.filters, + filter_groups: group.filter_groups?.map(patchGroup) ?? group.filter_groups, + }) + return JSON.stringify(patchGroup(JSON.parse(filterJson))) +} diff --git a/bin/observe-version.test.js b/bin/observe-version.test.js new file mode 100644 index 00000000000..4c002237ddc --- /dev/null +++ b/bin/observe-version.test.js @@ -0,0 +1,187 @@ +import assert from 'node:assert/strict' +import {test} from 'node:test' + +import { + lineErrorFilters, + lineExpression, + lineHistogramFilters, + lineName, + lineRegex, + releaseLine, + versionRefusal, +} from './observe-version.js' + +const line52 = releaseLine('5.2.0') +const line53 = releaseLine('5.3.0') + +test('a minor or major release starts a line, and a patch does not', () => { + assert.deepEqual(releaseLine('5.2.0'), {major: '5', minor: '2'}) + assert.deepEqual(releaseLine('6.0.0'), {major: '6', minor: '0'}) + assert.equal(releaseLine('5.2.1'), undefined) + assert.equal(releaseLine('5.2'), undefined) + assert.equal(releaseLine('0.0.0-nightly-20261204061218'), undefined) + assert.equal(lineRegex(line52), '5[.]2[.][0-9]+') +}) + +test("a patch is refused with how to move a line that still pins one version, and a non-release isn't a version", () => { + assert.equal( + versionRefusal('5.2.1'), + '5.2.1 is a patch: the resources track the 5.2 line, so it needs no update. Run this for a minor or major release, X.Y.0. If the resources still pin one version, run this once with --version=5.2.0.', + ) + assert.equal(versionRefusal('5.2'), 'Version must be a minor or major release, X.Y.0 (got: 5.2)') +}) + +test('names show the line, keeping a leading v, and a later minor moves them on', () => { + assert.equal(lineName('Correctness (Version 5.2.0)', line52), 'Correctness (Version 5.2.x)') + assert.equal(lineName('Spike in Errors (v4.9.4)', line52), 'Spike in Errors (v5.2.x)') + assert.equal(lineName('p50 Latency (Version 5.1.*)', line52), 'p50 Latency (Version 5.2.x)') + assert.equal(lineName('Correctness (Version 5.2.x)', line53), 'Correctness (Version 5.3.x)') + // Only whole three-part versions change. + assert.equal(lineName('cli', line52), 'cli') + assert.equal(lineName('p75 over 1.5s', line52), 'p75 over 1.5s') + assert.equal(lineName('build 10.2.0.1', line52), 'build 10.2.0.1') +}) + +test('raw SLI expressions match every version of the line with a regex', () => { + const expression = + '1 - (sum(rate(cli_commands_total{exit="unexpected_error", cli_version="5.2.0"} [15m])) / sum(rate(cli_commands_total{cli_version="5.2.0"} [15m])))' + const lined = lineExpression(expression, line52) + assert.equal( + lined, + '1 - (sum(rate(cli_commands_total{exit="unexpected_error", cli_version=~"5[.]2[.][0-9]+"} [15m])) / sum(rate(cli_commands_total{cli_version=~"5[.]2[.][0-9]+"} [15m])))', + ) + assert.equal(lineExpression(lined, line52), lined) + assert.equal(lineExpression(lined, line53), lined.replaceAll('5[.]2[.]', '5[.]3[.]')) + // Other matchers stay as they are. + assert.equal( + lineExpression('sum(rate(cli_commands_total{exit!="ok"}[5m]))', line52), + 'sum(rate(cli_commands_total{exit!="ok"}[5m]))', + ) + assert.equal(lineExpression('vector(1)', line52), 'vector(1)') +}) + +test('histogram SLI filters match the line on cli_version and keep every other filter', () => { + const filters = [ + {key: 'job', value: 'shopify-cli', op: '='}, + {key: 'cli_version', value: '5.2.0', op: '='}, + ] + const lined = lineHistogramFilters(filters, line52) + assert.deepEqual(lined, [ + {key: 'job', value: 'shopify-cli', op: '='}, + {key: 'cli_version', value: '5[.]2[.][0-9]+', op: '=~'}, + ]) + assert.deepEqual(lineHistogramFilters(lined, line53)[1], {key: 'cli_version', value: '5[.]3[.][0-9]+', op: '=~'}) +}) + +// An SLI shaped like the CLI's correctness SLOs, with made-up values: the job matcher first in each selector, an +// error rate over a command rate, and a traffic guard that multiplies. +const correctness = + '1 - (sum(rate(cli_commands_total{job=~"@shopify/(app|store):.*", exit="error", cli_version="1.4.0"} [5m])) / sum(rate(cli_commands_total{job=~"@shopify/(app|store):.*", cli_version="1.4.0"} [5m]))) * on() (sum(rate(cli_commands_total{job=~"@shopify/(app|store):.*", cli_version="1.4.0"}[5m])) > 2)' +// Histogram filters shaped like the CLI's latency SLOs', with a made-up exclusion. +const latencyFilters = [ + {key: 'job', value: 'excluded-command', op: '!='}, + {key: 'job', value: '@shopify/(app|store):.*', op: '=~'}, + {key: 'cli_version', value: '1.4.0', op: '='}, +] + +test('SLIs lose the job matcher and filter on traffic instead of multiplying by it', () => { + const lined = lineExpression(correctness, line52) + assert.equal( + lined, + '1 - (sum(rate(cli_commands_total{exit="error", cli_version=~"5[.]2[.][0-9]+"} [5m])) / sum(rate(cli_commands_total{cli_version=~"5[.]2[.][0-9]+"} [5m]))) and on() (sum(rate(cli_commands_total{cli_version=~"5[.]2[.][0-9]+"}[5m])) > 2)', + ) + assert.equal(lineExpression(lined, line52), lined) + // A space before the guard's window doesn't matter. + const spaced = (expression) => expression.replace('}[5m])) > 2)', '} [5m])) > 2)') + assert.equal(lineExpression(spaced(correctness), line52), spaced(lined)) + const linedFilters = lineHistogramFilters(latencyFilters, line52) + assert.deepEqual(linedFilters, [ + {key: 'job', value: 'excluded-command', op: '!='}, + {key: 'cli_version', value: '5[.]2[.][0-9]+', op: '=~'}, + ]) + assert.deepEqual(lineHistogramFilters(linedFilters, line52), linedFilters) +}) + +/** + * A correctness SLI's value at one moment, given its two rates, under PromQL's rules for vectors of one sample: a + * comparison without `bool` keeps its left side's value or leaves no sample (NaN here), and `and on()` keeps its + * left side only while its right side has a sample. + * + * @param {string} expression + * @param {{errorsPerSecond: number, commandsPerSecond: number}} rates + * @returns {number} + */ +function correctnessAt(expression, {errorsPerSecond, commandsPerSecond}) { + const arithmetic = expression + .replace(/sum\(rate\(cli_commands_total\{[^}]*exit=[^}]*\}\s*\[\w+\]\)\)/g, `${errorsPerSecond}`) + .replace(/sum\(rate\(cli_commands_total\{[^}]*\}\s*\[\w+\]\)\)/g, `${commandsPerSecond}`) + .replace(/\(([\d.]+) > ([\d.]+)\)/g, (_comparison, left, right) => + Number(left) > Number(right) ? `(${left})` : '(NaN)', + ) + .replace(/\* on\(\)/g, '*') + const [value, guard] = arithmetic.split(' and on() ') + const evaluate = (code) => Function(`return ${code}`)() + return guard !== undefined && Number.isNaN(evaluate(guard)) ? NaN : evaluate(value) +} + +test('a multiplied traffic guard makes a correctness SLI 1 minus errors a second, and the filter the error ratio', () => { + const busy = {errorsPerSecond: 0.002, commandsPerSecond: 300} + assert.ok(Math.abs(correctnessAt(correctness, busy) - (1 - 0.002)) < 1e-12) + assert.ok(Math.abs(correctnessAt(lineExpression(correctness, line52), busy) - (1 - 0.002 / 300)) < 1e-12) + // Below the guard's rate, both leave no sample. + const quiet = {errorsPerSecond: 0.01, commandsPerSecond: 1} + assert.ok(Number.isNaN(correctnessAt(correctness, quiet))) + assert.ok(Number.isNaN(correctnessAt(lineExpression(correctness, line52), quiet))) +}) + +test('only that job matcher goes, wherever it sits in a selector', () => { + const stale = 'job=~"@shopify/(app|store):.*"' + assert.equal(lineExpression(`m{exit="ok", ${stale}}`, line52), 'm{exit="ok"}') + assert.equal( + lineExpression(`m{exit="ok", ${stale}, cli_version="5.2.0"}`, line52), + 'm{exit="ok", cli_version=~"5[.]2[.][0-9]+"}', + ) + assert.equal(lineExpression(`m{${stale}}`, line52), 'm{}') + for (const kept of [ + 'job="cli"', + 'job!="excluded-command"', + 'job=~"@shopify/app:.*"', + 'job!~"@shopify/(app|store):.*"', + ]) { + assert.equal(lineExpression(`m{${kept}}`, line52), `m{${kept}}`) + } + const keptFilters = [ + {key: 'job', value: '@shopify/(app|store):.*', op: '!~'}, + {key: 'job', value: '@shopify/app:.*', op: '=~'}, + {key: 'exit', value: '@shopify/(app|store):.*', op: '=~'}, + ] + assert.deepEqual(lineHistogramFilters(keptFilters, line52), keptFilters) +}) + +test('a traffic guard becomes a filter only where it multiplies by a cli_commands_total rate without bool', () => { + for (const kept of [ + 'x * on() (sum(rate(cli_commands_total{exit="ok"}[5m])) > bool 2)', + 'x * on() (sum(rate(other_total{exit="ok"}[5m])) > 2)', + 'x * on() (sum(rate(cli_commands_total{exit="ok"}[5m])))', + ]) { + assert.equal(lineExpression(kept, line52), kept) + } +}) + +test('error filters start with the line, in every nested group, and keep everything else byte for byte', () => { + const filters = + '{"filters":null,"filter_groups":[{"filters":[{"column":"resource.service.name","op":"=","value":"cli"},{"column":"handled","op":"=","value":"false"},{"column":"app.version","op":"=","value":"5.2.0"}],"filter_groups":null,"conjunction":"AND"}],"conjunction":"AND"}' + const lined = lineErrorFilters(filters, 'app.version', line52) + assert.equal( + lined, + '{"filters":null,"filter_groups":[{"filters":[{"column":"resource.service.name","op":"=","value":"cli"},{"column":"handled","op":"=","value":"false"},{"column":"app.version","op":"starts-with","value":"5.2."}],"filter_groups":null,"conjunction":"AND"}],"conjunction":"AND"}', + ) + assert.equal(lineErrorFilters(lined, 'app.version', line52), lined) + assert.equal(lineErrorFilters(lined, 'app.version', line53), lined.replace('"5.2."', '"5.3."')) + const nested = + '{"filters":[{"column":"app.version","op":"=","value":"5.1.0"}],"filter_groups":[{"filters":null,"filter_groups":[{"filters":[{"column":"app.version","op":"!=","value":"5.1.1"}],"filter_groups":null,"conjunction":"AND"}],"conjunction":"OR"}],"conjunction":"AND"}' + assert.equal( + lineErrorFilters(nested, 'app.version', line52), + '{"filters":[{"column":"app.version","op":"starts-with","value":"5.2."}],"filter_groups":[{"filters":null,"filter_groups":[{"filters":[{"column":"app.version","op":"!=","value":"5.1.1"}],"filter_groups":null,"conjunction":"AND"}],"conjunction":"OR"}],"conjunction":"AND"}', + ) +}) diff --git a/bin/update-observe.js b/bin/update-observe.js index fc59fd38a83..b1dc1a1f9a6 100755 --- a/bin/update-observe.js +++ b/bin/update-observe.js @@ -1,31 +1,34 @@ #!/usr/bin/env node /** - * Updates Observe resources (SLOs, alert rules, error projects) that pin the - * latest CLI version. Replaces the manual post-release steps in the release + * Points the CLI's Observe resources (SLOs, alert rules, error projects) at the + * newest release line. Replaces the manual post-release steps in the release * runbook (https://github.com/Shopify/develop-app-inner-loop/issues/2694) that * require clicking through observe.shopify.io to update version filters by hand. * + * The resources track a whole line, X.Y.x, so that line's patches need no + * update: run this for each minor or major release, X.Y.0. + * * For each resource the script: * 1. Fetches the live config from the Monitoring API. - * 2. Patches only the version-touching fields by rewriting any X.Y.Z literal - * it finds in the live name, raw SLI expression, and version filter - * values. The JSON config holds no templates — the live values from - * Observe are the source of truth, so manual edits to surrounding text - * are preserved. + * 2. Patches only the version-touching fields to match the line + * (bin/observe-version.js): each version in the name becomes X.Y.x, + * `cli_version` matchers in a raw SLI expression and histogram SLI filters + * become the regex X[.]Y[.][0-9]+, and the version filter of an alert or + * error project starts with X.Y. SLIs also drop the job matcher + * `job=~"@shopify/(app|store):.*"`, and a traffic guard that multiplies + * (`* on()`) becomes a filter (`and on()`). The JSON config holds no + * templates — the live values from Observe are the source of truth, so + * manual edits to surrounding text are preserved. * 3. Re-upserts the full resource so non-version fields (objective, alertType, * notificationPolicyId, vaultTeamId, etc.) are preserved verbatim. * * Usage: - * pnpm update-observe -- --version=3.94.2 # update all resources - * pnpm update-observe -- --version=3.94.2 --resource=slo-p50-latency # update one resource - * pnpm update-observe -- --version=3.94.2 --dry-run # print payloads without sending + * pnpm update-observe --version=5.3.0 # update all resources + * pnpm update-observe --version=5.3.0 --resource=slo-p50-latency # update one resource + * pnpm update-observe --version=5.3.0 --dry-run # print payloads without sending * - * --version is required and must be concrete semver X.Y.Z. Wildcards - * (`*`) are intentionally not allowed in the CLI argument — if a live - * resource in Observe pins a partial version like `3.*.*` or `4.90.*`, the - * script preserves those wildcard components and only rewrites the numeric - * ones. So given `--version=4.95.3`, a live `3.*.*` becomes `4.*.*` and a - * live `4.90.*` becomes `4.95.*`. + * --version is required and must be a minor or major release, X.Y.0. A patch + * is refused: its line's resources already cover it. * --resource selects a single resource by its `key` from * bin/observe-cli-resources.json. Omit to update all of them. * @@ -41,6 +44,14 @@ * Templates live in bin/observe-cli-resources.json. To add or remove a managed * resource, edit that file — no script changes required. */ +import { + lineErrorFilters, + lineExpression, + lineHistogramFilters, + lineName, + releaseLine, + versionRefusal, +} from './observe-version.js' import {spawn} from 'node:child_process' import {chmodSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync} from 'node:fs' import {homedir, platform} from 'node:os' @@ -61,28 +72,10 @@ const {values: args} = parseArgs({ const dryRun = args['dry-run'] const version = args.version -if (!version) fail('--version is required (e.g. --version=3.94.2)') -if (!/^\d+\.\d+\.\d+$/.test(version)) fail(`Version must be concrete semver X.Y.Z (got: ${version})`) - -// Matches a 3-component version literal: digits or `*` separated by dots. -// Used to find/rewrite versions inside live names, expressions, and filter values. -const VERSION_LITERAL_RE = /(? { - const eParts = existing.split('.') - if (eParts.length !== 3) return version // unexpected shape; fall back to the literal target - return eParts.map((e, i) => (e === '*' ? '*' : targetParts[i])).join('.') -} - -// Rewrite every version literal found inside an arbitrary string. -const patchVersionString = (str) => - typeof str === 'string' ? str.replace(VERSION_LITERAL_RE, (match) => applyVersion(match)) : str +if (!version) fail('--version is required (e.g. --version=5.3.0)') +const line = releaseLine(version) +if (!line) fail(versionRefusal(version)) +const lineLabel = `${line.major}.${line.minor}.x` const config = JSON.parse(readFileSync(join(__dirname, 'observe-cli-resources.json'), 'utf-8')) let COOKIE = null // populated lazily; see authenticate() @@ -177,7 +170,7 @@ const buildSloInput = (live, resource) => { const input = stripUndefined({ id: live.id, - name: patchVersionString(live.name), + name: lineName(live.name, line), objective: live.objective, vaultTeamId: live.vaultTeam?.id, serviceId: live.service?.name, @@ -209,15 +202,11 @@ const buildSloInput = (live, resource) => { throw new Error(`Resource ${resource.key} is a RawSLI but has no live expression to patch`) } input.rawSLIInput = { - expression: patchVersionString(live.sli.expression), - weightExpression: patchVersionString(live.sli.weightExpression) || undefined, + expression: lineExpression(live.sli.expression, line), + weightExpression: live.sli.weightExpression ? lineExpression(live.sli.weightExpression, line) : undefined, } } else { - const filters = live.sli.metric.filters.map((f) => ({ - key: f.key, - op: f.op, - value: f.key === 'cli_version' && f.op === '=' ? applyVersion(f.value) : f.value, - })) + const filters = lineHistogramFilters(live.sli.metric.filters, line).map((f) => ({key: f.key, op: f.op, value: f.value})) input.histogramSLIInput = { metric: { metricName: live.sli.metric.metricName, @@ -232,29 +221,15 @@ const buildSloInput = (live, resource) => { return input } -const patchVersionInFilterJson = (jsonString, column) => { - const parsed = JSON.parse(jsonString) - const patchGroup = (group) => { - if (group.filters) { - for (const f of group.filters) { - if (f.column === column && typeof f.value === 'string') f.value = applyVersion(f.value) - } - } - if (group.filter_groups) group.filter_groups.forEach(patchGroup) - } - patchGroup(parsed) - return JSON.stringify(parsed) -} - const buildRuleInput = (live, resource) => { if (!live.customErrorFilters) { throw new Error(`Alert rule ${resource.key} has no customErrorFilters to patch`) } return stripUndefined({ id: live.id, - name: patchVersionString(live.name), + name: lineName(live.name, line), vaultTeamId: live.vaultTeam?.id, - expression: patchVersionString(live.expression), + expression: live.expression ? lineExpression(live.expression, line) : live.expression, dataSourceType: live.dataSourceType, for: live.for, sustainType: live.sustainType || undefined, @@ -271,7 +246,7 @@ const buildRuleInput = (live, resource) => { notificationPolicyId: live.notificationPolicy?.id, servicesDbServiceName: live.servicesDbService?.name, errorAlertFlavor: live.errorAlertFlavor, - customErrorFilters: patchVersionInFilterJson(live.customErrorFilters, resource.versionFilterColumn), + customErrorFilters: lineErrorFilters(live.customErrorFilters, resource.versionFilterColumn, line), includedVersionCount: live.includedVersionCount, disableGrouping: live.disableGrouping, maxGroups: live.maxGroups, @@ -298,13 +273,13 @@ const buildErrorProjectInput = (live, resource) => { } return stripUndefined({ id: live.id, - name: patchVersionString(live.name), + name: lineName(live.name, line), zone: live.zone || undefined, serviceName: live.serviceName || undefined, vaultTeamID: live.vaultTeam?.id, platformType: live.platformType || undefined, priorityCountType: live.priorityCountType, - errorFilters: patchVersionInFilterJson(live.errorFilters, resource.versionFilterColumn), + errorFilters: lineErrorFilters(live.errorFilters, resource.versionFilterColumn, line), severityThresholds: live.severityThresholds?.map((t) => ({severityId: t.severity.id, value: t.value})), includedVersionCount: live.includedVersionCount, useLlm: live.useLlm, @@ -550,7 +525,7 @@ const main = async () => { await authenticate() const scope = args.resource ? `resource=${args.resource}` : `${selected.length} resources` - console.log(`Updating Observe ${scope} for ${config.service} → cli_version=${version}${dryRun ? ' (dry run)' : ''}`) + console.log(`Updating Observe ${scope} for ${config.service} → the ${lineLabel} line${dryRun ? ' (dry run)' : ''}`) const results = await Promise.all(selected.map(updateOne)) const failed = results.filter((ok) => !ok).length