- Added `psutil` dependency for system performance metrics. - Implemented a new layout in `dashboard/layouts/system_health.py` using Mantine components for real-time monitoring of data collection services, database health, Redis status, and system performance. - Enhanced callbacks in `dashboard/callbacks/system_health.py` for detailed status updates and error handling. - Introduced quick status indicators for data collection, database, Redis, and performance metrics with auto-refresh functionality. - Created modals for viewing detailed data collection information and service logs. - Updated documentation to reflect the new features and usage guidelines.
212 lines
9.3 KiB
Python
212 lines
9.3 KiB
Python
"""
|
|
System health monitoring layout for the dashboard.
|
|
"""
|
|
|
|
from dash import html, dcc
|
|
import dash_mantine_components as dmc
|
|
|
|
|
|
def get_system_health_layout():
|
|
"""Create the enhanced system health monitoring layout with market data monitoring."""
|
|
return html.Div([
|
|
# Header section
|
|
dmc.Paper([
|
|
dmc.Title("⚙️ System Health & Data Monitoring", order=2, c="#2c3e50"),
|
|
dmc.Text("Real-time monitoring of data collection services, database health, and system performance",
|
|
c="dimmed", size="sm")
|
|
], p="lg", mb="xl"),
|
|
|
|
# Quick Status Overview Row
|
|
dmc.Grid([
|
|
dmc.GridCol([
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Group([
|
|
dmc.Text("📊 Data Collection", fw=600, c="#2c3e50"),
|
|
], justify="space-between"),
|
|
html.Div(id='data-collection-quick-status',
|
|
children=[dmc.Badge("🔄 Checking...", color="yellow", variant="light")])
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True)
|
|
], span=3),
|
|
|
|
dmc.GridCol([
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Group([
|
|
dmc.Text("🗄️ Database", fw=600, c="#2c3e50"),
|
|
], justify="space-between"),
|
|
html.Div(id='database-quick-status',
|
|
children=[dmc.Badge("🔄 Checking...", color="yellow", variant="light")])
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True)
|
|
], span=3),
|
|
|
|
dmc.GridCol([
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Group([
|
|
dmc.Text("🔗 Redis", fw=600, c="#2c3e50"),
|
|
], justify="space-between"),
|
|
html.Div(id='redis-quick-status',
|
|
children=[dmc.Badge("🔄 Checking...", color="yellow", variant="light")])
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True)
|
|
], span=3),
|
|
|
|
dmc.GridCol([
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Group([
|
|
dmc.Text("📈 Performance", fw=600, c="#2c3e50"),
|
|
], justify="space-between"),
|
|
html.Div(id='performance-quick-status',
|
|
children=[dmc.Badge("🔄 Loading...", color="yellow", variant="light")])
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True)
|
|
], span=3),
|
|
], gutter="md", mb="xl"),
|
|
|
|
# Detailed Monitoring Sections
|
|
dmc.Grid([
|
|
# Left Column - Data Collection Service
|
|
dmc.GridCol([
|
|
# Data Collection Service Status
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Title("📡 Data Collection Service", order=4, c="#2c3e50")
|
|
], inheritPadding=True, py="xs", withBorder=True),
|
|
dmc.CardSection([
|
|
# Service Status
|
|
dmc.Stack([
|
|
dmc.Title("Service Status", order=5, c="#34495e"),
|
|
html.Div(id='data-collection-service-status'),
|
|
], gap="sm"),
|
|
|
|
# Data Collection Metrics
|
|
dmc.Stack([
|
|
dmc.Title("Collection Metrics", order=5, c="#34495e"),
|
|
html.Div(id='data-collection-metrics'),
|
|
], gap="sm"),
|
|
|
|
# Service Controls
|
|
dmc.Stack([
|
|
dmc.Title("Service Controls", order=5, c="#34495e"),
|
|
dmc.Group([
|
|
dmc.Button("🔄 Refresh Status", id="refresh-data-status-btn",
|
|
variant="light", color="blue", size="sm"),
|
|
dmc.Button("📊 View Details", id="view-collection-details-btn",
|
|
variant="outline", color="blue", size="sm"),
|
|
dmc.Button("📋 View Logs", id="view-collection-logs-btn",
|
|
variant="outline", color="gray", size="sm")
|
|
], gap="xs")
|
|
], gap="sm")
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True, mb="md"),
|
|
|
|
# Data Collector Health
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Title("🔌 Individual Collectors", order=4, c="#2c3e50")
|
|
], inheritPadding=True, py="xs", withBorder=True),
|
|
dmc.CardSection([
|
|
html.Div(id='individual-collectors-status'),
|
|
html.Div([
|
|
dmc.Alert(
|
|
"Collector health data will be displayed here when the data collection service is running.",
|
|
title="📊 Collector Health Monitoring",
|
|
color="blue",
|
|
variant="light",
|
|
id="collectors-info-alert"
|
|
)
|
|
], id='collectors-placeholder')
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True, mb="md")
|
|
], span=6),
|
|
|
|
# Right Column - System Health
|
|
dmc.GridCol([
|
|
# Database Status
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Title("🗄️ Database Health", order=4, c="#2c3e50")
|
|
], inheritPadding=True, py="xs", withBorder=True),
|
|
dmc.CardSection([
|
|
dmc.Stack([
|
|
dmc.Title("Connection Status", order=5, c="#34495e"),
|
|
html.Div(id='database-status')
|
|
], gap="sm"),
|
|
|
|
dmc.Stack([
|
|
dmc.Title("Database Statistics", order=5, c="#34495e"),
|
|
html.Div(id='database-stats')
|
|
], gap="sm")
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True, mb="md"),
|
|
|
|
# Redis Status
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Title("🔗 Redis Status", order=4, c="#2c3e50")
|
|
], inheritPadding=True, py="xs", withBorder=True),
|
|
dmc.CardSection([
|
|
dmc.Stack([
|
|
dmc.Title("Connection Status", order=5, c="#34495e"),
|
|
html.Div(id='redis-status')
|
|
], gap="sm"),
|
|
|
|
dmc.Stack([
|
|
dmc.Title("Redis Statistics", order=5, c="#34495e"),
|
|
html.Div(id='redis-stats')
|
|
], gap="sm")
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True, mb="md"),
|
|
|
|
# System Performance
|
|
dmc.Card([
|
|
dmc.CardSection([
|
|
dmc.Title("📈 System Performance", order=4, c="#2c3e50")
|
|
], inheritPadding=True, py="xs", withBorder=True),
|
|
dmc.CardSection([
|
|
html.Div(id='system-performance-metrics')
|
|
], p="md")
|
|
], shadow="sm", radius="md", withBorder=True, mb="md")
|
|
], span=6)
|
|
], gutter="md"),
|
|
|
|
# Data Collection Details Modal
|
|
dmc.Modal(
|
|
title="📊 Data Collection Details",
|
|
id="collection-details-modal",
|
|
children=[
|
|
html.Div(id="collection-details-content")
|
|
],
|
|
size="lg"
|
|
),
|
|
|
|
# Collection Logs Modal
|
|
dmc.Modal(
|
|
title="📋 Collection Service Logs",
|
|
id="collection-logs-modal",
|
|
children=[
|
|
dmc.ScrollArea([
|
|
dmc.Code(
|
|
id="collection-logs-content",
|
|
block=True,
|
|
style={
|
|
'white-space': 'pre-wrap',
|
|
'background-color': '#f8f9fa',
|
|
'padding': '15px',
|
|
'border-radius': '5px',
|
|
'font-family': 'monospace'
|
|
}
|
|
)
|
|
], h=400),
|
|
dmc.Group([
|
|
dmc.Button("Refresh", id="refresh-logs-btn", variant="light"),
|
|
dmc.Button("Close", id="close-logs-modal", variant="outline")
|
|
], justify="flex-end", mt="md")
|
|
],
|
|
size="xl"
|
|
)
|
|
]) |