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

Replace the plugin logging system by the provided by the platform #6161

Merged
merged 21 commits into from
Dec 27, 2023

Conversation

Desvelao
Copy link
Member

@Desvelao Desvelao commented Nov 28, 2023

Description

This pull request replaces the custom logging service with the one provided by the platform.

Changes:

  • Add the wazuhCore plugin as dependency of main
  • Remove the logs.level setting
  • Replace the custom logging service with the one provided by the platform
    • Remove BaseLogger, log and uiLogger services
    • Create scoped server platform loggers with tags
    • Remove unused winston dependency used by the custom logger
      • yarn.lock files were updated
  • Move some services from the main to the core plugin, adapt its usage, and replace the logging service
    • CacheAPIUserAllowRunAs
    • ManageHosts
    • ServerAPIClient (aka api-interceptor)
    • ServerAPIHostEntries (aka manage-hosts)
    • UpdateConfigurationFile
    • UpdateRegistry
    • dashboardSecurity (aka SecurityObj)
  • Added some logs to server side
  • Remove constants that define the path to log files
  • Remove App logs application
  • Remove API endpoint
    • GET /utils/logs/ui (unused by the frontend side)
    • GET /utils/logs
  • Remove unused code
  • Replace the usage of endpoint controllers to get data in the statistics and monitoring by core services

Issues Resolved

#6137

Evidence

Logs starting the platform:

server    log   [10:16:58.708] [info][initialize][plugins][wazuh] Wazuh dashboard index: .kibana
server    log   [10:16:58.708] [info][initialize][plugins][wazuh] App revision: 00
server    log   [10:16:58.714] [info][initialize][plugins][wazuh] Total RAM: 15922MB
server    log   [10:17:00.310] [info][initialize][plugins][wazuh] Configuration registry saved.
server    log   [10:17:00.358] [error][data][opensearch] [ResponseError]: Response Error
server    log   [10:17:00.360] [error][data][opensearch] [ResponseError]: Response Error
server    log   [10:17:00.469] [info][monitoring][plugins][wazuh] Updated the wazuh-agent template
server    log   [10:17:00.594] [info][listening] Server running at https://0.0.0.0:5601
server    log   [10:17:00.745] [info][cron-scheduler][plugins][wazuh] Updated the wazuh-statistics template
server    log   [10:17:00.763] [info][server][OpenSearchDashboards][http] http server running at https://0.0.0.0:5601
server    log   [10:17:00.777] [error][monitoring][plugins][wazuh] getaddrinfo ENOTFOUND wazuh.manager
server    log   [10:17:06.430] [info][monitoring][plugins][wazuh] wazuh-monitoring-2023.48w index created
server    log   [10:17:06.441] [info][monitoring][plugins][wazuh] Settings added to wazuh-monitoring-2023.48w index
server    log   [10:17:06.751] [info][monitoring][plugins][wazuh] Bulk data to index wazuh-monitoring-2023.48w for 7 agents completed
server    log   [10:17:06.753] [error][monitoring][plugins][wazuh] Invalid URL

Test

Legend:
⚫: none
🟢: pass
🟡: warning
🔴: fail
⚪: not applicable

UI

Test Chrome Firefox Safari
The logs.level setting should not appear in the App settings application
The App logs application should not appear in the side bar menu

Details

⚫ The logs.level setting should not appear in the App settings application

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

⚫ The App logs application should not appear in the side bar menu

Chrome - ⚫

Firefox - ⚫

Safari - ⚫

Backend

Test Result
The default wazuh.yml should not contain the logs.level setting
Logs of monitoring task should use the platform logging
Logs of statistics task should use the platform logging
Logs of initialize task should use the platform logging
Logs of queue task should use the platform logging
Logs of migration task should use the platform logging
Logs of check updates plugin should use the platform logging
Logs of core plugin should use the platform logging

Details

⚫ The default wazuh.yml should not contain the logs.level setting
⚫ Logs of monitoring task should use the platform logging
⚫ Logs of statistics task should use the platform logging
⚫ Logs of initialize task should use the platform logging
⚫ Logs of queue task should use the platform logging
⚫ Logs of migration task should use the platform logging
⚫ Logs of check updates plugin should use the platform logging
⚫ Logs of core plugin should use the platform logging

Check List

  • All tests pass
    • yarn test:jest
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

- Enhance the logging messages
- Minor enhancements
- Replace the logging services
- Move services to core plugin
  - CacheAPIUserAllowRunAs
  - ManageHosts
  - ServerAPIClient (aka api-interceptor)
  - ServerAPIHostEntries (aka )
  - UpdateConfigurationFile
  - UpdateRegistry
- Adapt the usage of services in the main and check updates plugin from
  core plugin
- Remove plugin logger from main and core plugins
- Remove API endpoint
  - GET /utils/logs/ui
- Remove unused code
- Adapt the test suites
@Desvelao Desvelao self-assigned this Nov 28, 2023
@Desvelao Desvelao linked an issue Nov 28, 2023 that may be closed by this pull request
19 tasks
@Desvelao Desvelao marked this pull request as ready for review December 11, 2023 12:58
@Desvelao Desvelao requested a review from a team as a code owner December 11, 2023 12:58
@JuanGarriuz
Copy link
Member

JuanGarriuz commented Dec 18, 2023

Logs starting app

image

Test

Legend:
⚫: none
🟢: pass
🟡: warning
🔴: fail
⚪: not applicable

UI

Test Chrome Firefox Safari
The logs.level setting should not appear in the App settings application 🟢
The App logs application should not appear in the side bar menu 🟢

Details

🟢 The logs.level setting should not appear in the App settings application

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

🟢 The App logs application should not appear in the side bar menu

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

Backend

Test Result
The default wazuh.yml should not contain the logs.level setting 🟢
Logs of monitoring task should use the platform logging 🟢
Logs of statistics task should use the platform logging 🟢
Logs of initialize task should use the platform logging 🟢
Logs of queue task should use the platform logging 🟢
Logs of migration task should use the platform logging 🟢
Logs of check updates plugin should use the platform logging 🟢
Logs of core plugin should use the platform logging 🟢

Details

🟢 The default wazuh.yml should not contain the logs.level setting

image

🟢 Logs of monitoring task should use the platform logging

image

🟢Logs of statistics task should use the platform logging

image

🟢 Logs of initialize task should use the platform logging

image

🟢 Logs of queue task should use the platform logging

image

🟢 Logs of migration task should use the platform logging

image

image

🟢 Logs of check updates plugin should use the platform logging

image

image

🟢 Logs of core plugin should use the platform logging

image

Copy link
Member

@JuanGarriuz JuanGarriuz left a comment

Choose a reason for hiding this comment

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

LGTM!!

Copy link
Contributor

Wazuh Core plugin code coverage (Jest) test % values
Statements 22.02% ( 176 / 799 )
Branches 19.55% ( 79 / 404 )
Functions 14.63% ( 36 / 246 )
Lines 22.23% ( 173 / 778 )

Copy link
Contributor

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 76.33% ( 171 / 224 )
Branches 57.57% ( 57 / 99 )
Functions 61.7% ( 29 / 47 )
Lines 76.33% ( 171 / 224 )

@yenienserrano
Copy link
Member

yenienserrano commented Dec 26, 2023

Test

Legend:
⚫: none
🟢: pass
🟡: warning
🔴: fail
⚪: not applicable

UI

Test Chrome Firefox Safari
The logs.level setting should not appear in the App settings application 🟢
The App logs application should not appear in the side bar menu 🟢

Details

🟢 The logs.level setting should not appear in the App settings application

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

🟢 The App logs application should not appear in the side bar menu

Chrome - 🟢

image

Firefox - ⚫

Safari - ⚫

Backend

Test Result
The default wazuh.yml should not contain the logs.level setting 🟢
Logs of monitoring task should use the platform logging 🟢
Logs of statistics task should use the platform logging
Logs of initialize task should use the platform logging 🟢
Logs of queue task should use the platform logging
Logs of migration task should use the platform logging
Logs of check updates plugin should use the platform logging
Logs of core plugin should use the platform logging

Details

🟢 The default wazuh.yml should not contain the logs.level setting

image

🟢 Logs of monitoring task should use the platform logging

image

⚫ Logs of statistics task should use the platform logging
🟢 Logs of initialize task should use the platform logging

image

⚫ Logs of queue task should use the platform logging
⚫ Logs of migration task should use the platform logging
⚫ Logs of check updates plugin should use the platform logging
⚫ Logs of core plugin should use the platform logging

Copy link
Contributor

Main plugin code coverage (Jest) test % values
Statements 11.3% ( 3897 / 34473 )
Branches 7.51% ( 1714 / 22815 )
Functions 10.9% ( 898 / 8232 )
Lines 11.48% ( 3788 / 32993 )

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.

LGTM

@asteriscos asteriscos merged commit ff561c5 into master Dec 27, 2023
4 checks passed
@asteriscos asteriscos deleted the enhancement/6137-adapt-logging-method branch December 27, 2023 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt the logging method of the plugins to the provided by the platform
4 participants