Skip to content

Commit

Permalink
Merge branch '4.8.1' into enhancement/5509-remove-hardcoded-branch-re…
Browse files Browse the repository at this point in the history
…ferences
  • Loading branch information
santipadilla committed Jun 26, 2024
2 parents b90480c + 8bf979f commit fdd09d0
Show file tree
Hide file tree
Showing 5 changed files with 577 additions and 187 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ All notable changes to this project will be documented in this file.

## [4.8.1] - TBD

### Added

- Added the capability to plot indexed alerts and vulnerabilities. ([#5518](https://github.com/wazuh/wazuh-qa/pull/5518)) \- (Framework)
- Add functionality to unify data of the binary processes with their subprocesses to plot ([#5500](https://github.com/wazuh/wazuh-qa/pull/5500)) \- (Framework)

### Changed

- Remove hardcode reference to branch in provision playbook for E2E tests ([#5509](https://github.com/wazuh/wazuh-qa/issues/5509)) \- (Tests)
- Fix test_consistency_initial_scans by adding a 30-minute wait before collecting vulnerabilities. ([#5507](https://github.com/wazuh/wazuh-qa/pull/5507)) \- (Tests)

## [4.8.0] - 12/06/2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
]
},
"alerts_info": {
"title": "Alerts and events info.",
"title": "Alerts and events info",
"columns": [
"Events processed", "Events received", "Written alerts", "Written firewall", "Written fts"
"Events processed", "Events received", "Written alerts", "Written firewall", "Written fts",
"Written archives", "Written stats"
]
}
}
63 changes: 54 additions & 9 deletions deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,81 @@
from os.path import exists
from tempfile import gettempdir

from wazuh_testing.tools.performance.visualization import DataVisualizer
from wazuh_testing.tools.performance.visualization import (
BinaryDatavisualizer,
ClusterStatisticsVisualizer,
DaemonStatisticsVisualizer,
IndexerAlerts,
IndexerVulnerabilities,
LogcollectorStatisticsVisualizer,
)

supported_targets = ['binary', 'analysis', 'remote', 'wazuhdb', 'logcollector',
'cluster', 'indexer-alerts',
'indexer-vulnerabilities']
daemon_supported_statistics = ['analysis', 'remote', 'wazuhdb']
strategy_plot_by_target = {
'binary': BinaryDatavisualizer,
'daemon-statistics': DaemonStatisticsVisualizer,
'cluster': ClusterStatisticsVisualizer,
'logcollector': LogcollectorStatisticsVisualizer,
'indexer-alerts': IndexerAlerts,
'indexer-vulnerabilities': IndexerVulnerabilities
}


def create_destination_directory(destination_directory):
if not exists(destination_directory):
makedirs(destination_directory)


def validate_arguments(options):
if options.visualization_target != 'binary' and options.unify:
raise ValueError('Unify option is not allowed for non binary data plotting')


def get_script_arguments():
parser = argparse.ArgumentParser(usage="%(prog)s [options]", description="Script to generate data visualizations",
parser = argparse.ArgumentParser(usage='%(prog)s [options]', description='Script to generate data visualizations',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-s', '--sources', dest='csv_list', required=True, type=str, nargs='+', action='store',
help='Paths to the CSV files separated by whitespace.')
parser.add_argument('-t', '--target', dest='visualization_target', default='binary',
choices=['binary', 'analysis', 'remote', 'agent', 'logcollector', 'cluster', 'api', 'wazuhdb'],
choices=supported_targets,
help='Generate data visualizations for a specific target. Default binary.')
parser.add_argument('-d', '--destination', dest='destination', default=gettempdir(),
help=f'Directory to store the images. Default {gettempdir()}')
parser.add_argument('-n', '--name', dest='name', default=None,
help=f'Base name for the images. Default {None}.')
parser.add_argument('-c', '--columns', dest='columns', default=None,
help=f'Path to Json with Columns to Plot. Default {None}.')
parser.add_argument('-u', '--unify', dest='unify', action='store_true',
help='Unify data of the binary processes with their subprocesses to plot.')

return parser.parse_args()


def main():
options = get_script_arguments()
destination = options.destination
create_destination_directory(options.destination)

target = options.visualization_target
validate_arguments(options)

visualization_options = {
'dataframes': options.csv_list,
'store_path': options.destination,
'base_name': options.name
}

strategy = target
if target in daemon_supported_statistics:
visualization_options['daemon'] = target
strategy = 'daemon-statistics'
elif target == 'binary':
visualization_options['unify_child_daemon_metrics'] = options.unify

dv = strategy_plot_by_target[strategy](**visualization_options)

if not exists(destination):
makedirs(destination)
dv = DataVisualizer(dataframes=options.csv_list, target=options.visualization_target,
compare=False, store_path=options.destination, base_name=options.name,
columns_path=options.columns)
dv.plot()


Expand Down
Loading

0 comments on commit fdd09d0

Please sign in to comment.