Dashboards, Widgets, & RSS
Relevant source files
The following files were used as context for generating this wiki page:
The Dashboard and Widget system provides a customizable visual interface for users to monitor infrastructure insights, utilization, and reporting data. Dashboards (represented by the MiqWidgetSet model) serve as containers for Widgets (MiqWidget), which display specific types of content such as charts, reports, or RSS feeds. This system integrates closely with the reporting engine to transform complex datasets into digestible UI components tailored to specific user roles or groups.
Sources: app/models/miq_widget.rb:6-21, app/models/miq_widget_set.rb, db/fixtures/miq_product_features.yml:450-480
Architecture Overview
The system is built on a hierarchical structure where dashboards are owned by users or groups and contain multiple widgets. Widgets are content-agnostic containers that delegate the actual data generation to specialized content classes based on their content_type.
Core Components and Relationships
The following diagram illustrates the relationship between dashboards, widgets, and the reporting results they consume.
Widgets (MiqWidget)
Widgets are the primary units of display. They support four main content types: report, chart, rss, and menu. Each widget can be configured with specific visibility rules based on user roles or groups.
Content Generation Logic
Widget content is generated asynchronously via the MiqTask and MiqQueue systems. When a widget is triggered for generation, it determines its subscribers and queues individual tasks for each group or user involved.
- Queueing: The
queue_generate_contentmethod checks if the widget is enabled and has active subscribers. - Task Creation: A
MiqTaskis created to track the overall progress across multiple targets (groups/users). - Callback: As individual queue messages finish,
generate_content_complete_callbackupdates the task percentage and status.
Sources: app/models/miq_widget.rb:34-118, spec/models/miq_widget_spec.rb:130-160
Key Data Fields
| Field | Type | Description |
|---|---|---|
content_type | String | Must be one of: report, chart, rss, menu. |
visibility | Hash (Serialized) | Contains arrays of roles or groups that can view the widget. Use _ALL_ for global visibility. |
options | Hash (Serialized) | Configuration like row_count or timezone_matters. |
resource | Polymorphic | Typically points to an MiqReport used as the data source. |
Sources: app/models/miq_widget.rb:21-34, spec/models/miq_widget_spec.rb:25-45
Dashboards (MiqWidgetSet)
Dashboards (internal name MiqWidgetSet) are collections of widgets arranged for a specific user or group. They can be marked as read_only (system-provided) or user-defined.
Unique Constraints and Ownership
Dashboards must have a unique description per group and userid. System-wide dashboards often have a nil userid and serve as defaults. Users can customize these defaults, which creates a user-specific version of the dashboard.
Content Formatting and Charts
Widgets often utilize the reporting formatter classes to render data. For chart-type widgets, the ManageIQ::Reporting::Formatter::ChartCommon module provides the logic for slicing legends and building document bodies for various chart styles.
Supported Chart Types
- Performance Charts: Time-based area or line charts (e.g., Cluster, Host, or VM utilization).
- Utilization Timestamp Charts: Column charts showing metrics like CPU, Memory, and Disk usage grouped by utilization types.
- Reporting Charts: Numeric or value-based charts like Pries, Donuts, or Stacked Columns derived from report data.
Sources: lib/manageiq/reporting/formatter/chart_common.rb:30-45, lib/manageiq/reporting/formatter/chart_common.rb:112-140
Legend and Formatting Logic
The system automatically truncates long legend strings using slice_legend and formats numeric values (like bytes to human-readable sizes) before rendering the final widget content.
# Example of utilization tooltip formatting
tip = case r[0]
when "CPU"
mri.format(tip_key, r[tip_key], :format => {:function => {:name => "mhz_to_human_size"}})
when "Memory"
mri.format(tip_key, r[tip_key].to_f * 1024 * 1024, :format => {:function => {:name => "bytes_to_human_size"}})
end
Sources: lib/manageiq/reporting/formatter/chart_common.rb:7-15, lib/manageiq/reporting/formatter/chart_common.rb:125-135
Security and RBAC
Access to Dashboards and Widgets is controlled through MiqProductFeature. Specific features exist for viewing, adding, removing, and resetting widgets.
- Dashboard View:
dashboard_viewidentifier. - Widget Admin:
miq_report_widget_editorallows adding, copying, deleting, and editing widgets. - Visibility Filter: The
MiqWidget.available_for_usermethod filters widgets by matching the user's role or group against the widget's visibility hash.
Sources: db/fixtures/miq_product_features.yml:450-515, app/models/miq_widget.rb:265-285
Conclusion
The Dashboards and Widgets system is a robust framework for delivering data-driven visualizations. By decoupling content generation (via Reports and Content classes) from the display containers (Widgets and Dashboards), the system allows for flexible, role-based infrastructure monitoring. Integration with the asynchronous queue ensures that complex report-backed widgets do not impact UI responsiveness during data retrieval.