wazuh-qa
wazuh-qa copied to clipboard
Enhance performance statistics module
Description
The developed tool deps/wazuh_testing/wazuh_testing/tools/performance/statistic.py
to retrieve statistics from the Wazuh API has certain improvements that may be needed to avoid misfunctions and errors in the fetched data.
- API Token management The API authentication process is an API process child in charge of managing the authentication requests made to the API that are queued before attending them and returning a response. If any of the requests are delayed, the processing time is carried over to the following requests, making the API susceptible to errors. This happened in a worker of a loaded environment (https://github.com/wazuh/wazuh/issues/21937#issuecomment-1966755209) in which the API received three consecutive calls:
2024/02/23 18:38:58 INFO: wazuh 127.0.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 200.024s: 500
2024/02/23 18:38:58 ERROR: JSON couldn't be loaded
2024/02/23 18:38:58 INFO: wazuh 127.0.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 209.895s: 500
2024/02/23 18:38:58 ERROR: JSON couldn't be loaded
2024/02/23 18:38:58 INFO: wazuh 127.0.0.1 "GET /security/user/authenticate" with parameters {} and body {} done in 205.954s: 500
The process could be enhanced, keeping in mind the time it takes for the JWT token to expire and requesting it only if needed. https://github.com/wazuh/wazuh-qa/blob/6e19ed12bb870316add15193febe0f8b81915afe/deps/wazuh_testing/wazuh_testing/tools/performance/statistic.py#L159-L178
-
Retrieved statistics management and data visualization The tool contains a method to
Write the data collected from the .state into a CSV file.
. It explicitly defines the fields to fetch from the obtained data that should be written in the CSV file and is prone to errors in case a modification from the Core or Framework side is to be done. This must be analyzed so that it is maintainable over time and robust to changes in the origin of the data.The data visualization script suffers a similar caveat, the plots are generated using hardcoded columns and fails if any of their names changes or if the column is no longer present. We should find a way of generating graphics dynamically to prevent the pipeline from failing everytime there is a minimal modification to the statistics files.
Sample artifacts that can be of use to test modifications (these already contain the resulting CSV files in <node>/data/stats/<target>
):
artifacts4.7.3-I.zip artifacts4.7.3-II.zip artifacts4.7.3-III.zip