feat: drill-down filters on overview and outdated agent version highlight
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,10 +8,12 @@ from app.config import get_settings
|
|||||||
from app.database import get_db
|
from app.database import get_db
|
||||||
from app.models import Event, Host
|
from app.models import Event, Host
|
||||||
from app.schemas.list_models import HostDetail, HostListResponse, HostSummary
|
from app.schemas.list_models import HostDetail, HostListResponse, HostSummary
|
||||||
|
from app.services.agent_version import latest_agent_versions_by_product
|
||||||
from app.services.host_delete import delete_host_and_related
|
from app.services.host_delete import delete_host_and_related
|
||||||
from app.services.host_health import (
|
from app.services.host_health import (
|
||||||
HEARTBEAT_TYPE,
|
HEARTBEAT_TYPE,
|
||||||
agent_status,
|
agent_status as compute_agent_status,
|
||||||
|
apply_agent_status_host_filter,
|
||||||
max_daily_report_time_by_host,
|
max_daily_report_time_by_host,
|
||||||
max_event_time_by_host,
|
max_event_time_by_host,
|
||||||
)
|
)
|
||||||
@@ -25,6 +27,7 @@ def list_hosts(
|
|||||||
page_size: int = Query(50, ge=1, le=200),
|
page_size: int = Query(50, ge=1, le=200),
|
||||||
product: str | None = None,
|
product: str | None = None,
|
||||||
hostname: str | None = None,
|
hostname: str | None = None,
|
||||||
|
agent_status: str | None = Query(None, pattern="^(online|stale|unknown)$"),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
_user: str = Depends(get_current_user),
|
_user: str = Depends(get_current_user),
|
||||||
) -> HostListResponse:
|
) -> HostListResponse:
|
||||||
@@ -40,6 +43,15 @@ def list_hosts(
|
|||||||
stmt = stmt.where(host_match)
|
stmt = stmt.where(host_match)
|
||||||
count_stmt = count_stmt.where(host_match)
|
count_stmt = count_stmt.where(host_match)
|
||||||
|
|
||||||
|
settings = get_settings()
|
||||||
|
if agent_status:
|
||||||
|
stmt, count_stmt = apply_agent_status_host_filter(
|
||||||
|
stmt,
|
||||||
|
count_stmt,
|
||||||
|
agent_status,
|
||||||
|
stale_minutes=settings.sac_heartbeat_stale_minutes,
|
||||||
|
)
|
||||||
|
|
||||||
total = db.scalar(count_stmt) or 0
|
total = db.scalar(count_stmt) or 0
|
||||||
rows = db.scalars(
|
rows = db.scalars(
|
||||||
stmt.order_by(Host.last_seen_at.desc())
|
stmt.order_by(Host.last_seen_at.desc())
|
||||||
@@ -47,7 +59,6 @@ def list_hosts(
|
|||||||
.limit(page_size)
|
.limit(page_size)
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
settings = get_settings()
|
|
||||||
hb_map = max_event_time_by_host(db, HEARTBEAT_TYPE)
|
hb_map = max_event_time_by_host(db, HEARTBEAT_TYPE)
|
||||||
report_map = max_daily_report_time_by_host(db)
|
report_map = max_daily_report_time_by_host(db)
|
||||||
|
|
||||||
@@ -72,13 +83,19 @@ def list_hosts(
|
|||||||
last_heartbeat_at=last_hb,
|
last_heartbeat_at=last_hb,
|
||||||
last_daily_report_at=report_map.get(host.id),
|
last_daily_report_at=report_map.get(host.id),
|
||||||
last_inventory_at=host.inventory_updated_at,
|
last_inventory_at=host.inventory_updated_at,
|
||||||
agent_status=agent_status(
|
agent_status=compute_agent_status(
|
||||||
last_hb, stale_minutes=settings.sac_heartbeat_stale_minutes
|
last_hb, stale_minutes=settings.sac_heartbeat_stale_minutes
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return HostListResponse(items=items, total=total, page=page, page_size=page_size)
|
return HostListResponse(
|
||||||
|
items=items,
|
||||||
|
total=total,
|
||||||
|
page=page,
|
||||||
|
page_size=page_size,
|
||||||
|
latest_agent_versions=latest_agent_versions_by_product(db),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _host_detail_from_model(
|
def _host_detail_from_model(
|
||||||
@@ -108,7 +125,7 @@ def _host_detail_from_model(
|
|||||||
last_heartbeat_at=last_hb,
|
last_heartbeat_at=last_hb,
|
||||||
last_daily_report_at=report_map.get(host.id),
|
last_daily_report_at=report_map.get(host.id),
|
||||||
last_inventory_at=host.inventory_updated_at,
|
last_inventory_at=host.inventory_updated_at,
|
||||||
agent_status=agent_status(last_hb, stale_minutes=settings.sac_heartbeat_stale_minutes),
|
agent_status=compute_agent_status(last_hb, stale_minutes=settings.sac_heartbeat_stale_minutes),
|
||||||
agent_instance_id=host.agent_instance_id,
|
agent_instance_id=host.agent_instance_id,
|
||||||
tags=host.tags if isinstance(host.tags, list) else [],
|
tags=host.tags if isinstance(host.tags, list) else [],
|
||||||
use_sac_mode=host.use_sac_mode,
|
use_sac_mode=host.use_sac_mode,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -156,6 +156,10 @@ def list_problems(
|
|||||||
|
|
||||||
hostname: str | None = Query(None),
|
hostname: str | None = Query(None),
|
||||||
|
|
||||||
|
created_within_hours: int | None = Query(None, ge=1, le=8760),
|
||||||
|
|
||||||
|
resolved_within_hours: int | None = Query(None, ge=1, le=8760),
|
||||||
|
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
|
|
||||||
_user: str = Depends(get_current_user),
|
_user: str = Depends(get_current_user),
|
||||||
@@ -194,6 +198,22 @@ def list_problems(
|
|||||||
|
|
||||||
count_stmt = count_stmt.where(Host.hostname.ilike(like) | Host.display_name.ilike(like))
|
count_stmt = count_stmt.where(Host.hostname.ilike(like) | Host.display_name.ilike(like))
|
||||||
|
|
||||||
|
if created_within_hours is not None:
|
||||||
|
|
||||||
|
since = datetime.now(timezone.utc) - timedelta(hours=created_within_hours)
|
||||||
|
|
||||||
|
stmt = stmt.where(Problem.created_at >= since)
|
||||||
|
|
||||||
|
count_stmt = count_stmt.where(Problem.created_at >= since)
|
||||||
|
|
||||||
|
if resolved_within_hours is not None:
|
||||||
|
|
||||||
|
since = datetime.now(timezone.utc) - timedelta(hours=resolved_within_hours)
|
||||||
|
|
||||||
|
stmt = stmt.where(Problem.status == "resolved", Problem.updated_at >= since)
|
||||||
|
|
||||||
|
count_stmt = count_stmt.where(Problem.status == "resolved", Problem.updated_at >= since)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
total = db.scalar(count_stmt) or 0
|
total = db.scalar(count_stmt) or 0
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class HostListResponse(BaseModel):
|
|||||||
total: int
|
total: int
|
||||||
page: int
|
page: int
|
||||||
page_size: int
|
page_size: int
|
||||||
|
latest_agent_versions: dict[str, str] = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
class EventSummary(BaseModel):
|
class EventSummary(BaseModel):
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
"""Сравнение версий агентов (ssh-monitor / rdp-login-monitor, формат X.Y.Z-SAC)."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import re
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from sqlalchemy import select
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from app.models import Host
|
||||||
|
|
||||||
|
_VERSION_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)(?:-SAC)?$", re.IGNORECASE)
|
||||||
|
_DEFAULT_LAG_THRESHOLD = 3
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True, order=True)
|
||||||
|
class ParsedAgentVersion:
|
||||||
|
major: int
|
||||||
|
minor: int
|
||||||
|
patch: int
|
||||||
|
|
||||||
|
|
||||||
|
def parse_agent_version(raw: str | None) -> ParsedAgentVersion | None:
|
||||||
|
if not raw:
|
||||||
|
return None
|
||||||
|
text = raw.strip()
|
||||||
|
match = _VERSION_RE.match(text)
|
||||||
|
if not match:
|
||||||
|
return None
|
||||||
|
return ParsedAgentVersion(
|
||||||
|
major=int(match.group(1)),
|
||||||
|
minor=int(match.group(2)),
|
||||||
|
patch=int(match.group(3)),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def agent_version_lag(host: ParsedAgentVersion, latest: ParsedAgentVersion) -> int | None:
|
||||||
|
"""Отставание от latest: patch при том же major.minor, иначе None (любое отставание)."""
|
||||||
|
if host > latest:
|
||||||
|
return 0
|
||||||
|
if host.major != latest.major or host.minor != latest.minor:
|
||||||
|
return None
|
||||||
|
return latest.patch - host.patch
|
||||||
|
|
||||||
|
|
||||||
|
def is_agent_version_outdated(
|
||||||
|
host_version: str | None,
|
||||||
|
latest_version: str | None,
|
||||||
|
*,
|
||||||
|
lag_threshold: int = _DEFAULT_LAG_THRESHOLD,
|
||||||
|
) -> bool:
|
||||||
|
host = parse_agent_version(host_version)
|
||||||
|
latest = parse_agent_version(latest_version)
|
||||||
|
if host is None or latest is None or host >= latest:
|
||||||
|
return False
|
||||||
|
lag = agent_version_lag(host, latest)
|
||||||
|
if lag is None:
|
||||||
|
return True
|
||||||
|
return lag >= lag_threshold
|
||||||
|
|
||||||
|
|
||||||
|
def latest_agent_versions_by_product(db: Session) -> dict[str, str]:
|
||||||
|
rows = db.execute(
|
||||||
|
select(Host.product, Host.product_version).where(
|
||||||
|
Host.product_version.isnot(None),
|
||||||
|
Host.product_version != "",
|
||||||
|
)
|
||||||
|
).all()
|
||||||
|
best: dict[str, ParsedAgentVersion] = {}
|
||||||
|
best_raw: dict[str, str] = {}
|
||||||
|
for product, version in rows:
|
||||||
|
parsed = parse_agent_version(version)
|
||||||
|
if parsed is None:
|
||||||
|
continue
|
||||||
|
current = best.get(product)
|
||||||
|
if current is None or parsed > current:
|
||||||
|
best[product] = parsed
|
||||||
|
best_raw[product] = version.strip()
|
||||||
|
return best_raw
|
||||||
@@ -62,3 +62,39 @@ def count_stale_hosts(db: Session, stale_minutes: int) -> int:
|
|||||||
for host_id in host_ids
|
for host_id in host_ids
|
||||||
if agent_status(hb_map.get(host_id), stale_minutes=stale_minutes) == "stale"
|
if agent_status(hb_map.get(host_id), stale_minutes=stale_minutes) == "stale"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def apply_agent_status_host_filter(
|
||||||
|
stmt,
|
||||||
|
count_stmt,
|
||||||
|
agent_status_filter: str,
|
||||||
|
*,
|
||||||
|
stale_minutes: int,
|
||||||
|
):
|
||||||
|
"""Ограничить выборку Host по online / stale / unknown (как в agent_status)."""
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
hb_subq = (
|
||||||
|
select(Event.host_id, func.max(Event.received_at).label("last_hb"))
|
||||||
|
.where(Event.type == HEARTBEAT_TYPE)
|
||||||
|
.group_by(Event.host_id)
|
||||||
|
.subquery()
|
||||||
|
)
|
||||||
|
cutoff = datetime.now(timezone.utc) - timedelta(minutes=stale_minutes)
|
||||||
|
|
||||||
|
if agent_status_filter == "online":
|
||||||
|
join = stmt.join(hb_subq, Host.id == hb_subq.c.host_id)
|
||||||
|
count_join = count_stmt.join(hb_subq, Host.id == hb_subq.c.host_id)
|
||||||
|
cond = hb_subq.c.last_hb >= cutoff
|
||||||
|
return join.where(cond), count_join.where(cond)
|
||||||
|
if agent_status_filter == "stale":
|
||||||
|
join = stmt.join(hb_subq, Host.id == hb_subq.c.host_id)
|
||||||
|
count_join = count_stmt.join(hb_subq, Host.id == hb_subq.c.host_id)
|
||||||
|
cond = hb_subq.c.last_hb < cutoff
|
||||||
|
return join.where(cond), count_join.where(cond)
|
||||||
|
if agent_status_filter == "unknown":
|
||||||
|
join = stmt.outerjoin(hb_subq, Host.id == hb_subq.c.host_id)
|
||||||
|
count_join = count_stmt.outerjoin(hb_subq, Host.id == hb_subq.c.host_id)
|
||||||
|
cond = hb_subq.c.last_hb.is_(None)
|
||||||
|
return join.where(cond), count_join.where(cond)
|
||||||
|
return stmt, count_stmt
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
"""Agent version parse/compare for outdated highlighting."""
|
||||||
|
|
||||||
|
from app.services.agent_version import is_agent_version_outdated, latest_agent_versions_by_product, parse_agent_version
|
||||||
|
from app.models import Host
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_agent_version():
|
||||||
|
assert parse_agent_version("2.0.25-SAC") == parse_agent_version("2.0.25")
|
||||||
|
assert parse_agent_version("bad") is None
|
||||||
|
assert parse_agent_version(None) is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_outdated_same_minor_patch_lag():
|
||||||
|
latest = "2.0.25-SAC"
|
||||||
|
assert is_agent_version_outdated("2.0.25-SAC", latest) is False
|
||||||
|
assert is_agent_version_outdated("2.0.24-SAC", latest) is False
|
||||||
|
assert is_agent_version_outdated("2.0.23-SAC", latest) is False
|
||||||
|
assert is_agent_version_outdated("2.0.22-SAC", latest) is True
|
||||||
|
assert is_agent_version_outdated("2.0.18-SAC", latest) is True
|
||||||
|
assert is_agent_version_outdated("2.0.20-SAC", latest) is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_outdated_different_minor_or_major():
|
||||||
|
latest = "2.0.1-SAC"
|
||||||
|
assert is_agent_version_outdated("1.2.5-SAC", latest) is True
|
||||||
|
assert is_agent_version_outdated("2.1.0-SAC", latest) is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_latest_agent_versions_by_product(db_session):
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
|
db_session.add_all(
|
||||||
|
[
|
||||||
|
Host(
|
||||||
|
hostname="linux-a",
|
||||||
|
os_family="linux",
|
||||||
|
product="ssh-monitor",
|
||||||
|
product_version="1.2.5-SAC",
|
||||||
|
last_seen_at=now,
|
||||||
|
),
|
||||||
|
Host(
|
||||||
|
hostname="linux-b",
|
||||||
|
os_family="linux",
|
||||||
|
product="ssh-monitor",
|
||||||
|
product_version="2.0.1-SAC",
|
||||||
|
last_seen_at=now,
|
||||||
|
),
|
||||||
|
Host(
|
||||||
|
hostname="win-a",
|
||||||
|
os_family="windows",
|
||||||
|
product="rdp-login-monitor",
|
||||||
|
product_version="2.0.18-SAC",
|
||||||
|
last_seen_at=now,
|
||||||
|
),
|
||||||
|
Host(
|
||||||
|
hostname="win-b",
|
||||||
|
os_family="windows",
|
||||||
|
product="rdp-login-monitor",
|
||||||
|
product_version="2.0.25-SAC",
|
||||||
|
last_seen_at=now,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
db_session.commit()
|
||||||
|
|
||||||
|
latest = latest_agent_versions_by_product(db_session)
|
||||||
|
assert latest["ssh-monitor"] == "2.0.1-SAC"
|
||||||
|
assert latest["rdp-login-monitor"] == "2.0.25-SAC"
|
||||||
@@ -1,11 +1,86 @@
|
|||||||
"""Hosts list API."""
|
"""Hosts list API."""
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from app.config import get_settings
|
||||||
from app.models import Event, Host, Problem
|
from app.models import Event, Host, Problem
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def host_stale_settings(monkeypatch):
|
||||||
|
monkeypatch.setenv("SAC_HEARTBEAT_STALE_MINUTES", "60")
|
||||||
|
get_settings.cache_clear()
|
||||||
|
yield
|
||||||
|
get_settings.cache_clear()
|
||||||
|
|
||||||
|
|
||||||
|
def test_hosts_filter_agent_status_stale(client, db_session, jwt_headers, host_stale_settings):
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
|
stale_host = Host(
|
||||||
|
hostname="stale-pc",
|
||||||
|
os_family="windows",
|
||||||
|
product="rdp-login-monitor",
|
||||||
|
last_seen_at=now,
|
||||||
|
)
|
||||||
|
fresh_host = Host(
|
||||||
|
hostname="fresh-pc",
|
||||||
|
os_family="windows",
|
||||||
|
product="rdp-login-monitor",
|
||||||
|
last_seen_at=now,
|
||||||
|
)
|
||||||
|
unknown_host = Host(
|
||||||
|
hostname="unknown-pc",
|
||||||
|
os_family="linux",
|
||||||
|
product="ssh-monitor",
|
||||||
|
last_seen_at=now,
|
||||||
|
)
|
||||||
|
db_session.add_all([stale_host, fresh_host, unknown_host])
|
||||||
|
db_session.flush()
|
||||||
|
|
||||||
|
db_session.add(
|
||||||
|
Event(
|
||||||
|
event_id=str(uuid.uuid4()),
|
||||||
|
host_id=stale_host.id,
|
||||||
|
occurred_at=now - timedelta(hours=2),
|
||||||
|
received_at=now - timedelta(hours=2),
|
||||||
|
category="agent",
|
||||||
|
type="agent.heartbeat",
|
||||||
|
severity="info",
|
||||||
|
title="hb",
|
||||||
|
summary="s",
|
||||||
|
payload={},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db_session.add(
|
||||||
|
Event(
|
||||||
|
event_id=str(uuid.uuid4()),
|
||||||
|
host_id=fresh_host.id,
|
||||||
|
occurred_at=now - timedelta(minutes=5),
|
||||||
|
received_at=now - timedelta(minutes=5),
|
||||||
|
category="agent",
|
||||||
|
type="agent.heartbeat",
|
||||||
|
severity="info",
|
||||||
|
title="hb",
|
||||||
|
summary="s",
|
||||||
|
payload={},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db_session.commit()
|
||||||
|
|
||||||
|
r = client.get("/api/v1/hosts?agent_status=stale", headers=jwt_headers)
|
||||||
|
assert r.status_code == 200
|
||||||
|
body = r.json()
|
||||||
|
assert body["total"] == 1
|
||||||
|
assert body["items"][0]["hostname"] == "stale-pc"
|
||||||
|
assert body["items"][0]["agent_status"] == "stale"
|
||||||
|
|
||||||
|
r_all = client.get("/api/v1/hosts", headers=jwt_headers)
|
||||||
|
assert r_all.json()["total"] == 3
|
||||||
|
|
||||||
|
|
||||||
def test_hosts_search_by_display_name(client, db_session, jwt_headers):
|
def test_hosts_search_by_display_name(client, db_session, jwt_headers):
|
||||||
h = Host(
|
h = Host(
|
||||||
hostname="pc-01",
|
hostname="pc-01",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
"""Problems correlation and API smoke tests."""
|
"""Problems correlation and API smoke tests."""
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
from tests.test_ingest import VALID_EVENT
|
from app.models import Host, Problem
|
||||||
|
|
||||||
|
|
||||||
def _event_payload(**overrides):
|
def _event_payload(**overrides):
|
||||||
@@ -67,3 +67,101 @@ def test_new_problem_after_resolve(client, auth_headers, jwt_headers):
|
|||||||
assert len(open_items) == 1
|
assert len(open_items) == 1
|
||||||
assert open_items[0]["event_count"] == 1
|
assert open_items[0]["event_count"] == 1
|
||||||
assert open_items[0]["id"] != pid
|
assert open_items[0]["id"] != pid
|
||||||
|
|
||||||
|
|
||||||
|
def test_problems_created_within_hours(client, db_session, jwt_headers):
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
|
h = Host(
|
||||||
|
hostname="p-host",
|
||||||
|
os_family="linux",
|
||||||
|
product="ssh-monitor",
|
||||||
|
last_seen_at=now,
|
||||||
|
)
|
||||||
|
db_session.add(h)
|
||||||
|
db_session.flush()
|
||||||
|
db_session.add(
|
||||||
|
Problem(
|
||||||
|
host_id=h.id,
|
||||||
|
title="recent",
|
||||||
|
summary="s",
|
||||||
|
severity="warning",
|
||||||
|
status="open",
|
||||||
|
rule_id="rule:test",
|
||||||
|
fingerprint="fp-recent",
|
||||||
|
event_count=1,
|
||||||
|
last_seen_at=now,
|
||||||
|
created_at=now - timedelta(hours=2),
|
||||||
|
updated_at=now - timedelta(hours=2),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db_session.add(
|
||||||
|
Problem(
|
||||||
|
host_id=h.id,
|
||||||
|
title="old",
|
||||||
|
summary="s",
|
||||||
|
severity="warning",
|
||||||
|
status="resolved",
|
||||||
|
rule_id="rule:test",
|
||||||
|
fingerprint="fp-old",
|
||||||
|
event_count=1,
|
||||||
|
last_seen_at=now,
|
||||||
|
created_at=now - timedelta(days=3),
|
||||||
|
updated_at=now - timedelta(days=2),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db_session.commit()
|
||||||
|
|
||||||
|
r = client.get("/api/v1/problems?created_within_hours=24", headers=jwt_headers)
|
||||||
|
assert r.status_code == 200
|
||||||
|
body = r.json()
|
||||||
|
assert body["total"] == 1
|
||||||
|
assert body["items"][0]["title"] == "recent"
|
||||||
|
|
||||||
|
|
||||||
|
def test_problems_resolved_within_hours(client, db_session, jwt_headers):
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
|
h = Host(
|
||||||
|
hostname="r-host",
|
||||||
|
os_family="linux",
|
||||||
|
product="ssh-monitor",
|
||||||
|
last_seen_at=now,
|
||||||
|
)
|
||||||
|
db_session.add(h)
|
||||||
|
db_session.flush()
|
||||||
|
db_session.add(
|
||||||
|
Problem(
|
||||||
|
host_id=h.id,
|
||||||
|
title="closed today",
|
||||||
|
summary="s",
|
||||||
|
severity="warning",
|
||||||
|
status="resolved",
|
||||||
|
rule_id="rule:test",
|
||||||
|
fingerprint="fp-closed-today",
|
||||||
|
event_count=1,
|
||||||
|
last_seen_at=now,
|
||||||
|
created_at=now - timedelta(days=2),
|
||||||
|
updated_at=now - timedelta(hours=1),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db_session.add(
|
||||||
|
Problem(
|
||||||
|
host_id=h.id,
|
||||||
|
title="closed long ago",
|
||||||
|
summary="s",
|
||||||
|
severity="warning",
|
||||||
|
status="resolved",
|
||||||
|
rule_id="rule:test",
|
||||||
|
fingerprint="fp-closed-old",
|
||||||
|
event_count=1,
|
||||||
|
last_seen_at=now,
|
||||||
|
created_at=now - timedelta(days=10),
|
||||||
|
updated_at=now - timedelta(days=5),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db_session.commit()
|
||||||
|
|
||||||
|
r = client.get("/api/v1/problems?resolved_within_hours=24", headers=jwt_headers)
|
||||||
|
assert r.status_code == 200
|
||||||
|
body = r.json()
|
||||||
|
assert body["total"] == 1
|
||||||
|
assert body["items"][0]["title"] == "closed today"
|
||||||
|
|||||||
@@ -223,6 +223,7 @@ export interface HostListResponse {
|
|||||||
total: number;
|
total: number;
|
||||||
page: number;
|
page: number;
|
||||||
page_size: number;
|
page_size: number;
|
||||||
|
latest_agent_versions?: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProblemSummary {
|
export interface ProblemSummary {
|
||||||
|
|||||||
@@ -287,6 +287,15 @@ pre {
|
|||||||
color: #9aa4b2;
|
color: #9aa4b2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.agent-version-outdated {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.1rem 0.35rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #5c1a1a;
|
||||||
|
color: #ffd4d4;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
.live-badge {
|
.live-badge {
|
||||||
color: #6bcb77;
|
color: #6bcb77;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
const VERSION_RE = /^(\d+)\.(\d+)\.(\d+)(?:-SAC)?$/i;
|
||||||
|
const DEFAULT_LAG_THRESHOLD = 3;
|
||||||
|
|
||||||
|
export interface ParsedAgentVersion {
|
||||||
|
major: number;
|
||||||
|
minor: number;
|
||||||
|
patch: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseAgentVersion(raw: string | null | undefined): ParsedAgentVersion | null {
|
||||||
|
if (!raw) return null;
|
||||||
|
const match = raw.trim().match(VERSION_RE);
|
||||||
|
if (!match) return null;
|
||||||
|
return {
|
||||||
|
major: Number(match[1]),
|
||||||
|
minor: Number(match[2]),
|
||||||
|
patch: Number(match[3]),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function compareVersions(a: ParsedAgentVersion, b: ParsedAgentVersion): number {
|
||||||
|
if (a.major !== b.major) return a.major - b.major;
|
||||||
|
if (a.minor !== b.minor) return a.minor - b.minor;
|
||||||
|
return a.patch - b.patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
function agentVersionLag(host: ParsedAgentVersion, latest: ParsedAgentVersion): number | null {
|
||||||
|
if (compareVersions(host, latest) > 0) return 0;
|
||||||
|
if (host.major !== latest.major || host.minor !== latest.minor) return null;
|
||||||
|
return latest.patch - host.patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isAgentVersionOutdated(
|
||||||
|
hostVersion: string | null | undefined,
|
||||||
|
latestVersion: string | null | undefined,
|
||||||
|
lagThreshold = DEFAULT_LAG_THRESHOLD,
|
||||||
|
): boolean {
|
||||||
|
const host = parseAgentVersion(hostVersion);
|
||||||
|
const latest = parseAgentVersion(latestVersion);
|
||||||
|
if (!host || !latest || compareVersions(host, latest) >= 0) return false;
|
||||||
|
const lag = agentVersionLag(host, latest);
|
||||||
|
if (lag === null) return true;
|
||||||
|
return lag >= lagThreshold;
|
||||||
|
}
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<div class="dash-label">Новых проблем за 24 ч</div>
|
<div class="dash-label">Новых проблем за 24 ч</div>
|
||||||
|
|
||||||
<RouterLink to="/problems">Все проблемы →</RouterLink>
|
<RouterLink :to="{ path: '/problems', query: { created_within_hours: '24' } }">Новые за 24 ч →</RouterLink>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<div class="dash-label">Закрыто за 24 ч</div>
|
<div class="dash-label">Закрыто за 24 ч</div>
|
||||||
|
|
||||||
<RouterLink :to="{ path: '/problems', query: { status: 'resolved' } }">Resolved →</RouterLink>
|
<RouterLink :to="{ path: '/problems', query: { resolved_within_hours: '24' } }">Закрытые за 24 ч →</RouterLink>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
<div class="dash-label">Устаревший heartbeat</div>
|
<div class="dash-label">Устаревший heartbeat</div>
|
||||||
|
|
||||||
<RouterLink to="/hosts">Хосты →</RouterLink>
|
<RouterLink :to="{ path: '/hosts', query: { agent_status: 'stale' } }">Stale-хосты →</RouterLink>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,18 @@
|
|||||||
<div class="filters">
|
<div class="filters">
|
||||||
<label>
|
<label>
|
||||||
Поиск (hostname / display name)
|
Поиск (hostname / display name)
|
||||||
<input v-model="search" type="search" placeholder="UNMS Kalina" @keyup.enter="loadHosts" />
|
<input v-model="search" type="search" placeholder="UNMS Kalina" @keyup.enter="applyFilters" />
|
||||||
</label>
|
</label>
|
||||||
<button type="button" class="secondary" @click="loadHosts">Найти</button>
|
<label>
|
||||||
|
Статус агента
|
||||||
|
<select v-model="agentStatusFilter" @change="applyFilters">
|
||||||
|
<option value="">Все</option>
|
||||||
|
<option value="online">online</option>
|
||||||
|
<option value="stale">stale</option>
|
||||||
|
<option value="unknown">unknown</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<button type="button" class="secondary" @click="applyFilters">Найти</button>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="error" class="error">{{ error }}</p>
|
<p v-if="error" class="error">{{ error }}</p>
|
||||||
<p v-else-if="loading">Загрузка…</p>
|
<p v-else-if="loading">Загрузка…</p>
|
||||||
@@ -44,7 +53,14 @@
|
|||||||
<td>{{ h.id }}</td>
|
<td>{{ h.id }}</td>
|
||||||
<td>{{ h.display_name || h.hostname }}</td>
|
<td>{{ h.display_name || h.hostname }}</td>
|
||||||
<td>{{ h.hostname }}</td>
|
<td>{{ h.hostname }}</td>
|
||||||
<td>{{ h.product_version || "—" }}</td>
|
<td>
|
||||||
|
<span
|
||||||
|
:class="{ 'agent-version-outdated': isVersionOutdated(h) }"
|
||||||
|
:title="versionTitle(h)"
|
||||||
|
>
|
||||||
|
{{ h.product_version || "—" }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
<td>{{ h.os_family }}</td>
|
<td>{{ h.os_family }}</td>
|
||||||
<td>{{ h.ipv4 || "—" }}</td>
|
<td>{{ h.ipv4 || "—" }}</td>
|
||||||
<td :class="'agent-' + h.agent_status">{{ agentLabel(h.agent_status) }}</td>
|
<td :class="'agent-' + h.agent_status">{{ agentLabel(h.agent_status) }}</td>
|
||||||
@@ -80,8 +96,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { useSacLiveEventStream } from "../composables/useSacLiveEventStream";
|
import { useSacLiveEventStream } from "../composables/useSacLiveEventStream";
|
||||||
import {
|
import {
|
||||||
apiFetch,
|
apiFetch,
|
||||||
@@ -91,13 +107,16 @@ import {
|
|||||||
type HostSummary,
|
type HostSummary,
|
||||||
} from "../api";
|
} from "../api";
|
||||||
import { patchHostSummaryFromDetail } from "../utils/hostsLiveUpdate";
|
import { patchHostSummaryFromDetail } from "../utils/hostsLiveUpdate";
|
||||||
|
import { isAgentVersionOutdated } from "../utils/agentVersion";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
const data = ref<HostListResponse | null>(null);
|
const data = ref<HostListResponse | null>(null);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const error = ref("");
|
const error = ref("");
|
||||||
const search = ref("");
|
const search = ref("");
|
||||||
|
const agentStatusFilter = ref("");
|
||||||
type SortKey =
|
type SortKey =
|
||||||
| "id"
|
| "id"
|
||||||
| "display_name"
|
| "display_name"
|
||||||
@@ -168,6 +187,19 @@ function agentLabel(status: string) {
|
|||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isVersionOutdated(h: HostSummary): boolean {
|
||||||
|
const latest = data.value?.latest_agent_versions?.[h.product];
|
||||||
|
return isAgentVersionOutdated(h.product_version, latest);
|
||||||
|
}
|
||||||
|
|
||||||
|
function versionTitle(h: HostSummary): string {
|
||||||
|
const latest = data.value?.latest_agent_versions?.[h.product];
|
||||||
|
if (!isVersionOutdated(h)) return "";
|
||||||
|
return latest
|
||||||
|
? `Устарела относительно последней для ${h.product}: ${latest}`
|
||||||
|
: "Устаревшая версия агента";
|
||||||
|
}
|
||||||
|
|
||||||
function openHost(id: number) {
|
function openHost(id: number) {
|
||||||
router.push(`/hosts/${id}`);
|
router.push(`/hosts/${id}`);
|
||||||
}
|
}
|
||||||
@@ -258,6 +290,7 @@ async function loadHosts() {
|
|||||||
const q = search.value.trim();
|
const q = search.value.trim();
|
||||||
const params = new URLSearchParams({ page: "1", page_size: "100" });
|
const params = new URLSearchParams({ page: "1", page_size: "100" });
|
||||||
if (q) params.set("hostname", q);
|
if (q) params.set("hostname", q);
|
||||||
|
if (agentStatusFilter.value) params.set("agent_status", agentStatusFilter.value);
|
||||||
data.value = await apiFetch<HostListResponse>(`/api/v1/hosts?${params}`);
|
data.value = await apiFetch<HostListResponse>(`/api/v1/hosts?${params}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error.value = e instanceof Error ? e.message : "Ошибка";
|
error.value = e instanceof Error ? e.message : "Ошибка";
|
||||||
@@ -266,6 +299,25 @@ async function loadHosts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildHostsQuery(): Record<string, string> {
|
||||||
|
const q: Record<string, string> = {};
|
||||||
|
if (search.value.trim()) q.hostname = search.value.trim();
|
||||||
|
if (agentStatusFilter.value) q.agent_status = agentStatusFilter.value;
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyFilters() {
|
||||||
|
void router.replace({ path: "/hosts", query: buildHostsQuery() });
|
||||||
|
void loadHosts();
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncFromRoute() {
|
||||||
|
const hostname = route.query.hostname;
|
||||||
|
if (typeof hostname === "string") search.value = hostname;
|
||||||
|
const status = route.query.agent_status;
|
||||||
|
agentStatusFilter.value = typeof status === "string" ? status : "";
|
||||||
|
}
|
||||||
|
|
||||||
async function patchHostRowFromLatestEvent() {
|
async function patchHostRowFromLatestEvent() {
|
||||||
if (!data.value?.items.length || patchingHostRow) return;
|
if (!data.value?.items.length || patchingHostRow) return;
|
||||||
patchingHostRow = true;
|
patchingHostRow = true;
|
||||||
@@ -315,6 +367,15 @@ async function confirmDelete(h: HostSummary) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
syncFromRoute();
|
||||||
loadHosts();
|
loadHosts();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [route.query.hostname, route.query.agent_status] as const,
|
||||||
|
() => {
|
||||||
|
syncFromRoute();
|
||||||
|
loadHosts();
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>Проблемы</h1>
|
<h1>Проблемы</h1>
|
||||||
<div class="filters">
|
<div class="filters">
|
||||||
<select v-model="statusFilter" @change="load(1)">
|
<select v-model="statusFilter" @change="applyFilters">
|
||||||
<option value="">Все статусы</option>
|
<option value="">Все статусы</option>
|
||||||
<option value="open">open</option>
|
<option value="open">open</option>
|
||||||
<option value="acknowledged">acknowledged</option>
|
<option value="acknowledged">acknowledged</option>
|
||||||
<option value="resolved">resolved</option>
|
<option value="resolved">resolved</option>
|
||||||
</select>
|
</select>
|
||||||
<select v-model="severityFilter" @change="load(1)">
|
<select v-model="severityFilter" @change="applyFilters">
|
||||||
<option value="">Все severity</option>
|
<option value="">Все severity</option>
|
||||||
<option>info</option>
|
<option>info</option>
|
||||||
<option>warning</option>
|
<option>warning</option>
|
||||||
<option>high</option>
|
<option>high</option>
|
||||||
<option>critical</option>
|
<option>critical</option>
|
||||||
</select>
|
</select>
|
||||||
<input v-model="hostnameFilter" placeholder="hostname / имя сервера" @keyup.enter="load(1)" />
|
<input v-model="hostnameFilter" placeholder="hostname / имя сервера" @keyup.enter="applyFilters" />
|
||||||
<button type="button" @click="load(1)">Применить</button>
|
<button type="button" @click="applyFilters">Применить</button>
|
||||||
</div>
|
</div>
|
||||||
|
<p v-if="timeFilterHint" class="muted">{{ timeFilterHint }}</p>
|
||||||
<p v-if="error" class="error">{{ error }}</p>
|
<p v-if="error" class="error">{{ error }}</p>
|
||||||
<p v-else-if="loading">Загрузка…</p>
|
<p v-else-if="loading">Загрузка…</p>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -90,12 +91,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, watch } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { ackProblem, apiFetch, resolveProblem, type ProblemListResponse } from "../api";
|
import { ackProblem, apiFetch, resolveProblem, type ProblemListResponse } from "../api";
|
||||||
import { formatServerName } from "../utils/hostDisplay";
|
import { formatServerName } from "../utils/hostDisplay";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const data = ref<ProblemListResponse | null>(null);
|
const data = ref<ProblemListResponse | null>(null);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@@ -105,8 +107,20 @@ const pageSize = 50;
|
|||||||
const statusFilter = ref("");
|
const statusFilter = ref("");
|
||||||
const severityFilter = ref("");
|
const severityFilter = ref("");
|
||||||
const hostnameFilter = ref("");
|
const hostnameFilter = ref("");
|
||||||
|
const createdWithinHours = ref("");
|
||||||
|
const resolvedWithinHours = ref("");
|
||||||
const actingId = ref<number | null>(null);
|
const actingId = ref<number | null>(null);
|
||||||
|
|
||||||
|
const timeFilterHint = computed(() => {
|
||||||
|
if (createdWithinHours.value) {
|
||||||
|
return `Показаны проблемы, созданные за последние ${createdWithinHours.value} ч (любой статус).`;
|
||||||
|
}
|
||||||
|
if (resolvedWithinHours.value) {
|
||||||
|
return `Показаны проблемы, закрытые за последние ${resolvedWithinHours.value} ч.`;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
|
||||||
function formatDt(iso: string) {
|
function formatDt(iso: string) {
|
||||||
return new Date(iso).toLocaleString("ru-RU");
|
return new Date(iso).toLocaleString("ru-RU");
|
||||||
}
|
}
|
||||||
@@ -120,9 +134,13 @@ async function load(p: number) {
|
|||||||
page: String(page.value),
|
page: String(page.value),
|
||||||
page_size: String(pageSize),
|
page_size: String(pageSize),
|
||||||
});
|
});
|
||||||
if (statusFilter.value) params.set("status", statusFilter.value);
|
if (statusFilter.value && !resolvedWithinHours.value) {
|
||||||
|
params.set("status", statusFilter.value);
|
||||||
|
}
|
||||||
if (severityFilter.value) params.set("severity", severityFilter.value);
|
if (severityFilter.value) params.set("severity", severityFilter.value);
|
||||||
if (hostnameFilter.value.trim()) params.set("hostname", hostnameFilter.value.trim());
|
if (hostnameFilter.value.trim()) params.set("hostname", hostnameFilter.value.trim());
|
||||||
|
if (createdWithinHours.value) params.set("created_within_hours", createdWithinHours.value);
|
||||||
|
if (resolvedWithinHours.value) params.set("resolved_within_hours", resolvedWithinHours.value);
|
||||||
data.value = await apiFetch<ProblemListResponse>(`/api/v1/problems?${params}`);
|
data.value = await apiFetch<ProblemListResponse>(`/api/v1/problems?${params}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error.value = e instanceof Error ? e.message : "Ошибка загрузки";
|
error.value = e instanceof Error ? e.message : "Ошибка загрузки";
|
||||||
@@ -131,6 +149,37 @@ async function load(p: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildProblemsQuery(): Record<string, string> {
|
||||||
|
const q: Record<string, string> = {};
|
||||||
|
if (statusFilter.value && !resolvedWithinHours.value) q.status = statusFilter.value;
|
||||||
|
if (severityFilter.value) q.severity = severityFilter.value;
|
||||||
|
if (hostnameFilter.value.trim()) q.hostname = hostnameFilter.value.trim();
|
||||||
|
if (createdWithinHours.value) q.created_within_hours = createdWithinHours.value;
|
||||||
|
if (resolvedWithinHours.value) q.resolved_within_hours = resolvedWithinHours.value;
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyFilters() {
|
||||||
|
if (resolvedWithinHours.value) createdWithinHours.value = "";
|
||||||
|
else if (createdWithinHours.value) resolvedWithinHours.value = "";
|
||||||
|
void router.replace({ path: "/problems", query: buildProblemsQuery() });
|
||||||
|
void load(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncFromRoute() {
|
||||||
|
const status = route.query.status;
|
||||||
|
statusFilter.value = typeof status === "string" ? status : "";
|
||||||
|
const severity = route.query.severity;
|
||||||
|
severityFilter.value = typeof severity === "string" ? severity : "";
|
||||||
|
const hostname = route.query.hostname;
|
||||||
|
hostnameFilter.value = typeof hostname === "string" ? hostname : "";
|
||||||
|
const created = route.query.created_within_hours;
|
||||||
|
createdWithinHours.value = typeof created === "string" ? created : "";
|
||||||
|
const resolved = route.query.resolved_within_hours;
|
||||||
|
resolvedWithinHours.value = typeof resolved === "string" ? resolved : "";
|
||||||
|
if (resolvedWithinHours.value) statusFilter.value = "resolved";
|
||||||
|
}
|
||||||
|
|
||||||
async function doAck(id: number) {
|
async function doAck(id: number) {
|
||||||
actingId.value = id;
|
actingId.value = id;
|
||||||
error.value = "";
|
error.value = "";
|
||||||
@@ -158,22 +207,22 @@ async function doResolve(id: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const status = route.query.status;
|
syncFromRoute();
|
||||||
if (typeof status === "string" && status) statusFilter.value = status;
|
|
||||||
const severity = route.query.severity;
|
|
||||||
if (typeof severity === "string" && severity) severityFilter.value = severity;
|
|
||||||
const hostname = route.query.hostname;
|
|
||||||
if (typeof hostname === "string" && hostname) hostnameFilter.value = hostname;
|
|
||||||
load(1);
|
load(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [route.query.status, route.query.severity, route.query.hostname] as const,
|
() =>
|
||||||
([status, severity, hostname]) => {
|
[
|
||||||
if (typeof status === "string") statusFilter.value = status;
|
route.query.status,
|
||||||
if (typeof severity === "string") severityFilter.value = severity;
|
route.query.severity,
|
||||||
if (typeof hostname === "string") hostnameFilter.value = hostname;
|
route.query.hostname,
|
||||||
|
route.query.created_within_hours,
|
||||||
|
route.query.resolved_within_hours,
|
||||||
|
] as const,
|
||||||
|
() => {
|
||||||
|
syncFromRoute();
|
||||||
load(1);
|
load(1);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user