Dashboard Package
Dashboard UI components and utilities. This documentation is auto-generated from Python docstrings.
Package Overview
HemoStat Dashboard Package
Real-time Streamlit dashboard for monitoring HemoStat container health system. Displays live container metrics, active issues, remediation history, and event timeline.
Main Application
Streamlit-based monitoring dashboard.
HemoStat Dashboard Main Application
Real-time Streamlit dashboard for monitoring HemoStat container health system. Displays live container metrics, active issues, remediation history, and event timeline with auto-refresh every 5 seconds.
- dashboard.app.check_redis_connection()[source]
Test Redis connection and return status.
- Returns:
True if Redis is connected, False otherwise
- Return type:
- dashboard.app.main()[source]
Main dashboard application entry point.
Initializes the dashboard, renders sidebar, header, content, and footer.
Render dashboard footer with version and status information.
Displays HemoStat version and last update timestamp.
- dashboard.app.render_header()[source]
Render dashboard header with title and connection status.
Displays main title, subtitle with current timestamp, and connection status indicator.
UI Components
Reusable dashboard components for displaying metrics and events.
Dashboard UI Components Module
Provides reusable Streamlit components for rendering dashboard visualizations. Includes metrics cards, health grids, issue feeds, history tables, and timelines.
- dashboard.components.format_timestamp(iso_timestamp)[source]
Format ISO timestamp to relative or absolute time string in Eastern Time (GMT-5).
Converts ISO timestamps to relative time for recent events (“2 minutes ago”, “1 hour ago”) and absolute time for older events (“Jan 3, 10:30 AM EST”).
- dashboard.components.get_event_type_icon(event_type)[source]
Map event type to text indicator.
Returns text indicator for different event types: - health_alert: [ALERT] - remediation: [REMEDIATION] - false_alarm: [FALSE ALARM] - unknown: [EVENT]
- dashboard.components.get_severity_emoji(severity)[source]
Map severity level to text indicator.
Returns text indicator for different severity levels: - critical: [CRITICAL] - high: [HIGH] - medium: [MEDIUM] - low: [LOW] - unknown: [UNKNOWN]
- dashboard.components.get_status_color(status)[source]
Map status string to hex color code.
Returns color codes for different status values: - success/healthy: green - failed/unhealthy: red - rejected: orange - unknown: gray
- dashboard.components.render_active_issues(events)[source]
Render active issues that need attention.
Displays failed/rejected remediations and recent health alerts with severity indicators. Uses expanders for detailed information.
- dashboard.components.render_health_grid(events)[source]
Render container health status in a grid layout.
Displays a table of containers with their latest status, CPU/memory percentages from hemostat:stats:* keys (preferred) or event data (fallback), and last update timestamp. Uses color coding for status (green=healthy, red=unhealthy, blue=remediated).
- dashboard.components.render_metrics_cards(remediation_stats, false_alarm_count, active_containers)[source]
Render key metrics in a row of cards.
Displays four metric cards showing total remediations, success rate, false alarms, and active containers. Uses color coding for success rate (green >80%, yellow 50-80%, red <50%).
- dashboard.components.render_remediation_history(events)[source]
Render table of remediation attempts with filtering.
Displays all remediation events with columns for timestamp, container, action, status, reason, and confidence. Includes filters for status, container, and time range. Reasons can be expanded to view full text.
- dashboard.components.render_timeline(events, max_events=100)[source]
Render chronological timeline of all events with graph visualization.
Displays events in reverse chronological order (newest first) with type indicators, container names, and expandable details. Also shows a timeline graph of event frequency.
Data Fetching Utilities
Redis data fetching and aggregation utilities.
Dashboard Data Fetcher Module
Provides Redis data access layer with efficient caching for dashboard operations. Uses Streamlit caching decorators to minimize Redis polling and improve performance.
- dashboard.data_fetcher.get_active_containers()
Fetch list of active container IDs from Redis with 5-second cache.
Scans Redis for keys matching hemostat:state:container:* pattern and extracts container IDs. Uses SCAN instead of KEYS for production safety.
- dashboard.data_fetcher.get_all_container_stats()
Fetch all container statistics from Redis with 5-second cache.
Scans Redis for keys matching hemostat:stats:* pattern and retrieves parsed stats for each container. Uses SCAN for production safety.
- dashboard.data_fetcher.get_all_events(limit=1000)
Fetch all events from Redis with 5-second cache.
Retrieves events from the hemostat:events:all list, parses JSON, and returns sorted by timestamp (newest first). Handles missing keys and malformed JSON gracefully.
- dashboard.data_fetcher.get_container_stats(container_id)
Fetch container statistics from Redis with 5-second cache.
Retrieves stats from hemostat:state:container:{container_id} key, parses JSON, and returns as dictionary. Returns None if key doesn’t exist or has expired.
- dashboard.data_fetcher.get_events_by_type(event_type, limit=1000)
Fetch events of a specific type from Redis with 5-second cache.
Retrieves events from hemostat:events:{event_type} list, parses JSON, and returns as list. Handles missing keys gracefully.
- dashboard.data_fetcher.get_false_alarm_count()
Count false alarm events from Redis with 5-second cache.
Uses LLEN to efficiently count events in hemostat:events:false_alarm list without fetching all events.
- Returns:
Number of false alarm events
- Return type:
- dashboard.data_fetcher.get_redis_client()
Get or create a cached Redis client for long-lived connections.
Loads Redis configuration from environment variables and establishes a connection with string response decoding enabled. Tests connection on first initialization.
- Returns:
Connected Redis client instance with decode_responses=True
- Return type:
redis.Redis
- Raises:
redis.ConnectionError – If Redis connection cannot be established
- dashboard.data_fetcher.get_remediation_stats()
Aggregate remediation statistics from Redis with 5-second cache.
Fetches events from hemostat:events:remediation_complete and calculates: - Total remediations - Success count - Failure count - Rejection count (cooldown/circuit breaker) - Success rate percentage