Skip to content

feat(hosts): notification severity and trend charts on metrics tab#165

Merged
simonjcarr merged 1 commit into
mainfrom
feature/host-notification-charts
Apr 13, 2026
Merged

feat(hosts): notification severity and trend charts on metrics tab#165
simonjcarr merged 1 commit into
mainfrom
feature/host-notification-charts

Conversation

@simonjcarr
Copy link
Copy Markdown
Collaborator

Summary

Adds host-scoped notification charts to Monitoring → Metrics on every host detail page.

New charts

Chart Description
Notification Severity Donut chart — critical / warning / info breakdown for this host only
Notification Trend Line chart — critical & warning counts over a selectable window (1h → 3 months)

Both charts sit below the existing Heartbeat Interval chart in the metrics tab.

Implementation

  • New component host-notification-charts.tsx in the host detail directory — self-contained, owns its own time-range state and queries
  • getNotificationStats and getNotificationsOverTime now accept an optional hostId parameter; when provided they add resource_type = 'host' and resource_id = hostId to the WHERE clause — existing callers (global notifications page) pass no hostId and are unaffected
  • Charts use the same currentUserId context as the rest of the host page so results are scoped to the viewing user's notifications about this host
  • Trend chart includes the same time-range dropdown (1h · 6h · 12h · 24h · 7d · 30d · 3 months) with hourly/daily aggregation and dynamic subtitle as the global notifications page

Test plan

  • Open a host detail page → Monitoring → Metrics
  • Pie chart renders with correct severity colours and percentages
  • Trend chart renders with legible axis labels in dark mode
  • Changing the trend range dropdown fetches and displays the correct data
  • Both charts show "No notifications / No data" placeholder when no notifications exist for this host
  • Global notifications page charts are unaffected
  • pnpm run build passes with no TypeScript errors

🤖 Generated with Claude Code

Adds two charts to the Monitoring → Metrics tab of each host detail page,
both scoped to that specific host:

- Severity breakdown (pie/donut): shows the count and percentage of
  critical / warning / info notifications received for this host
- Notification trend (line chart): shows critical & warning notification
  counts over a selectable time window (1h · 6h · 12h · 24h · 7d · 30d ·
  3 months) with the same hourly/daily aggregation logic as the global
  notifications page

Server actions getNotificationStats and getNotificationsOverTime now
accept an optional hostId parameter which adds resourceType='host' and
resourceId=hostId filters, keeping the existing global behaviour unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@simonjcarr simonjcarr merged commit 271df68 into main Apr 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant