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

Adding configuration for redirecting journalctl logs to a file #7508

Merged
merged 10 commits into from Nov 7, 2022

Conversation

YashviJain01
Copy link
Collaborator

@YashviJain01 YashviJain01 commented Oct 28, 2022

🔩 Description: What code changed, and why?

After adding the below configuration the logs will be redirecting to /var/log/automate.log

[global.v1.log]
redirect_sys_log = true
redirect_log_file_path = "/var/tmp/"
compress_rotated_logs = true
max_size_rotate_logs = "10M"
max_number_rotated_logs = 2

⛓️ Related Resources

https://chefio.atlassian.net/browse/STALWART-231
https://chefio.atlassian.net/browse/STALWART-232
https://chefio.atlassian.net/browse/STALWART-227

👍 Definition of Done

Whenever users patches this command a file named automate.log will be formed in /var/log/ folder. Which will have logrotate policies enabled.

if redirect_sys_log is set to be true, it will give an error if redirect_log_file_path is not having any value. That is its a required parameter
The default value is as follows for others:

compress_rotated_logs =false
max_size_rotate_logs = "100M"
max_number_rotated_logs = 10

👟 How to Build and Test the Change

rebuild components/automate-deployment/
rebuild components/automate-cli/

Patch the below file :

[global.v1.log]
redirect_sys_log = true
compress_rotated_logs = true
max_size_rotate_logs = "10M"
max_number_rotated_logs = 2

✅ Checklist

All PRs must tick these:

With occasional exceptions, all PRs from Progress employees must tick these:

  • Is the code clear? (complicated code or lots of comments--subdivide and use well-named methods, meaningful variable names, etc.)
  • Consistency checked? (user notifications, user prompts, visual patterns, code patterns, variable names)
  • Repeated code blocks eliminated? (adapt and reuse existing components, blocks, functions, etc.)
  • Spelling, grammar, typos checked? (at a minimum use make spell in any component directory)
  • Code well-formatted? (indents, line breaks, etc. improve rather than hinder readability)

All PRs from Progress employees should tick these if appropriate:

  • Tests added/updated? (all new code needs new tests)
  • Docs added/updated? (all customer-facing changes)

Please add a note next to any checkbox above if you are NOT ticking it.

📷 Screenshots, if applicable

Yashvi Jain added 2 commits October 27, 2022 17:29
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
@netlify
Copy link

netlify bot commented Oct 28, 2022

👷 Deploy Preview for chef-automate processing.

Name Link
🔨 Latest commit 3e5a482
🔍 Latest deploy log https://app.netlify.com/sites/chef-automate/deploys/6368c7c895ab0d000886001b

@YashviJain01 YashviJain01 marked this pull request as draft October 28, 2022 09:54
@YashviJain01 YashviJain01 marked this pull request as ready for review November 2, 2022 06:20
@YashviJain01 YashviJain01 self-assigned this Nov 2, 2022
* cns

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* Logrotate setup

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* Changes

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* PAtch changes

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* PAtch changes

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* Added string conf

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* Ran system command

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* Added changes

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* Final changes

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

* Removing unwanted loggers

Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>

* Adding correct combination for logrotate

Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>

* logrotate

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>

Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
Co-authored-by: Pappu Kumar <pappu.kumar@progress.com>
Co-authored-by: Yashvi Jain <yashvi.jain@progress.com>
@Dmaddu
Copy link
Collaborator

Dmaddu commented Nov 2, 2022

@YashviJain01 @daveaugustus Please record a demo video and attach it to this PR.

Yashvi Jain and others added 3 commits November 3, 2022 10:29
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
Signed-off-by: Pappu Kumar <pappu.kumar@progress.com>
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
@YashviJain01
Copy link
Collaborator Author

SyslogFinal.mov

Yashvi Jain added 2 commits November 4, 2022 16:12
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
api/config/deployment/config_request.go Outdated Show resolved Hide resolved
api/config/deployment/config_request.go Outdated Show resolved Hide resolved
api/config/shared/global.go Outdated Show resolved Hide resolved
api/config/shared/global.go Outdated Show resolved Hide resolved
api/config/shared/global_test.go Outdated Show resolved Hide resolved
Signed-off-by: Yashvi Jain <yashvi.jain@progress.com>
@sonarcloud
Copy link

sonarcloud bot commented Nov 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

14.1% 14.1% Coverage
0.0% 0.0% Duplication

@kalroy kalroy merged commit 999426c into main Nov 7, 2022
@kalroy kalroy deleted the yashvi/STALWART-231 branch November 7, 2022 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants