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

Improve logging for startup scripts on linux #1230

Merged

Conversation

triarius
Copy link
Contributor

@triarius triarius commented Oct 2, 2023

Prior to this PR, the startup scripts had tracing enabled (set -x) which made them difficult to read. This PR disables tracing and adds manual logging to the startup scripts.

I've tried to log before performing an action, and log if it fails. If a file is written to, I also try to log what was written. If you compare the output of these logs (the cloudwatch log group /buildkite/elastic-stack/<instance-id>) before an after this PR, the after has more information and is easier to follow (IMO).

Screenshots

Before

2023-10-02T22:30:17,887170592+11:00

After

2023-10-02T22:27:33,246787488+11:00

I've also removed some use of >&2, see e8184d8.

@triarius triarius force-pushed the pdp-1587-clearer-logs-in-buildkiteelastic-stack-log-group branch from fd394a8 to ff9c649 Compare October 2, 2023 09:21
The command that sends the scripts output streams to the loggers merges
stdout and stderr anyway, so there is no point in writing to stderr in
the script.

This is the logging command:
```
exec > >(tee -a /var/log/elastic-stack.log | logger -t user-data -s 2>/dev/console) 2>&1
```
it is present in each of these scripts.
@triarius triarius force-pushed the pdp-1587-clearer-logs-in-buildkiteelastic-stack-log-group branch from ff9c649 to e8184d8 Compare October 2, 2023 09:35
@triarius triarius requested a review from a team October 2, 2023 11:40
Copy link
Contributor

@moskyb moskyb left a comment

Choose a reason for hiding this comment

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

this is way better!

@triarius triarius merged commit d21ab45 into main Oct 4, 2023
1 check passed
@triarius triarius deleted the pdp-1587-clearer-logs-in-buildkiteelastic-stack-log-group branch October 4, 2023 00:04
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.

2 participants