refactor web pagination and add partitioned events, flap/timeout showcase agents
This commit is contained in:
@@ -85,10 +85,11 @@ class Check(Base):
|
||||
class Event(Base):
|
||||
__tablename__ = "events"
|
||||
|
||||
event_id: Mapped[UUID] = mapped_column(_uuid(), primary_key=True)
|
||||
event_id: Mapped[UUID] = mapped_column(_uuid(), nullable=False)
|
||||
agent_id: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
check_id: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
observed_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
||||
# Partition key (RANGE) on Postgres; composite PK = (event_id, received_at).
|
||||
received_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False, server_default=func.now()
|
||||
)
|
||||
@@ -103,6 +104,7 @@ class Event(Base):
|
||||
incident_key: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint("event_id", "received_at", name="events_pkey"),
|
||||
CheckConstraint(
|
||||
"status IN ('ok','warning','critical','unknown')", name="events_status_chk"
|
||||
),
|
||||
@@ -114,9 +116,21 @@ class Event(Base):
|
||||
text("observed_at DESC"),
|
||||
),
|
||||
Index("events_observed_at_idx", text("observed_at DESC")),
|
||||
Index("events_received_at_idx", text("received_at DESC")),
|
||||
)
|
||||
|
||||
|
||||
class EventIngestDedup(Base):
|
||||
__tablename__ = "event_ingest_dedup"
|
||||
|
||||
event_id: Mapped[UUID] = mapped_column(_uuid(), primary_key=True)
|
||||
received_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False, server_default=func.now()
|
||||
)
|
||||
|
||||
__table_args__ = (Index("event_ingest_dedup_received_at_idx", "received_at"),)
|
||||
|
||||
|
||||
class Incident(Base):
|
||||
__tablename__ = "incidents"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user