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): add a metrics source kind to the alerts platform (#125034)

Jimmy Zhu5f8384fd294c
diff --git a/products/alerts_platform/backend/delivery/message.py b/products/alerts_platform/backend/delivery/message.py
index 5ed733ff6da1..f0172f7aae40 100644
--- a/products/alerts_platform/backend/delivery/message.py
+++ b/products/alerts_platform/backend/delivery/message.py
@@ -47,6 +47,7 @@ _SOURCE_LABELS: Final[dict[SourceKind, str]] = {
SourceKind.BILLING: "Billing",
SourceKind.WAREHOUSE_SOURCE: "Warehouse sync",
SourceKind.WAREHOUSE_DESTINATION: "Warehouse destination",
+ SourceKind.METRICS: "Metric",
}
# What a held row says, when cooldown or mute kept its announcement and only its incident moved.
diff --git a/products/alerts_platform/backend/facade/contracts.py b/products/alerts_platform/backend/facade/contracts.py
index 7c7a15eff88b..ecc1a020b0df 100644
--- a/products/alerts_platform/backend/facade/contracts.py
+++ b/products/alerts_platform/backend/facade/contracts.py
@@ -32,6 +32,7 @@ class SourceKind(StrEnum):
BILLING = "billing"
WAREHOUSE_SOURCE = "warehouse_source"
WAREHOUSE_DESTINATION = "warehouse_destination"
+ METRICS = "metrics"
@frozen
diff --git a/products/alerts_platform/backend/facade/enums.py b/products/alerts_platform/backend/facade/enums.py
index 273e0897a913..205d14a7e67d 100644
--- a/products/alerts_platform/backend/facade/enums.py
+++ b/products/alerts_platform/backend/facade/enums.py
@@ -15,6 +15,7 @@ class PlatformAlertConfigurationSourceKind(LabeledStrEnum):
INSIGHT = "insight", "Insight"
WAREHOUSE_SOURCE = "warehouse_source", "Warehouse source"
WAREHOUSE_DESTINATION = "warehouse_destination", "Warehouse destination"
+ METRICS = "metrics", "Metrics"
class PlatformAlertOwner(LabeledStrEnum):
diff --git a/products/alerts_platform/backend/presentation/views/platform_alert.py b/products/alerts_platform/backend/presentation/views/platform_alert.py
index c6295550444f..a980a00d7ac2 100644
--- a/products/alerts_platform/backend/presentation/views/platform_alert.py
+++ b/products/alerts_platform/backend/presentation/views/platform_alert.py
@@ -255,6 +255,7 @@ SOURCE_KIND_RESOURCE: dict[str, APIScopeObject] = {
PlatformAlertConfigurationSourceKind.LOGS.value: "logs",
PlatformAlertConfigurationSourceKind.WAREHOUSE_SOURCE.value: "external_data_source",
PlatformAlertConfigurationSourceKind.WAREHOUSE_DESTINATION.value: "external_data_source",
+ PlatformAlertConfigurationSourceKind.METRICS.value: "metrics",
}
# Kinds the read API does not serve. An insight copy shows its insight's bound and firing state,
diff --git a/products/alerts_platform/frontend/generated/api.schemas.ts b/products/alerts_platform/frontend/generated/api.schemas.ts
index 7cfa9274c127..5c17386c975d 100644
--- a/products/alerts_platform/frontend/generated/api.schemas.ts
+++ b/products/alerts_platform/frontend/generated/api.schemas.ts
@@ -12,6 +12,7 @@
* * `insight` - Insight
* * `warehouse_source` - Warehouse source
* * `warehouse_destination` - Warehouse destination
+ * * `metrics` - Metrics
*/
export type PlatformAlertConfigurationSourceKindEnumApi =
(typeof PlatformAlertConfigurationSourceKindEnumApi)[keyof typeof PlatformAlertConfigurationSourceKindEnumApi]
@@ -21,6 +22,7 @@ export const PlatformAlertConfigurationSourceKindEnumApi = {
Insight: 'insight',
WarehouseSource: 'warehouse_source',
WarehouseDestination: 'warehouse_destination',
+ Metrics: 'metrics',
} as const
/**
@@ -195,7 +197,8 @@ export interface PlatformAlertConfigurationApi {
* * `logs` - Logs
* * `insight` - Insight
* * `warehouse_source` - Warehouse source
- * * `warehouse_destination` - Warehouse destination */
+ * * `warehouse_destination` - Warehouse destination
+ * * `metrics` - Metrics */
readonly source_kind: PlatformAlertConfigurationSourceKindEnumApi
/** Source-specific settings. The shape depends on source_kind. The bound the alert is evaluated against is under the condition key. */
readonly source_config: PlatformAlertConfigurationApiSourceConfig
diff --git a/products/alerts_platform/frontend/platformAlertFormat.ts b/products/alerts_platform/frontend/platformAlertFormat.ts
index 8728d80bbf8e..f7dce35563a5 100644
--- a/products/alerts_platform/frontend/platformAlertFormat.ts
+++ b/products/alerts_platform/frontend/platformAlertFormat.ts
@@ -37,6 +37,10 @@ export const SOURCE_KINDS: Record<PlatformAlertConfigurationSourceKindEnumApi, S
label: 'Warehouse destination',
alertUrl: () => urls.warehouseDestinations(),
},
+ [PlatformAlertConfigurationSourceKindEnumApi.Metrics]: {
+ label: 'Metrics',
+ alertUrl: () => urls.metrics(),
+ },
}
export function sourceAlertUrl(configuration: PlatformAlertConfigurationApi): string | null {
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index d48e911afb57..298d480786fb 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -78343,6 +78343,7 @@ export namespace Schemas {
* * `insight` - Insight
* * `warehouse_source` - Warehouse source
* * `warehouse_destination` - Warehouse destination
+ * * `metrics` - Metrics
*/
export type PlatformAlertConfigurationSourceKindEnum = typeof PlatformAlertConfigurationSourceKindEnum[keyof typeof PlatformAlertConfigurationSourceKindEnum];
@@ -78352,6 +78353,7 @@ export namespace Schemas {
Insight: 'insight',
WarehouseSource: 'warehouse_source',
WarehouseDestination: 'warehouse_destination',
+ Metrics: 'metrics',
} as const;
/**
@@ -78444,7 +78446,8 @@ export namespace Schemas {
* * `logs` - Logs
* * `insight` - Insight
* * `warehouse_source` - Warehouse source
- * * `warehouse_destination` - Warehouse destination */
+ * * `warehouse_destination` - Warehouse destination
+ * * `metrics` - Metrics */
readonly source_kind: PlatformAlertConfigurationSourceKindEnum;
/** Source-specific settings. The shape depends on source_kind. The bound the alert is evaluated against is under the condition key. */
readonly source_config: PlatformAlertConfigurationSourceConfig;