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

Support log output in json #966

Merged
merged 9 commits into from
Apr 11, 2019
Merged

Support log output in json #966

merged 9 commits into from
Apr 11, 2019

Conversation

lox
Copy link
Contributor

@lox lox commented Mar 31, 2019

This adds a --log-format option to buildkite-agent start that allows for json output for better integration with structured logging systems.

$ buildkite-agent start --debug --log-format=json
{"ts":"2019-03-31T22:51:28+11:00","level":"NOTICE","msg":"Starting buildkite-agent v3.10.2 with PID: 3282"}
{"ts":"2019-03-31T22:51:28+11:00","level":"NOTICE","msg":"The agent source code can be found here: https://github.com/buildkite/agent"}
{"ts":"2019-03-31T22:51:28+11:00","level":"NOTICE","msg":"For questions and support, email us at: [email protected]"}
{"ts":"2019-03-31T22:51:28+11:00","level":"INFO","msg":"Configuration loaded from: /usr/local/etc/buildkite-agent/buildkite-agent.cfg"}
{"ts":"2019-03-31T22:51:28+11:00","level":"DEBUG","msg":"Bootstrap command: buildkite-agent bootstrap"}
{"ts":"2019-03-31T22:51:28+11:00","level":"DEBUG","msg":"Build path: /usr/local/var/buildkite-agent/builds"}
{"ts":"2019-03-31T22:51:28+11:00","level":"DEBUG","msg":"Hooks directory: /usr/local/etc/buildkite-agent/hooks"}
{"ts":"2019-03-31T22:51:28+11:00","level":"DEBUG","msg":"Plugins directory: /usr/local/var/buildkite-agent/plugins"}
{"ts":"2019-03-31T22:51:28+11:00","level":"INFO","msg":"Registering agent with Buildkite..."}
{"ts":"2019-03-31T22:51:28+11:00","level":"DEBUG","msg":"POST https://agent.buildkite.com/v3/register"}

This lays the groundwork for structured field logging too, although the only field currently implemented is the agent name.

@lox lox requested a review from a team April 2, 2019 04:28
@lox lox force-pushed the log-format-json branch from f738650 to b7caf04 Compare April 2, 2019 04:33
@lox
Copy link
Contributor Author

lox commented Apr 2, 2019

This is what things look like for normal console logging:

image

This is what json logging looks like:

image

@lox lox force-pushed the log-format-json branch from b7caf04 to aa96bb6 Compare April 11, 2019 22:48
@lox lox merged commit 7847fd8 into master Apr 11, 2019
@lox lox deleted the log-format-json branch April 11, 2019 23:03
@lox lox mentioned this pull request Apr 20, 2019
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