Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistency in the non-core visualizations and agent status #4166

Merged
merged 6 commits into from
Jun 2, 2022

Conversation

Desvelao
Copy link
Member

@Desvelao Desvelao commented May 25, 2022

Description

This PR adds some enhancements in the consistency of non-core visualizations and agent status.

Changes

  • Consistency in custom donut visualizations:
  • Replaced the visualizations in Agents and Modules/SCA/Inventory by the VisualizationBasic component
  • Removed the Pie component
  • Consistency in agent status, labels, and colors:
  • Centralized the agent status, labels, and colors to constants.ts file
  • Replaced the hardcoded values with the centralized ones
  • Added the pending status to:
    • Agents stats in Modules directory
    • Status visualization in Agents section
    • Details panel in Agents section
    • Agents stats in Management/Status
  • Created a service to get the color and label depending on the agent
    status. It is shared by the backend and frontend.
  • Created a component to display the agent status: AgentStatus.
    It is adapted to the different use cases.
    • Replaced the old rendering with the new one in some components. Removed unnecessary methods and layout.
  • Removed deprecated methods and files
    • Rendering agent status stats when the monitoring job was disabled
      and the visualization of agent status evolution was in Modules/Security events. WzVisualize component.
      • Removed an API request to get the agent status data
  • Refactored the API request managing in:
    • Modules/SCA/Inventory
    • Agents
    • Management/Status
  • Added a new property error to VisualizationBasic to render the
    error message coming from error.message
  • Fixed an error when creating a visualization that didn't apply the
    definitions in uiStateJSON property. This is due to a bug in Kibana 7.10.2
  • Fixed some typos

Screenshots

  • Agents
    image
  • Modules/SCA
    image
  • Modules directory
    image
  • Management/Status
    image
  • Agent selector
    image
  • Group's agent
    image

Test

  • Agents:
    • Status visualization:
      • Click on the legend's labels adding a filter to the search bar
      • Include the Pending status
    • Details panels:
      • Click on the agent status stat adding a filter to the search bar
      • Include the Pending status
    • Evolution visualization:
      • status colors are equals to the other panels
    • Search bar
      • status suggestion includes pending status
  • Agent selector
    • status suggestion includes pending status
    • Status colum displays the status indicator and the label.
    • If there is a selected agent, it displays the status indicator and the agent name (id) as a label.
  • Management/Groups/
    • Search bar:
      • status suggestion includes pending status
  • Modules directory
    • Display the agent count by status including pending state
  • Management/Status
    • Display the agent count by status including pending state
    • Display the agent status using the labels.
    • The agent count should display as expected when loading the first time or change the manager using the manager node selector for a cluster mode
  • Reviewing the files changed, access to the sections, and using an agent with status same of change, see that is working as expected.
    • Modules/File integrity monitoring/Inventory
      • active: display the data
      • not active: display a prompt related to the agent status
    • Modules/SCA/Inventory
      • never_connected: prompt with a message related to the agent status
      • not never_connected: display the data
    • Agent/Stats:
      • active: display the data
      • not active: display a prompt related to the agent status
    • Agent/Inventory
      • active: display the data
      • disconnected: display a prompt related to the agent status
      • never_connected: display a prompt related to the agent status
    • Agent/Overview:
      • never_connected: display a prompt related to the agent status
      • no never_connected: display the data
    • Agents
      • Table
        • not never_connected: not display the button to open the agent configuration
        • Status column is rendered with an indicator that depends on the agent status and a label without _ character
          • For window width < 1200, only display the indicator and no the status label
    • Agent/Configuration
      • active: display the section
      • never_connected: display a prompt related to the agent status
    • <Module> - Generate a report in PDF
      • not active: display a message with the current state of the agent.
  • The order of agent status are: active, disconnected, pending, never_connected

Closes #4077

@Desvelao Desvelao self-assigned this May 25, 2022
@Desvelao Desvelao added the type/enhancement Enhancement issue label May 25, 2022
@Desvelao Desvelao linked an issue May 25, 2022 that may be closed by this pull request
…bels and colors

- Consistency in custom donut visualizations:
 - Replaced the visualizations in `Agents` and `Modules/SCA/Inventory` by the `VisualizationBasic` component
 - Removed the `Pie` component
- Consistency in agent status, labels, and colors:
 - Centralized the agent status, labels, and colors to constants.ts file
 - Replaced the hardcoded values with the centralized ones
 - Added the `pending` status to:
   - Agents stats in Modules directory
   - Status visualization in `Agents` section
   - Details panel in `Agents` section
   - Agents stats in Management/Status
- Created a service to get the color and label depending on the agent
  status. It is shared by the backend and frontend.
- Created a component to display the agent status: AgentStatus.
  It is adapted to the different use cases.
  - Replaced the old rendering with the new one in some components. Removed unnecessary methods and layout.
- Removed deprecated methods and files
  - Rendering agent status stats when the monitoring job was disabled
    and the visualization of agent status evolution was in Modules/Security events. `WzVisualize` component.
    - Removed an API request to get the agent status data
- Refactored the API request managing in:
  - `Modules/SCA/Inventory`
  - `Agents`
  - `Management/Status`
- Added a new property `error` to `VisualizationBasic` to render the
  error message coming from `error.message`
- Fixed an error when creating a visualization that didn't apply the
  definitions in `uiStateJSON` property. This is due to a bug in Kibana 7.10.2
- Fixed some typos
@Desvelao Desvelao force-pushed the feat/4077-consistency-charts-agent-status branch from 0b68a75 to 7ab242e Compare May 25, 2022 12:54
@Mayons95
Copy link
Contributor

Testing in progress

@Mayons95
Copy link
Contributor

Mayons95 commented May 27, 2022

Test OK
Screenshot from 2022-05-27 09-43-14
Screenshot from 2022-05-27 09-44-41
Screenshot from 2022-05-27 09-45-44

@Mayons95 Mayons95 self-requested a review May 27, 2022 12:47
@AlexRuiz7
Copy link
Member

AlexRuiz7 commented Jun 1, 2022

Test

  • Agents:
    • Status visualization:
      • Click on the legend's labels, adding a filter to the search bar
      • Include the Pending status
    • Details panels:
      • Click on the agent status stat, adding a filter to the search bar
      • Include the Pending status
    • Evolution visualization:
      • status colors are equals to the other panels
    • Search bar
      • status suggestion includes pending status
  • Agent selector
    • status suggestion includes pending status
    • Status column displays the status indicator and the label.
    • If there is a selected agent, it displays the status indicator and the agent name (ID) as a label.
  • Management/Groups/
    • Search bar:
      • status suggestion includes pending status
  • Modules directory
    • Display the agent count by status, including pending state
  • Management/Status
    • Display the agent count by status, including pending state
    • Display the agent status using the labels.
    • The agent count should display as expected when loading the first time or change the manager using the manager node selector for a cluster mode
  • Reviewing the files changed, access to the sections, and using an agent with status same of change, see that is working as expected.
    • Modules/File integrity monitoring/Inventory
      • active: display the data
      • not active: display a prompt related to the agent status
    • Modules/SCA/Inventory
      • never_connected: prompt with a message related to the agent status
      • not never_connected: display the data
    • Agent/Stats:
      • active: display the data
      • not active: display a prompt related to the agent status
    • Agent/Inventory
      • active: display the data
      • disconnected: display a prompt related to the agent status
      • never_connected: display a prompt related to the agent status
    • Agent/Overview:
      • never_connected: display a prompt related to the agent status
      • no never_connected: display the data
    • Agents
      • Table
        • not never_connected: not display the button to open the agent configuration
        • Status column is rendered with an indicator that depends on the agent status and a label without _ character
          • For window width < 1200, only display the indicator and on the status label
    • Agent/Configuration
      • active: display the section
      • never_connected: display a prompt related to the agent status
    • <Module> - Generate a report in PDF
      • not active: display a message with the current state of the agent.
  • The order of agent status are: active, disconnected, pending, never_connected

Copy link
Member

@AlexRuiz7 AlexRuiz7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Test: ✔️
  • Code Review: ✔️*

*Left some feedback. Check the comments.

@@ -0,0 +1,11 @@
import { UI_COLOR_AGENT_STATUS, UI_LABEL_NAME_AGENT_STATUS } from '../constants';

type AgentStatus = 'active' | 'disconected' | 'pending' | 'never_connected';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated values from API_NAME_AGENT_STATUS.

Couldn't it be used instead??

import { API_NAME_AGENT_STATUS } from '../constants';

type AgentStatus = API_NAME_AGENT_STATUS

Or even better, use enums: https://www.typescriptlang.org/docs/handbook/enums.html#string-enums

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will see if I can redefine this type to avoid the hardcoded values and use the constant.

Comment on lines +1 to +16
import React from 'react';
import { EuiToolTip } from '@elastic/eui';
import { agentStatusColorByAgentStatus, agentStatusLabelByAgentStatus } from '../../../common/services/wz_agent_status';

export const AgentStatus = ({ status, children = null, labelProps = {}, style = {} }) => (
<span className="euiFlexGroup euiFlexGroup--gutterExtraSmall euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow" style={style}>
<EuiToolTip position="top" content={agentStatusLabelByAgentStatus(status).toLowerCase()}>
<span className="euiFlexItem euiFlexItem--flexGrowZero">
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" className={`euiIcon euiIcon--medium`} style={{ color: agentStatusColorByAgentStatus(status) }} focusable="false" role="img" aria-hidden="true">
<circle cx="8" cy="8" r="4"></circle>
</svg>
</span>
</EuiToolTip>
<span className="euiFlexItem euiFlexItem--flexGrowZero" {...labelProps}>{children || agentStatusLabelByAgentStatus(status).toLowerCase()}</span>
</span>
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run formatter


export class Inventory extends Component {
_isMount = false;
constructor(props) {
super(props);
const { agent } = this.props;
this.state = { agent, items: [], itemIdToExpandedRowMap: {}, showMoreInfo: false, loading: false, filters: [], pageTableChecks: {pageIndex: 0} }
this.policies = [];
this.state = { agent, items: [], itemIdToExpandedRowMap: {}, showMoreInfo: false, loading: false, filters: [], pageTableChecks: {pageIndex: 0}, policies: [] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatter here

@@ -96,7 +98,7 @@ export default [
],
}),
uiStateJSON: JSON.stringify({
vis: { colors: { never_connected: '#447EBC', active: '#E5AC0E' } },
vis: { colors: { active: UI_COLOR_AGENT_STATUS.active, disconnected: UI_COLOR_AGENT_STATUS.disconnected, pending: UI_COLOR_AGENT_STATUS.pending, never_connected: UI_COLOR_AGENT_STATUS.never_connected } },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format

@@ -96,7 +98,7 @@ export default [
],
}),
uiStateJSON: JSON.stringify({
vis: { colors: { never_connected: '#447EBC', active: '#E5AC0E' } },
vis: { colors: { active: UI_COLOR_AGENT_STATUS.active, disconnected: UI_COLOR_AGENT_STATUS.disconnected, pending: UI_COLOR_AGENT_STATUS.pending, never_connected: UI_COLOR_AGENT_STATUS.never_connected } },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format

Copy link
Member

@yenienserrano yenienserrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test: ✔️
CR: ✔️

…into feat/4077-consistency-charts-agent-status
@Desvelao Desvelao merged commit cacf792 into 4.3-7.10 Jun 2, 2022
@Desvelao Desvelao deleted the feat/4077-consistency-charts-agent-status branch June 2, 2022 09:51
@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

The backport to 4.3-7.16 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.3-7.16 4.3-7.16
# Navigate to the new working tree
cd .worktrees/backport-4.3-7.16
# Create a new branch
git switch --create backport-4166-to-4.3-7.16
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 cacf7923c8ed33cc6397b6f1c28a3ee2ed3fe66b
# Push it to GitHub
git push --set-upstream origin backport-4166-to-4.3-7.16
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.3-7.16

Then, create a pull request where the base branch is 4.3-7.16 and the compare/head branch is backport-4166-to-4.3-7.16.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

The backport to 4.3-1.2-wzd failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.3-1.2-wzd 4.3-1.2-wzd
# Navigate to the new working tree
cd .worktrees/backport-4.3-1.2-wzd
# Create a new branch
git switch --create backport-4166-to-4.3-1.2-wzd
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 cacf7923c8ed33cc6397b6f1c28a3ee2ed3fe66b
# Push it to GitHub
git push --set-upstream origin backport-4166-to-4.3-1.2-wzd
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.3-1.2-wzd

Then, create a pull request where the base branch is 4.3-1.2-wzd and the compare/head branch is backport-4166-to-4.3-1.2-wzd.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

The backport to cloud/4.3-7.10 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-cloud/4.3-7.10 cloud/4.3-7.10
# Navigate to the new working tree
cd .worktrees/backport-cloud/4.3-7.10
# Create a new branch
git switch --create backport-4166-to-cloud/4.3-7.10
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 cacf7923c8ed33cc6397b6f1c28a3ee2ed3fe66b
# Push it to GitHub
git push --set-upstream origin backport-4166-to-cloud/4.3-7.10
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-cloud/4.3-7.10

Then, create a pull request where the base branch is cloud/4.3-7.10 and the compare/head branch is backport-4166-to-cloud/4.3-7.10.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

The backport to cloud/4.3-7.10-custom-agents-view failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-cloud/4.3-7.10-custom-agents-view cloud/4.3-7.10-custom-agents-view
# Navigate to the new working tree
cd .worktrees/backport-cloud/4.3-7.10-custom-agents-view
# Create a new branch
git switch --create backport-4166-to-cloud/4.3-7.10-custom-agents-view
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 cacf7923c8ed33cc6397b6f1c28a3ee2ed3fe66b
# Push it to GitHub
git push --set-upstream origin backport-4166-to-cloud/4.3-7.10-custom-agents-view
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-cloud/4.3-7.10-custom-agents-view

Then, create a pull request where the base branch is cloud/4.3-7.10-custom-agents-view and the compare/head branch is backport-4166-to-cloud/4.3-7.10-custom-agents-view.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

Jest Test Coverage % values
Statements 4.09% ( 1489 / 36372 )
Branches 1.68% ( 473 / 28235 )
Functions 3.06% ( 272 / 8898 )
Lines 4.14% ( 1440 / 34790 )

@snaow snaow changed the title [Enhancement] Consistency in the non-core visualizations and agent status Consistency in the non-core visualizations and agent status Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Enhancement issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improvement of agent charts
4 participants