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 flagged read api for platform alerts (#109080)

Jon McCallum385fefb4ae34
diff --git a/products/alerts/backend/presentation/views/platform_alert.py b/products/alerts/backend/presentation/views/platform_alert.py
new file mode 100644
index 000000000000..2a004e30d95f
--- /dev/null
+++ b/products/alerts/backend/presentation/views/platform_alert.py
@@ -0,0 +1,144 @@
+from django.db.models import Prefetch, QuerySet
+
+from rest_framework import serializers, viewsets
+
+from posthog.api.routing import TeamAndOrgViewSetMixin
+from posthog.permissions import PostHogFeatureFlagPermission, get_authenticator_scopes
+from posthog.scopes import APIScopeObject, scopes_not_covered
+
+from products.alerts.backend.models.platform_alert import PlatformAlert, PlatformAlertConfiguration
+from products.alerts.backend.presentation.views.alert import ScheduleRestrictionField
+
+
+class PlatformAlertSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = PlatformAlert
+ fields = ["id", "grouping_key", "state", "firing_started_at", "last_notified_at", "snooze_until"]
+ read_only_fields = fields
+ extra_kwargs = {
+ "id": {"help_text": "Unique identifier of this alert instance."},
+ "grouping_key": {
+ "help_text": "Key of the result group this instance tracks. Empty when the source does not group results."
+ },
+ "state": {"help_text": "Current state of this alert instance."},
+ "firing_started_at": {
+ "help_text": "When the current firing started. Null when the instance is not firing."
+ },
+ "last_notified_at": {"help_text": "When a notification was last sent for this instance."},
+ "snooze_until": {"help_text": "Time until which notifications are snoozed. Null when not snoozed."},
+ }
+
+
+class PlatformAlertConfigurationSerializer(serializers.ModelSerializer):
+ source_config = serializers.DictField(
+ child=serializers.JSONField(),
+ read_only=True,
+ help_text="Source-specific query settings. The shape depends on source_kind.",
+ )
+ schedule_restriction = ScheduleRestrictionField(
+ read_only=True,
+ allow_null=True,
+ help_text="Blocked local time windows (HH:MM in the project timezone) when the alert does not run. "
+ "Null means no quiet hours.",
+ )
+ alerts = PlatformAlertSerializer(
+ many=True,
+ read_only=True,
+ help_text="Runtime state for each result group of this configuration.",
+ )
+
+ class Meta:
+ model = PlatformAlertConfiguration
+ fields = [
+ "id",
+ "name",
+ "enabled",
+ "source_kind",
+ "source_config",
+ "threshold_count",
+ "threshold_operator",
+ "window_minutes",
+ "check_interval_minutes",
+ "evaluation_periods",
+ "datapoints_to_alarm",
+ "cooldown_minutes",
+ "schedule_restriction",
+ "next_check_at",
+ "consecutive_failures",
+ "legacy_configuration_id",
+ "created_at",
+ "updated_at",
+ "alerts",
+ ]
+ read_only_fields = fields
+ extra_kwargs = {
+ "id": {"help_text": "Unique identifier of the alert configuration."},
+ "name": {"help_text": "Human-readable name of the alert."},
+ "enabled": {"help_text": "Whether the alert is evaluated on schedule."},
+ "source_kind": {"help_text": "Product whose data the alert evaluates."},
+ "threshold_count": {"help_text": "Count the evaluated value is compared against."},
+ "threshold_operator": {"help_text": "Comparison operator applied between the value and threshold_count."},
+ "window_minutes": {"help_text": "Length of the evaluated time window, in minutes."},
+ "check_interval_minutes": {"help_text": "Minutes between scheduled checks."},
+ "evaluation_periods": {"help_text": "Number of recent checks considered when deciding to fire."},
+ "datapoints_to_alarm": {
+ "help_text": "Number of breaching checks within evaluation_periods required to fire."
+ },
+ "cooldown_minutes": {"help_text": "Minimum minutes between notifications for the same alert."},
+ "next_check_at": {"help_text": "When the next check is due. Null when no check is scheduled."},
+ "consecutive_failures": {"help_text": "Number of checks in a row that failed to evaluate."},
+ "legacy_configuration_id": {
+ "help_text": "ID of the legacy source configuration this row was backfilled from. "
+ "Null for alerts created on the platform."
+ },
+ "created_at": {"help_text": "When the configuration was created."},
+ "updated_at": {"help_text": "When the configuration was last changed."},
+ }
+
+
+# A configuration shows the source product's data (its filters and firing state), so a reader
+# also needs read access to that product. `alert:read` alone must not reveal it.
+SOURCE_KIND_RESOURCE: dict[str, APIScopeObject] = {
+ PlatformAlertConfiguration.SourceKind.LOGS: "logs",
+}
+
+
+class PlatformAlertConfigurationViewSet(TeamAndOrgViewSetMixin, viewsets.ReadOnlyModelViewSet):
+ scope_object = "alert"
+ serializer_class = PlatformAlertConfigurationSerializer
+ posthog_feature_flag = "platform-alerts"
+ permission_classes = [PostHogFeatureFlagPermission]
+ # The fail-closed manager raises if `.all()` runs at import, so scoping happens in
+ # safely_get_queryset.
+ queryset = PlatformAlertConfiguration.objects.unscoped()
+
+ def _should_skip_parents_filter(self) -> bool:
+ # safely_get_queryset scopes a child environment to its parent team, where the rows live. The
+ # default parent-lookup filter would AND the raw URL team id back in and hide them.
+ return True
+
+ def _readable_source_kinds(self) -> list[str]:
+ # Session auth carries no scopes, so only the access-control check applies to it.
+ token_scopes = get_authenticator_scopes(getattr(self.request, "successful_authenticator", None))
+ readable: list[str] = []
+ for source_kind, resource in SOURCE_KIND_RESOURCE.items():
+ if not self.user_access_control.check_access_level_for_resource(resource, "viewer"):
+ continue
+ if (
+ token_scopes is not None
+ and "*" not in token_scopes
+ and scopes_not_covered(token_scopes, [f"{resource}:read"])
+ ):
+ continue
+ readable.append(source_kind)
+ return readable
+
+ def safely_get_queryset(self, queryset: QuerySet) -> QuerySet[PlatformAlertConfiguration]:
+ canonical_team_id = self.team.parent_team_id or self.team.id
+ alerts = PlatformAlert.objects.for_team(canonical_team_id, canonical=True).order_by("grouping_key")
+ return (
+ PlatformAlertConfiguration.objects.for_team(canonical_team_id, canonical=True)
+ .filter(source_kind__in=self._readable_source_kinds())
+ .prefetch_related(Prefetch("alerts", queryset=alerts))
+ .order_by("-created_at", "-id")
+ )
diff --git a/products/alerts/backend/routes.py b/products/alerts/backend/routes.py
index ed84bd386fa1..1a70be7d5e6a 100644
--- a/products/alerts/backend/routes.py
+++ b/products/alerts/backend/routes.py
@@ -1,6 +1,7 @@
from posthog.api.routing import RouterRegistry
import products.alerts.backend.presentation.views.alert as alert
+import products.alerts.backend.presentation.views.platform_alert as platform_alert
def register_routes(routers: RouterRegistry) -> None:
@@ -10,5 +11,11 @@ def register_routes(routers: RouterRegistry) -> None:
"project_alerts",
["team_id"],
)
+ routers.projects.register(
+ r"platform_alerts",
+ platform_alert.PlatformAlertConfigurationViewSet,
+ "project_platform_alerts",
+ ["team_id"],
+ )
# ThresholdViewSet is registered as a sub-route under insights/<id>/thresholds
# by products.product_analytics.backend.routes — it imports alert.ThresholdViewSet.
diff --git a/products/alerts/backend/tests/api/test_platform_alert.py b/products/alerts/backend/tests/api/test_platform_alert.py
new file mode 100644
index 000000000000..4dbb1b0aa4c7
--- /dev/null
+++ b/products/alerts/backend/tests/api/test_platform_alert.py
@@ -0,0 +1,132 @@
+from datetime import UTC, datetime
+from uuid import UUID, uuid4
+
+from posthog.test.base import APIBaseTest
+from unittest.mock import patch
+
+from parameterized import parameterized
+from rest_framework import status
+
+from posthog.constants import AvailableFeature
+from posthog.models import OrganizationMembership, User
+from posthog.models.scoping import team_scope
+from posthog.models.team import Team
+
+from products.access_control.backend.models.access_control import AccessControl
+from products.alerts.backend.models import PlatformAlert, PlatformAlertConfiguration
+
+
+class TestPlatformAlertAPI(APIBaseTest):
+ def _create_configuration(
+ self, team: Team, name: str, legacy_configuration_id: UUID | None = None
+ ) -> PlatformAlertConfiguration:
+ with team_scope(team.id):
+ return PlatformAlertConfiguration.objects.create(
+ team=team,
+ name=name,
+ source_kind=PlatformAlertConfiguration.SourceKind.LOGS,
+ source_config={"service": "api"},
+ threshold_count=10,
+ threshold_operator="above",
+ window_minutes=5,
+ check_interval_minutes=10,
+ legacy_configuration_id=legacy_configuration_id,
+ )
+
+ def _set_flag(self, enabled: bool) -> None:
+ self.enterContext(patch("posthog.permissions.posthog_feature_flag_enabled", return_value=enabled))
+
+ @parameterized.expand([("list", False), ("retrieve", True)])
+ def test_flag_off_blocks_access(self, _name: str, with_id: bool) -> None:
+ self._set_flag(False)
+ configuration = self._create_configuration(self.team, "API errors")
+ url = f"/api/projects/{self.team.id}/platform_alerts/"
+ if with_id:
+ url += f"{configuration.id}/"
+
+ response = self.client.get(url)
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN, response.json()
+ assert response.json()["code"] == "feature_flag_required"
+
+ def test_list_returns_own_configurations_with_nested_alerts(self) -> None:
+ self._set_flag(True)
+ legacy_configuration_id = uuid4()
+ configuration = self._create_configuration(self.team, "API errors", legacy_configuration_id)
+ firing_started_at = datetime(2026, 9, 16, 10, tzinfo=UTC)
+ with team_scope(self.team.id):
+ alert = PlatformAlert.objects.create(
+ team=self.team,
+ configuration=configuration,
+ grouping_key="checkout",
+ state=PlatformAlert.State.FIRING,
+ firing_started_at=firing_started_at,
+ last_notified_at=firing_started_at,
+ )
+ other_team = Team.objects.create(organization=self.organization, name="Other team")
+ other_configuration = self._create_configuration(other_team, "Other team errors")
+ child_environment = Team.objects.create(organization=self.organization, parent_team=self.team, name="env")
+
+ list_response = self.client.get(f"/api/projects/{self.team.id}/platform_alerts/")
+ child_retrieve_response = self.client.get(
+ f"/api/projects/{child_environment.id}/platform_alerts/{configuration.id}/"
+ )
+ other_retrieve_response = self.client.get(
+ f"/api/projects/{self.team.id}/platform_alerts/{other_configuration.id}/"
+ )
+
+ assert list_response.status_code == status.HTTP_200_OK, list_response.json()
+ results = list_response.json()["results"]
+ assert [r["id"] for r in results] == [str(configuration.id)]
+ assert results[0]["legacy_configuration_id"] == str(legacy_configuration_id)
+ assert results[0]["alerts"] == [
+ {
+ "id": str(alert.id),
+ "grouping_key": "checkout",
+ "state": "firing",
+ "firing_started_at": "2026-09-16T10:00:00Z",
+ "last_notified_at": "2026-09-16T10:00:00Z",
+ "snooze_until": None,
+ }
+ ]
+ assert child_retrieve_response.status_code == status.HTTP_200_OK, child_retrieve_response.json()
+ assert child_retrieve_response.json() == results[0]
+ assert other_retrieve_response.status_code == status.HTTP_404_NOT_FOUND
+
+ @parameterized.expand(
+ [
+ ("member_without_logs_access", None, False),
+ ("key_without_logs_scope", ["alert:read"], False),
+ ("key_with_logs_scope", ["alert:read", "logs:read"], True),
+ ]
+ )
+ def test_logs_configurations_need_logs_read_access(
+ self, _name: str, key_scopes: list[str] | None, visible: bool
+ ) -> None:
+ self._set_flag(True)
+ configuration = self._create_configuration(self.team, "API errors")
+ if key_scopes is None:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL}
+ ]
+ self.organization.save()
+ member = User.objects.create_and_join(self.organization, "[email protected]", "testtest")
+ AccessControl.objects.create(
+ team=self.team,
+ resource="logs",
+ resource_id=None,
+ access_level="none",
+ organization_member=OrganizationMembership.objects.get(user=member, organization=self.organization),
+ )
+ self.client.force_login(member)
+ else:
+ self.client.logout()
+ self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {self.create_personal_api_key_with_scopes(key_scopes)}")
+
+ list_response = self.client.get(f"/api/projects/{self.team.id}/platform_alerts/")
+ retrieve_response = self.client.get(f"/api/projects/{self.team.id}/platform_alerts/{configuration.id}/")
+
+ assert list_response.status_code == status.HTTP_200_OK, list_response.json()
+ assert [r["id"] for r in list_response.json()["results"]] == ([str(configuration.id)] if visible else [])
+ expected_retrieve_status = status.HTTP_200_OK if visible else status.HTTP_404_NOT_FOUND
+ assert retrieve_response.status_code == expected_retrieve_status, retrieve_response.json()
diff --git a/products/alerts/frontend/generated/api.schemas.ts b/products/alerts/frontend/generated/api.schemas.ts
index 78248456799a..affb65ae0ded 100644
--- a/products/alerts/frontend/generated/api.schemas.ts
+++ b/products/alerts/frontend/generated/api.schemas.ts
@@ -980,6 +980,127 @@ export interface PaginatedThresholdWithAlertListApi {
results: ThresholdWithAlertApi[]
}
+/**
+ * * `logs` - Logs
+ */
+export type PlatformAlertConfigurationSourceKindEnumApi =
+ (typeof PlatformAlertConfigurationSourceKindEnumApi)[keyof typeof PlatformAlertConfigurationSourceKindEnumApi]
+
+export const PlatformAlertConfigurationSourceKindEnumApi = {
+ Logs: 'logs',
+} as const
+
+/**
+ * * `not_firing` - Not firing
+ * * `firing` - Firing
+ * * `errored` - Errored
+ * * `snoozed` - Snoozed
+ * * `broken` - Broken
+ */
+export type BillingAlertConfigurationStateEnumApi =
+ (typeof BillingAlertConfigurationStateEnumApi)[keyof typeof BillingAlertConfigurationStateEnumApi]
+
+export const BillingAlertConfigurationStateEnumApi = {
+ NotFiring: 'not_firing',
+ Firing: 'firing',
+ Errored: 'errored',
+ Snoozed: 'snoozed',
+ Broken: 'broken',
+} as const
+
+export interface PlatformAlertApi {
+ /** Unique identifier of this alert instance. */
+ readonly id: string
+ /** Key of the result group this instance tracks. Empty when the source does not group results. */
+ readonly grouping_key: string
+ /** Current state of this alert instance.
+ *
+ * * `not_firing` - Not firing
+ * * `firing` - Firing
+ * * `errored` - Errored
+ * * `snoozed` - Snoozed
+ * * `broken` - Broken */
+ readonly state: BillingAlertConfigurationStateEnumApi
+ /**
+ * When the current firing started. Null when the instance is not firing.
+ * @nullable
+ */
+ readonly firing_started_at: string | null
+ /**
+ * When a notification was last sent for this instance.
+ * @nullable
+ */
+ readonly last_notified_at: string | null
+ /**
+ * Time until which notifications are snoozed. Null when not snoozed.
+ * @nullable
+ */
+ readonly snooze_until: string | null
+}
+
+/**
+ * Source-specific query settings. The shape depends on source_kind.
+ */
+export type PlatformAlertConfigurationApiSourceConfig = { [key: string]: unknown }
+
+export interface PlatformAlertConfigurationApi {
+ /** Unique identifier of the alert configuration. */
+ readonly id: string
+ /** Human-readable name of the alert. */
+ readonly name: string
+ /** Whether the alert is evaluated on schedule. */
+ readonly enabled: boolean
+ /** Product whose data the alert evaluates.
+ *
+ * * `logs` - Logs */
+ readonly source_kind: PlatformAlertConfigurationSourceKindEnumApi
+ /** Source-specific query settings. The shape depends on source_kind. */
+ readonly source_config: PlatformAlertConfigurationApiSourceConfig
+ /** Count the evaluated value is compared against. */
+ readonly threshold_count: number
+ /** Comparison operator applied between the value and threshold_count. */
+ readonly threshold_operator: string
+ /** Length of the evaluated time window, in minutes. */
+ readonly window_minutes: number
+ /** Minutes between scheduled checks. */
+ readonly check_interval_minutes: number
+ /** Number of recent checks considered when deciding to fire. */
+ readonly evaluation_periods: number
+ /** Number of breaching checks within evaluation_periods required to fire. */
+ readonly datapoints_to_alarm: number
+ /** Minimum minutes between notifications for the same alert. */
+ readonly cooldown_minutes: number
+ /** Blocked local time windows (HH:MM in the project timezone) when the alert does not run. Null means no quiet hours. */
+ readonly schedule_restriction: AlertScheduleRestrictionApi | null
+ /**
+ * When the next check is due. Null when no check is scheduled.
+ * @nullable
+ */
+ readonly next_check_at: string | null
+ /** Number of checks in a row that failed to evaluate. */
+ readonly consecutive_failures: number
+ /**
+ * ID of the legacy source configuration this row was backfilled from. Null for alerts created on the platform.
+ * @nullable
+ */
+ readonly legacy_configuration_id: string | null
+ /** When the configuration was created. */
+ readonly created_at: string
+ /** When the configuration was last changed. */
+ readonly updated_at: string
+ /** Runtime state for each result group of this configuration. */
+ readonly alerts: readonly PlatformAlertApi[]
+}
+
+export interface PaginatedPlatformAlertConfigurationListApi {
+ count: number
+ /** @nullable */
+ next?: string | null
+ /** @nullable */
+ previous?: string | null
+ results: PlatformAlertConfigurationApi[]
+}
+
export type AlertsListParams = {
/**
* Optional. Restrict results to alerts created by the user with this UUID.
@@ -1040,3 +1161,14 @@ export type InsightsThresholdsListParams = {
*/
offset?: number
}
+
+export type PlatformAlertsListParams = {
+ /**
+ * Number of results to return per page.
+ */
+ limit?: number
+ /**
+ * The initial index from which to return the results.
+ */
+ offset?: number
+}
diff --git a/products/alerts/frontend/generated/api.ts b/products/alerts/frontend/generated/api.ts
index 0e6ee1dc7ea4..c07950454434 100644
--- a/products/alerts/frontend/generated/api.ts
+++ b/products/alerts/frontend/generated/api.ts
@@ -20,8 +20,11 @@ import type {
AlertsRetrieveParams,
InsightsThresholdsListParams,
PaginatedAlertListApi,
+ PaginatedPlatformAlertConfigurationListApi,
PaginatedThresholdWithAlertListApi,
PatchedAlertApi,
+ PlatformAlertConfigurationApi,
+ PlatformAlertsListParams,
ThresholdWithAlertApi,
} from './api.schemas'
@@ -288,3 +291,45 @@ export const insightsThresholdsRetrieve = async (
method: 'GET',
})
}
+
+export const getPlatformAlertsListUrl = (projectId: string, params?: PlatformAlertsListParams) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/projects/${projectId}/platform_alerts/?${stringifiedParams}`
+ : `/api/projects/${projectId}/platform_alerts/`
+}
+
+export const platformAlertsList = async (
+ projectId: string,
+ params?: PlatformAlertsListParams,
+ options?: RequestInit
+): Promise<PaginatedPlatformAlertConfigurationListApi> => {
+ return apiMutator<PaginatedPlatformAlertConfigurationListApi>(getPlatformAlertsListUrl(projectId, params), {
+ ...options,
+ method: 'GET',
+ })
+}
+
+export const getPlatformAlertsRetrieveUrl = (projectId: string, id: string) => {
+ return `/api/projects/${projectId}/platform_alerts/${id}/`
+}
+
+export const platformAlertsRetrieve = async (
+ projectId: string,
+ id: string,
+ options?: RequestInit
+): Promise<PlatformAlertConfigurationApi> => {
+ return apiMutator<PlatformAlertConfigurationApi>(getPlatformAlertsRetrieveUrl(projectId, id), {
+ ...options,
+ method: 'GET',
+ })
+}
diff --git a/products/alerts/mcp/tools.yaml b/products/alerts/mcp/tools.yaml
index 37866dc5ebc5..9527e4e73649 100644
--- a/products/alerts/mcp/tools.yaml
+++ b/products/alerts/mcp/tools.yaml
@@ -234,3 +234,9 @@ tools:
insights-thresholds-retrieve:
operation: insights_thresholds_retrieve
enabled: false
+ platform-alerts-list:
+ operation: platform_alerts_list
+ enabled: false
+ platform-alerts-retrieve:
+ operation: platform_alerts_retrieve
+ enabled: false
diff --git a/pyproject.toml b/pyproject.toml
index 80e3c514924a..152dddeededa 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -590,6 +590,7 @@ ignore_imports = [
"products.alerts.backend.presentation.views.alert -> products.alerts.backend.insight_alert_state_machine",
"products.alerts.backend.presentation.views.alert -> products.alerts.backend.models.alert",
"products.alerts.backend.presentation.views.insight_alerts -> products.alerts.backend.models.alert",
+ "products.alerts.backend.presentation.views.platform_alert -> products.alerts.backend.models.platform_alert",
"products.mcp_analytics.backend.presentation.views -> products.mcp_analytics.backend.logic",
"products.mcp_analytics.backend.presentation.views -> products.mcp_analytics.backend.models",
"products.mcp_analytics.backend.presentation.serializers -> products.mcp_analytics.backend.models",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 1d1ad7119ea6..08f4a27e89eb 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -67021,6 +67021,109 @@ export namespace Schemas {
results?: PersonListRecord[];
}
+ /**
+ * * `logs` - Logs
+ */
+ export type PlatformAlertConfigurationSourceKindEnum = typeof PlatformAlertConfigurationSourceKindEnum[keyof typeof PlatformAlertConfigurationSourceKindEnum];
+
+
+ export const PlatformAlertConfigurationSourceKindEnum = {
+ Logs: 'logs',
+ } as const;
+
+ export interface PlatformAlert {
+ /** Unique identifier of this alert instance. */
+ readonly id: string;
+ /** Key of the result group this instance tracks. Empty when the source does not group results. */
+ readonly grouping_key: string;
+ /** Current state of this alert instance.
+ *
+ * * `not_firing` - Not firing
+ * * `firing` - Firing
+ * * `errored` - Errored
+ * * `snoozed` - Snoozed
+ * * `broken` - Broken */
+ readonly state: BillingAlertConfigurationStateEnum;
+ /**
+ * When the current firing started. Null when the instance is not firing.
+ * @nullable
+ */
+ readonly firing_started_at: string | null;
+ /**
+ * When a notification was last sent for this instance.
+ * @nullable
+ */
+ readonly last_notified_at: string | null;
+ /**
+ * Time until which notifications are snoozed. Null when not snoozed.
+ * @nullable
+ */
+ readonly snooze_until: string | null;
+ }
+
+ /**
+ * Source-specific query settings. The shape depends on source_kind.
+ */
+ export type PlatformAlertConfigurationSourceConfig = { [key: string]: unknown };
+
+ export interface PlatformAlertConfiguration {
+ /** Unique identifier of the alert configuration. */
+ readonly id: string;
+ /** Human-readable name of the alert. */
+ readonly name: string;
+ /** Whether the alert is evaluated on schedule. */
+ readonly enabled: boolean;
+ /** Product whose data the alert evaluates.
+ *
+ * * `logs` - Logs */
+ readonly source_kind: PlatformAlertConfigurationSourceKindEnum;
+ /** Source-specific query settings. The shape depends on source_kind. */
+ readonly source_config: PlatformAlertConfigurationSourceConfig;
+ /** Count the evaluated value is compared against. */
+ readonly threshold_count: number;
+ /** Comparison operator applied between the value and threshold_count. */
+ readonly threshold_operator: string;
+ /** Length of the evaluated time window, in minutes. */
+ readonly window_minutes: number;
+ /** Minutes between scheduled checks. */
+ readonly check_interval_minutes: number;
+ /** Number of recent checks considered when deciding to fire. */
+ readonly evaluation_periods: number;
+ /** Number of breaching checks within evaluation_periods required to fire. */
+ readonly datapoints_to_alarm: number;
+ /** Minimum minutes between notifications for the same alert. */
+ readonly cooldown_minutes: number;
+ /** Blocked local time windows (HH:MM in the project timezone) when the alert does not run. Null means no quiet hours. */
+ readonly schedule_restriction: AlertScheduleRestriction | null;
+ /**
+ * When the next check is due. Null when no check is scheduled.
+ * @nullable
+ */
+ readonly next_check_at: string | null;
+ /** Number of checks in a row that failed to evaluate. */
+ readonly consecutive_failures: number;
+ /**
+ * ID of the legacy source configuration this row was backfilled from. Null for alerts created on the platform.
+ * @nullable
+ */
+ readonly legacy_configuration_id: string | null;
+ /** When the configuration was created. */
+ readonly created_at: string;
+ /** When the configuration was last changed. */
+ readonly updated_at: string;
+ /** Runtime state for each result group of this configuration. */
+ readonly alerts: readonly PlatformAlert[];
+ }
+
+ export interface PaginatedPlatformAlertConfigurationList {
+ count: number;
+ /** @nullable */
+ next?: string | null;
+ /** @nullable */
+ previous?: string | null;
+ results: PlatformAlertConfiguration[];
+ }
+
/**
* * `SYSTEM` - SYSTEM
* * `PLUGIN` - PLUGIN
@@ -119032,6 +119135,17 @@ export namespace Schemas {
Json: 'json',
} as const;
+ export type PlatformAlertsListParams = {
+ /**
+ * Number of results to return per page.
+ */
+ limit?: number;
+ /**
+ * The initial index from which to return the results.
+ */
+ offset?: number;
+ };
+
export type PluginConfigsLogsListParams = {
/**
* Number of results to return per page.