Check a canary before rolling out
Compare a canary's errors with the stable version's from your logs, then let Argo Rollouts or any pipeline stop a rollout that makes things worse.
Before you start
- A Tailcove source receiving your app's logs
- A way to run the new version on some hosts or pods next to the old one
A canary is only useful if someone looks at it before the rollout goes on. Tailcove's canary comparison does the looking: you tell it which lines are the canary and which are the baseline, and it says worse, ok or not_enough_data, with the reason. This guide sets it up by hand first, then from Argo Rollouts, then from a plain script.
On this page6 sections
It works because both sides are measured over the same minutes. A deploy check compares the hour before a release with the 15 minutes after, so a traffic spike at the wrong moment can fool it. A canary and its baseline see the same traffic at the same time.
1. Find a query for each side#
Everything starts with two queries in the query language that split your source's lines into "new version" and "everything else". Open a few lines from each side in the log viewer and look for what differs. The usual candidates:
- The host. Canary machines named
canary-1,canary-2:host:canary-*against-host:canary-*. - The release. If your lines carry the version in a
releasefield (events from the Sentry SDKs do):release:v2.4.0againstrelease:v2.3.9. - The pod. On Kubernetes the agent uses the pod's name as the host, and a pod's name holds its ReplicaSet's hash:
host:web-5b8d6c9f7-*againsthost:web-6f9c7d8b4-*. Runkubectl get rsto see both hashes.
Make sure the two don't overlap. If a line can match both, it counts on both sides, and the comparison gets quieter than it should be.
2. Try it on the Compare page#
Open Compare in the sidebar, pick the source and paste the two queries. Start with Last 15m.
You'll see lines, error lines, errors a minute and the error share for each side, the verdict, and the error patterns the canary logged that the baseline didn't log once. If the verdict is not_enough_data, one side had fewer than 50 lines: widen the window to 30 or 60 minutes, or send more traffic to the canary.
Two numbers matter most. The error share is error lines divided by lines; the canary counts as worse when its share is above both 1.5 times the baseline's and the baseline's plus one point (with at least 5 error lines). And any error only the canary logged, 3 times or more, makes it worse on its own. The full rule is in the docs.
Press Copy link and drop it in your team's channel when you're about to promote. The link carries the queries and the window, so whoever opens it sees the same comparison.
3. Make a token#
In Tailcove, open Settings → API tokens and create a token with only the logs:read ability. Copy the source's id from the address of its page, like src_01jbx5q8k7m3n2p4r6s8t0v1w3.
Check the token works before you wire it into anything:
curl -s -G "https://tailcove.dev/api/v1/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/compare" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
--data-urlencode "baseline=-host:canary-*" \
--data-urlencode "canary=host:canary-*" | jq '.data | {verdict, reason}'
4. Gate an Argo Rollouts canary#
Store the token where the analysis can read it:
kubectl create secret generic tailcove --from-literal=api-token=YOUR_API_TOKEN
Add an AnalysisTemplate that asks Tailcove every 5 minutes. Argo passes in the stable and canary pod template hashes, so the queries follow each rollout without you editing them:
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: tailcove-canary
spec:
args:
- name: stable-hash
- name: canary-hash
- name: api-token
valueFrom:
secretKeyRef:
name: tailcove
key: api-token
metrics:
- name: tailcove-canary
initialDelay: 5m
interval: 5m
count: 3
failureLimit: 1
successCondition: result == 'ok' || result == 'not_enough_data'
provider:
web:
url: 'https://tailcove.dev/api/v1/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/compare?baseline=host%3Aweb-{{args.stable-hash}}-%2A&canary=host%3Aweb-{{args.canary-hash}}-%2A&minutes=15'
headers:
- key: Authorization
value: 'Bearer {{args.api-token}}'
jsonPath: '{$.data.verdict}'
Then call it from the rollout's steps, after the first bit of traffic has moved:
strategy:
canary:
steps:
- setWeight: 10
- analysis:
templates:
- templateName: tailcove-canary
args:
- name: stable-hash
valueFrom:
podTemplateHashValue: Stable
- name: canary-hash
valueFrom:
podTemplateHashValue: Latest
- setWeight: 50
- pause: { duration: 10m }
With count: 3 and failureLimit: 1, one worse is let through and a second one aborts the rollout, and Argo scales the canary back down. We let not_enough_data pass because a 10% canary of a quiet service often has under 50 lines in 15 minutes; blocking on it would stall every rollout at night. If you'd rather it waited, raise minutes or initialDelay.
To see what Argo saw, run kubectl argo rollouts get rollout web and look at the analysis run's measurements. Each one is the verdict string.
5. Or gate any pipeline with a script#
Without Argo, a step in your deploy script does the same job. Run it after the canary has had traffic for a while:
answer=$(curl -sf -G "https://tailcove.dev/api/v1/sources/$TAILCOVE_SOURCE_ID/compare" \
-H "Authorization: Bearer $TAILCOVE_API_TOKEN" \
--data-urlencode "baseline=-host:canary-*" \
--data-urlencode "canary=host:canary-*" \
--data-urlencode "minutes=15")
echo "$answer" | jq -r '.data.reason'
if [ "$(echo "$answer" | jq -r '.data.verdict')" = "worse" ]; then
exit 1
fi
curl -f makes the step fail on a 401, 404 or 422 too, so a typo in a query doesn't quietly pass.
When it says worse#
Open the Compare page with the same queries (or the link from your channel) and start with Errors only the canary logged. View lines opens the canary's lines of that pattern in the log viewer, with the window already set. A new error pattern is usually the fastest way to the bug: it's the code path the new version added or broke.
If there's no new pattern and the share alone tripped, look at Errors that grew most on the canary. A timeout that went from 0.5% to 3% of lines points at a slower dependency or a smaller connection pool, not at new code.
Ready to try it on your own logs?
The Free plan includes a source, live tail, search and alerts. No credit card.