Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(alerts-platform): allow up to 2000 insight keys per tick (#126645)

Jimmy Zhua449a87a64ab
diff --git a/docs/internal/alerts-platform-temporal.md b/docs/internal/alerts-platform-temporal.md
index daf13a4da440..8fcb456137f1 100644
--- a/docs/internal/alerts-platform-temporal.md
+++ b/docs/internal/alerts-platform-temporal.md
@@ -211,7 +211,8 @@ Scheduled runs use `TemporalScheduledStartTime`; manual runs use the workflow st
Activity retries retain the same cutoff rather than reading the activity's clock.
The activity returns an `AlertDemand` containing configuration IDs grouped by the shared `SourceKind` enum (`logs` and `insight`).
Only nonempty groups are returned. Discovery does not reserve or claim IDs.
-Each source is bounded to its binding's `discovery_limit`, or to `DISCOVERY_LIMIT_PER_SOURCE` (1,000) without a binding, so the manifest stays near 40 KB per source, under the repository's 256 KB rule for Temporal payload fields.
+Each source is bounded to its binding's `discovery_limit`, or to `DISCOVERY_LIMIT_PER_SOURCE` (1,000) without a binding, so the manifest stays near 55 KB per 1,000 keys, under the repository's 256 KB rule for Temporal payload fields.
+The insight binding allows up to 2,000 keys (`ALERTS_PLATFORM_INSIGHT_KEYS_PER_TICK`), about 110 KB.
A source that admits fewer checks per tick sets a lower limit, because every key starts a workflow.
`omitted_by_source` counts the due IDs left out. The tick adds that count to its `remaining` result, and the next tick discovers that work again.
diff --git a/posthog/settings/temporal.py b/posthog/settings/temporal.py
index 20c977279126..c88132c6adcc 100644
--- a/posthog/settings/temporal.py
+++ b/posthog/settings/temporal.py
@@ -437,12 +437,13 @@ ALERTS_PLATFORM_INSIGHT_MAX_INFLIGHT_CHECKS: int = max(
# fall behind their cadence. The pool above bounds concurrent queries, not this. A key that finds the
# pool full polls for a slot within its tick, so a high value costs waiting runs rather than load.
# The default is never below the pool size, so a larger pool is never left idle. Discovery returns
-# every key in one activity result, so the cap keeps it at the 1000 keys the other sources use.
+# every key in one activity result. At the cap of 2000 the insight group is about 110 KB, which keeps
+# it under the 256 KB limit for one Temporal payload field.
ALERTS_PLATFORM_INSIGHT_KEYS_PER_TICK: int = get_from_env(
"ALERTS_PLATFORM_INSIGHT_KEYS_PER_TICK", max(200, ALERTS_PLATFORM_INSIGHT_MAX_INFLIGHT_EVALUATIONS), type_cast=int
)
-if not 0 < ALERTS_PLATFORM_INSIGHT_KEYS_PER_TICK <= 1000:
- raise ImproperlyConfigured("ALERTS_PLATFORM_INSIGHT_KEYS_PER_TICK must be between 1 and 1000")
+if not 0 < ALERTS_PLATFORM_INSIGHT_KEYS_PER_TICK <= 2000:
+ raise ImproperlyConfigured("ALERTS_PLATFORM_INSIGHT_KEYS_PER_TICK must be between 1 and 2000")
# Chart renders for platform insight firings allowed to run at once, across every worker. A render
# blocks a worker thread for up to 90 seconds, so this keeps renders from taking the slots that
# planning and recording need.