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(alert-destinations): add display_kind to event specifications and update hog function names (#59946)

Jon McCallum57be6deaafeb
diff --git a/products/logs/backend/alert_destinations.py b/products/logs/backend/alert_destinations.py
index a2566817bfc3..fa90fa9c4d50 100644
--- a/products/logs/backend/alert_destinations.py
+++ b/products/logs/backend/alert_destinations.py
@@ -13,12 +13,16 @@ EventKind = Literal["firing", "resolved", "broken", "errored"]
@dataclass(frozen=True)
class EventKindSpec:
event_id: str
+ display_kind: str
header: str
body: str
button_url: str
button_label: str
webhook_body: dict[str, Any]
+ def destination_description(self, alert_name: str) -> str:
+ return f'Sends {self.display_kind} notifications for logs alert "{alert_name}".'
+
_FIRE_RESOLVE_DATA: dict[str, str] = {
"alert_id": "{event.properties.alert_id}",
@@ -46,6 +50,7 @@ _BROKEN_ERRORED_BASE_DATA: dict[str, str] = {
EVENT_KIND_CONFIG: dict[EventKind, EventKindSpec] = {
"firing": EventKindSpec(
event_id="$logs_alert_firing",
+ display_kind="firing",
header="🔴 Log alert '{event.properties.alert_name}' is firing",
body=(
"*Threshold breached:* {event.properties.result_count} logs in "
@@ -63,6 +68,7 @@ EVENT_KIND_CONFIG: dict[EventKind, EventKindSpec] = {
),
"resolved": EventKindSpec(
event_id="$logs_alert_resolved",
+ display_kind="resolved",
header="🟢 Log alert '{event.properties.alert_name}' has resolved",
body=(
"*Current count:* {event.properties.result_count} logs in "
@@ -80,6 +86,7 @@ EVENT_KIND_CONFIG: dict[EventKind, EventKindSpec] = {
),
"broken": EventKindSpec(
event_id="$logs_alert_auto_disabled",
+ display_kind="auto-disabled",
header="⚠️ Log alert '{event.properties.alert_name}' was auto-disabled",
body=(
"*Reason:* {event.properties.consecutive_failures} consecutive check failures.\n"
@@ -99,6 +106,7 @@ EVENT_KIND_CONFIG: dict[EventKind, EventKindSpec] = {
),
"errored": EventKindSpec(
event_id="$logs_alert_errored",
+ display_kind="errored",
header="🟡 Log alert '{event.properties.alert_name}' couldn't evaluate",
body=("*Reason:* {event.properties.error_message}\n*Failure count:* {event.properties.consecutive_failures}"),
button_url="{project.url}/logs/alerts/{event.properties.alert_id}",
@@ -187,7 +195,8 @@ def build_slack_config(
"type": "internal_destination",
"enabled": True,
"filters": _filter_for(alert, kind),
- "name": f"{alert.name}: {kind} → Slack #{channel_display}",
+ "name": f"Logs alert — {alert.name} ({spec.display_kind}) → Slack #{channel_display}",
+ "description": spec.destination_description(alert.name),
"template_id": "template-slack",
"inputs": {
"blocks": {"value": _slack_blocks(spec)},
@@ -209,7 +218,8 @@ def build_webhook_config(
"type": "internal_destination",
"enabled": True,
"filters": _filter_for(alert, kind),
- "name": f"{alert.name}: {kind} → Webhook {webhook_url}",
+ "name": f"Logs alert — {alert.name} ({spec.display_kind}) → Webhook {webhook_url}",
+ "description": spec.destination_description(alert.name),
"template_id": "template-webhook",
"inputs": {
"body": {"value": spec.webhook_body},