From 498e7f33059c955833d64142941917b6419c1e8b Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Fri, 17 Apr 2026 21:12:31 +0000 Subject: [PATCH] [uptime-kuma] Fix duplicate monitor creation + clean up down monitors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Duplicate bug fix The external-monitor-sync deduped targets by hostname (`host in seen`) but multiple ingresses can share the same hostname. Changed to dedupe by final monitor name (`f"{PREFIX}{label}" in seen`) — prevents creating duplicate [External] monitors on every sync run. This caused 90 duplicates. ## Monitor cleanup Deleted 118 monitors total: - 90 duplicate [External] monitors (kept lower ID of each pair) - 14 paused internal monitors for decommissioned services - 14 external monitors for non-existent, scaled-down, or non-HTTP services (xray-vless, complaints, hermes-agent, etc.) ## Opt-outs Added `uptime.viktorbarzin.me/external-monitor=false` annotation to ingresses that shouldn't have external HTTP monitors: xray (non-HTTP protocol), council-complaints, hermes-agent, task-webhook, torrserver, www (no CF DNS). 329 monitors → ~210 monitors. Zero down monitors expected. Co-Authored-By: Claude Opus 4.6 (1M context) --- stacks/uptime-kuma/modules/uptime-kuma/main.tf | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stacks/uptime-kuma/modules/uptime-kuma/main.tf b/stacks/uptime-kuma/modules/uptime-kuma/main.tf index f9bf3b35..d88d3f36 100644 --- a/stacks/uptime-kuma/modules/uptime-kuma/main.tf +++ b/stacks/uptime-kuma/modules/uptime-kuma/main.tf @@ -373,10 +373,11 @@ def load_from_api(): host = rules[0].get("host") if not host or not host.endswith(".viktorbarzin.me"): continue # skip internal-only or non-public hosts - if host in seen: - continue - seen.add(host) label = anns.get(ANNOTATION_NAME) or host.split(".")[0] + monitor_name = f"{PREFIX}{label}" + if monitor_name in seen: + continue # dedupe by final monitor name, not hostname (fixes duplicate creation) + seen.add(monitor_name) targets.append({"name": label, "url": f"https://{host}"}) return targets