Skip to content

Canary Slack alerts don't say which instance fired them #1987

Closed

Description

@obasilakis

Summary

The canary green→red Slack alert (services/canary_alerts.py) carries invariant_id, severity, violation count, snapshot_time and the persisted row ids — but nothing identifying which Trinity instance produced it. With more than one instance posting to the same webhook, an alert is unattributable: you know S-01 fired somewhere in the fleet, not where to look.

Context

Latent until now because dev was the only instance with CANARY_SLACK_WEBHOOK_URL set (2026-05-11). As of today eu2 carries the same webhook — enabled for the #1766 pull/work-stealing soak — so every alert in that channel is now ambiguous, and it gets worse with each instance added.

This matters most in exactly the situation the alert exists for: during the #1766 soak, an S-01 or L-03 alert needs to be triaged as "eu2, the pilot" or "dev, unrelated" within seconds. Guessing costs the response its value.

Trinity already has the information — no new env var strictly required

In rough order of usefulness:

Source On eu2 Notes
FRONTEND_URL (config.py:94) https://eu2.abilityai.dev Best fit. Human-readable, the host's first label is the ops slug, already set on managed instances, already forwarded by docker-compose.prod.yml:211. Not guaranteed on OSS/local installs → needs a fallback
PUBLIC_CHAT_URL (config.py:98) https://public-eu2.abilityai.dev Set, but names the public-chat host rather than the instance; public- prefix is noise in a label
installation_id (operator_intake_service.get_or_create_installation_id) durable UUID in system_settings Genuinely unique and stable, but opaque — useless as a Slack label on its own. Good as a machine-readable secondary field
container hostname docker id Meaningless to a human

Proposal

  1. Add an optional explicit override TRINITY_INSTANCE_NAME (unset by default) for operators who want a specific label.
  2. When unset, derive one from FRONTEND_URL's host (first DNS label, e.g. eu2).
  3. Fall back to installation_id[:8] when neither is available, so an OSS install still gets something distinguishing rather than an unlabelled alert.
  4. Surface it in the Slack payload — the block header and/or a context line — so it's visible without expanding the message.

Deliberately not proposing a new required var: managed instances already carry FRONTEND_URL, and adding a mandatory key would need a fleet-wide .env rollout before alerts improved anywhere.

Acceptance Criteria

  • Canary Slack alerts identify the originating instance in the visible part of the message
  • Resolution order is override → FRONTEND_URL host → installation_id prefix, with no crash when all are absent
  • Unit coverage for each resolution branch, including the all-absent fallback
  • The webhook URL is still never logged or echoed (existing property in canary_alerts.py — don't regress it)
  • Instances sharing one webhook produce visibly distinct alerts

Technical Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-lowpriority-p2theme-reliabilitytype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions