wazuh / wazuh-dashboard-plugins

Plugins for Wazuh Dashboard
https://wazuh.com/
GNU General Public License v2.0
431 stars 177 forks source link

[Remove discover] Implement embeddable dashboard on Server Management / Cluster module #6532

Closed asteriscos closed 5 months ago

asteriscos commented 6 months ago

Description

We have to implement the embeddable dashboard on Server Management / Cluster and deprecate any use of kibana-integrations components.

[!WARNING]
The embeddable panel id must be unique including general and agents visualizations. Otherwise, the visualizations will not refresh when we pin an agent, because they are cached by id

[!WARNING]
https://github.com/wazuh/wazuh-dashboard-plugins/issues/6549 depends on this task

Current Cluster screens **Screen on cluster mode** ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/ab24c227-c58f-4f13-b583-5122ab982e6e) ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/dff9daaa-a9e8-4b26-b23a-232d4f9f2085) ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/b132fab5-5ac6-45ec-acbf-83ca702ef680) ![image](https://github.com/wazuh/wazuh-dashboard-plugins/assets/43619595/09b969d6-c33f-479b-93fb-5fd4e744eacc)

Tasks

Source task

jbiset commented 6 months ago

Update 20/03/2024

The Server Management -> Cluster screen is different from the rest of the dashboards that are being migrated, since the sections of the screen are inserted with Angular through the management.html template. Therefore, we are analyzing migrating everything possible to React components without affecting other screens, preparing the context when replacing Angular. This is necessary not only for the replacement of the visualizations, but also for the replacement of the searchbar

Files involved:

jbiset commented 6 months ago

Update 21/03/2024

Given the need to componentize the Cluster screen with React components. It was decided to modularize all parts of the Cluster screen in the management.html template and reduce it to a minimum. In this way, not only is any use of kibana-integrations components deprecated, but also partial progress is made with the elimination of Angular.

TO CONTINUE:

jbiset commented 6 months ago

Update 22/03/2024 - 25/03/2024 - 26/03/2024

Work was done on reducing to a minimum everything related to the Cluster screen in management.html.

MIGRATE CLUSTER MODULE TO REACT COMPONENT

BREADCRUMBS ```html
{{ mctrl.tabNames[mctrl.tab] }} / {{ mctrl.currentGroup.name }}
``` It does not affect Cluster as it is only rendered if `mctrl.tab !== 'monitoring' && mctrl.tab !== 'configuration'"`. However, the HOC is added `withGlobalBreadcrumb([{ text: cluster.breadcrumbLabel }])`
CLUSTER DISABLED MESSAGE WHEN NOT AUTHORIZED ```html {/* Cluster disabled or not running */}
``` Replaced with the HOC `withUserAuthorizationPrompt([ { action: 'cluster:status', resource: '*:*:*' }, ])`
CLUSTER DISABLED MESSAGE WHEN NOT ENABLED AND NOT RUNNING CLUSTER ```html {/* Cluster disabled or not running */}
``` It is replaced with the corresponding component and the necessary resources of the cluster controller are migrated.
DISCOVER SEARCH BAR SECTION ```html
{{loadingStatus}}
``` It is replaced by the new searchbar and ng-if is added to the management template so that it is not rendered in the tab monitoring (cluster)
CLUSTER MAIN SECTION ```html
Details 
IP address {{configuration.nodes[0] || '-'}}
Running {{ status || 'no' }}
Version {{version}}
Information
Nodes {{nodesCount}}
Agents {{agentsCount}}
``` The elements are migrated to the new ClusterOverview class component and the necessary resources of the Cluster controller
THE PLACE FROM WHICH CLUSTER OVERVIEW IS RENDERER IS CHANGED Initially, the rendering was carried out through the template `management.html` with the following code: ```html ``` However, to avoid conflicts with other tasks and directly eliminate the use of the `management.html` template, the rendering is passed to the `management-main.js` component like other already migrated components, for example: statistics, logs, configuration, groups.
NODES DETAIL There is a currently unused section that shows the details of a node. The functionality that selects the node does not currently exist, making this section obsolete: ```html

Node {{ currentNode.name }}

{{ currentNode.name }} alerts summary
Node information
IP {{currentNode.healthCheck.info.ip}}
Version {{currentNode.healthCheck.info.version}}
Type {{currentNode.healthCheck.info.type}}
Name {{currentNode.healthCheck.info.name}}
Active agents {{ currentNode.healthCheck.info.n_active_agents }}
Last files integrity synchronization
Last sync {{currentNode.healthCheck.status.last_sync_integrity.date_end_master}}
Duration {{currentNode.healthCheck.status.last_sync_integrity.duration}}
Total shared files {{currentNode.healthCheck.status.last_sync_integrity.total_files.shared}}
Total missing files {{currentNode.healthCheck.status.last_sync_integrity.total_files.missing}}
Total extra but valid files {{currentNode.healthCheck.status.last_sync_integrity.total_files.extra_valid}}
Total extra files {{currentNode.healthCheck.status.last_sync_integrity.total_files.extra}}
Last agents information synchronization
Last sync {{currentNode.healthCheck.status.last_sync_agentinfo.date_end_master}}
Duration {{currentNode.healthCheck.status.last_sync_agentinfo.duration}}
Total agent info {{currentNode.healthCheck.status.last_sync_agentinfo.total_agentinfo}}
Last agents groups synchronization
Last sync {{currentNode.healthCheck.status.last_sync_agentgroups.date_end_master}}
Duration {{currentNode.healthCheck.status.last_sync_agentgroups.duration}}
Total agent info {{currentNode.healthCheck.status.last_sync_agentgroups.total_agentgroups}}
``` For now, since this information view for a selected node has not existed since at least version 4.4.0, it is not migrated. But it is left to consideration to analyze this use case.
ADDED TIMELION VISUALIZATIONS SECTION WITH EMBEDDABLES ```html
``` The `ClusterTimelions` component is added to the `ClusterOverview`, using `DashboardByRenderer`. Replacing the functionality of the previous code.
CONFIGURATION SECTION ```html

Overview

Top 5 nodes There are no results for selected time range. Try another one.
Configuration
Disabled {{configuration.disabled}}
Hidden {{configuration.hidden}}
Name {{configuration.name}}
Node name {{configuration.node_name}}
Node type {{configuration.node_type}}
Bind address {{configuration.bind_addr}}
IP {{configuration.nodes[0] || '-'}}
Port {{configuration.port}}
``` Pass the configuration section to the ClusterOverview class component and then replace the corresponding tags with OpenSearch UI components
jbiset commented 6 months ago

Update 26/03/2024

TO CONTINUE:

Current screen

image

jbiset commented 6 months ago

Update 27/03/2024

Current Server Management -> Cluster

Evidence.webm

The task is blocked until the dependencies are resolved

jbiset commented 6 months ago

Update 08/04/2024

jbiset commented 5 months ago

Update 16/04/2024

jbiset commented 5 months ago

Update 22/04/2024