How would you configure Harness Continuous Verification (CV) on a canary deployment so it automatically rolls back a bad release based on live Prometheus or Datadog metrics, and what threshold logic prevents it from rolling back on noisy-but-harmless metric blips?
Quick Answer
Configure a CV verification step in the canary stage that pulls the same metric query, such as error rate or p99 latency, for both the canary and baseline pod groups, scores the statistical deviation between them over a sliding analysis window, and only triggers rollback when the deviation stays above threshold across multiple consecutive windows — a single noisy data point should never trigger rollback on its own. The key design choice is windowed, multi-sample comparison rather than instantaneous point comparison.
Detailed Answer
Think of a canary deployment like a food safety inspector tasting a new recipe, the canary, against the current one, the baseline, side by side, sip by sip, over several courses — not just one bite. If the new recipe tastes slightly off on a single spoonful, a good inspector doesn't send the whole batch back; they keep tasting a few more spoonfuls to see if it's a consistent problem or just one under-salted bite.
Harness CV was designed because naive canary analysis, comparing canary error rate to baseline error rate once at one point in time, produces too many false positives — a canary pod that happens to get one slow database connection, or restarts once during rollout, looks identical to a genuinely broken release if you only look at a single snapshot. So CV instead pulls a metric time series for both canary and baseline over a rolling verification window, commonly five to ten minutes sampled every minute, and scores similarity using statistical comparison rather than a single threshold check.
In practice you configure a Verify step referencing a health source such as Prometheus or Datadog, specify the exact metric query parameterized by pod group label so it can pull canary and baseline series separately, and set the analysis to run continuously during the canary bake time. Each analysis window produces a risk score between zero and one based on how much the canary's metrics deviate from baseline; Harness accumulates these scores across consecutive windows, and only when a rolling number of windows, say three out of five, exceed the configured risk threshold does it trigger the configured on-failure action, typically an automatic rollback via a stage-rollback step.
At scale, the metric query design matters more than the threshold number. Teams commonly get burned by comparing raw counts instead of rates, since a canary with five percent of traffic will always show lower absolute error counts than baseline, which looks better and hides real problems, or by picking a verification window shorter than their p99 latency's natural noise cycle, causing constant false-positive rollbacks. What to monitor: the CV risk score trend over time per service, since a service that's frequently near-threshold even on healthy deploys means the threshold is miscalibrated for that service's normal metric variance, and rollback frequency, since an unusually high automatic-rollback rate is itself an incident worth investigating, often pointing to a monitoring or traffic-split bug rather than actual bad releases.
The non-obvious gotcha is traffic skew during a canary: if your load balancer doesn't evenly distribute traffic by request pattern, for example if all requests from one heavy customer land on the canary group by sticky session, the canary's metrics will look anomalous purely due to traffic composition, not code quality, and CV will roll back a perfectly good release. Senior engineers explicitly verify that the traffic-splitting mechanism randomizes fairly across request types before trusting CV's statistical comparison, and often exclude known-heavy or known-different traffic segments from the canary pool entirely.