35f658b573
Collapse the three former check types into a single core `Monitor` entity
with one management surface (/monitors), one result table (monitor_results),
and a single scheduled task. Every type can now watch a free-standing custom
destination (optional host_id) — not just a registered Host.
- models: Monitor + MonitorResult replace PingResult/DnsResult; Host loses its
ping/dns facet columns (now Monitor rows linked by host_id).
- checks: monitors/{ping,dns,http}.py pure probes + runner.run_monitor
dispatcher; one monitor_check scheduler with a per-monitor due-filter.
- status: single monitor_status_source replaces the three sources.
- UI: /monitors blueprint (type-aware add/edit/list/widget); host hub shows a
host's linked monitors + "add monitor for this host"; nav + widget registry
+ alert metric catalog rewired. http plugin folded into core and removed.
- migration 0022 merges the http branch, data-migrates host facets +
http_monitors + all three result histories, drops the old tables/columns.
Resolves the per-host ping/dns auto-attach issue (#275): monitors are now
explicit, never auto-added to every host.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Jg27rgypiW2efULXJDtMC
60 lines
2.8 KiB
Python
60 lines
2.8 KiB
Python
"""HTTP monitoring tables (relocated from the former http plugin)
|
|
|
|
This revision originally lived in plugins/http/migrations. The http plugin has
|
|
been folded into core (unified Monitor entity), so its one migration is moved
|
|
here UNCHANGED — same revision id + "http" branch label — purely so the
|
|
revision stays resolvable in existing databases that already stamped it. The
|
|
0022_unify_monitors merge revision then absorbs this branch and drops these
|
|
tables after migrating their data into `monitor_results`.
|
|
|
|
Revision ID: http_001_initial
|
|
Revises: (none — branch off core via depends_on)
|
|
Create Date: 2026-03-22
|
|
"""
|
|
from typing import Sequence, Union
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision: str = "http_001_initial"
|
|
down_revision: Union[str, None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = "http"
|
|
depends_on: Union[str, Sequence[str], None] = ("0004_app_settings",)
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"http_monitors",
|
|
sa.Column("id", sa.String(36), primary_key=True),
|
|
sa.Column("name", sa.String(128), nullable=False),
|
|
sa.Column("url", sa.String(2048), nullable=False),
|
|
sa.Column("method", sa.String(8), nullable=False, server_default="GET"),
|
|
sa.Column("expected_status", sa.Integer, nullable=False, server_default="200"),
|
|
sa.Column("content_match", sa.String(512), nullable=False, server_default=""),
|
|
sa.Column("headers_json", sa.Text, nullable=False, server_default="{}"),
|
|
sa.Column("timeout_seconds", sa.Integer, nullable=False, server_default="10"),
|
|
sa.Column("check_interval_seconds", sa.Integer, nullable=False, server_default="0"),
|
|
sa.Column("follow_redirects", sa.Boolean, nullable=False, server_default="1"),
|
|
sa.Column("verify_ssl", sa.Boolean, nullable=False, server_default="1"),
|
|
sa.Column("enabled", sa.Boolean, nullable=False, server_default="1"),
|
|
sa.Column("last_checked_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
|
)
|
|
|
|
op.create_table(
|
|
"http_results",
|
|
sa.Column("id", sa.String(36), primary_key=True),
|
|
sa.Column("monitor_id", sa.String(36), nullable=False, index=True),
|
|
sa.Column("checked_at", sa.DateTime(timezone=True), nullable=False, index=True),
|
|
sa.Column("status_code", sa.Integer, nullable=True),
|
|
sa.Column("response_ms", sa.Float, nullable=True),
|
|
sa.Column("is_up", sa.Boolean, nullable=False, server_default="0"),
|
|
sa.Column("content_matched", sa.Boolean, nullable=True),
|
|
sa.Column("error_msg", sa.String(512), nullable=True),
|
|
sa.Column("tls_expires_at", sa.DateTime(timezone=True), nullable=True),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("http_results")
|
|
op.drop_table("http_monitors")
|