This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Implement a structured logging output system. #5680
Merged
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
4071317
first cut of structured logging
hawkowl 0ea4fb1
remove deprecated options, command line options, and simplify the log…
hawkowl af7bc1c
this should be true
hawkowl 83bf10c
cleanup
hawkowl 9c19dc3
remove disused arguments from workers too
hawkowl c19f2d5
Merge branch 'hawkowl/prune-logging-options' into hawkowl/structured-…
hawkowl 32b9dd0
fix and push up
hawkowl 83507eb
fix
hawkowl 5cec494
update to use 18.9
hawkowl 69cd070
fix sytests?
hawkowl 51048fb
fix sytests?
hawkowl 0b76783
make a misc
hawkowl 9f5d825
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl 47820c5
fix
hawkowl 5260a8b
fix
hawkowl 586fd94
fix
hawkowl 50fcd60
fix
hawkowl 534b15d
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl ae34f25
review comments
hawkowl 34b3fce
review comments
hawkowl ba5b355
use native python read
hawkowl 64c5cdb
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl d1fc0ff
set the log level on the namespace too
hawkowl fa764c6
review comments
hawkowl b19156a
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl 6b4a540
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl 2fbc0e1
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl aafc342
fix
hawkowl cdb8a72
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl 755d7e8
more test
hawkowl fb9b18a
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl 680fdee
fix
hawkowl db1b1b3
tests
hawkowl 92289a7
fix
hawkowl e7c62b5
pass in a proper lang
hawkowl 55391d2
try this to see if it'll go faster
hawkowl b2fa4ad
docs:
hawkowl 9cf3c28
docs
hawkowl 673d380
docs
hawkowl aae792d
more test
hawkowl b50d3a9
more test
hawkowl 03ac5b4
fluentd log to export on console
hawkowl d10b9b8
fix
hawkowl 51b3e81
fix
hawkowl 232064e
cleanups
hawkowl d004e93
style fix
hawkowl 5bbc8e7
docs and typing
hawkowl b611e53
run mypy and check for errors
hawkowl 77f2334
run mypy and check for errors
hawkowl eb3c75d
add it to CI
hawkowl 71d695a
docs
hawkowl 589463f
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl 04f084c
some introductory logs
hawkowl 8697d51
failing test
hawkowl 4477c69
failing test
hawkowl 2684627
Merge remote-tracking branch 'origin/develop' into hawkowl/structured…
hawkowl 9864220
fix the test
hawkowl c400d15
fix the tests
hawkowl 267501a
fix mypy
hawkowl 518e48e
fix old tests
hawkowl 0a0845f
fix old tests
hawkowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Lay the groundwork for structured logging output. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Structured Logging | ||
|
||
A structured logging system can be useful when your logs are destined for a machine to parse and process. By maintaining its machine-readable characteristics, it enables more efficient searching and aggregations when consumed by software such as the "ELK stack". | ||
|
||
Synapse's structured logging system is configured via the file that Synapse's `log_config` config option points to. The file must be YAML and contain `structured: true`. It must contain a list of "drains" (places where logs go to). | ||
|
||
A structured logging configuration looks similar to the following: | ||
|
||
```yaml | ||
structured: true | ||
|
||
loggers: | ||
synapse: | ||
level: INFO | ||
synapse.storage.SQL: | ||
level: WARNING | ||
|
||
drains: | ||
console: | ||
type: console | ||
location: stdout | ||
file: | ||
type: file_json | ||
location: homeserver.log | ||
``` | ||
|
||
The above logging config will set Synapse as 'INFO' logging level by default, with the SQL layer at 'WARNING', and will have two logging drains (to the console and to a file, stored as JSON). | ||
|
||
## Drain Types | ||
|
||
Drain types can be specified by the `type` key. | ||
|
||
### `console` | ||
|
||
Outputs human-readable logs to the console. | ||
|
||
Arguments: | ||
|
||
- `location`: Either `stdout` or `stderr`. | ||
|
||
### `console_json` | ||
|
||
Outputs machine-readable JSON logs to the console. | ||
|
||
Arguments: | ||
|
||
- `location`: Either `stdout` or `stderr`. | ||
|
||
### `console_json_terse` | ||
|
||
Outputs machine-readable JSON logs to the console, separated by newlines. This | ||
format is not designed to be read and re-formatted into human-readable text, but | ||
is optimal for a logging aggregation system. | ||
|
||
Arguments: | ||
|
||
- `location`: Either `stdout` or `stderr`. | ||
|
||
### `file` | ||
|
||
Outputs human-readable logs to a file. | ||
|
||
Arguments: | ||
|
||
- `location`: An absolute path to the file to log to. | ||
|
||
### `file_json` | ||
|
||
Outputs machine-readable logs to a file. | ||
|
||
Arguments: | ||
|
||
- `location`: An absolute path to the file to log to. | ||
|
||
### `network_json_terse` | ||
|
||
Delivers machine-readable JSON logs to a log aggregator over TCP. This is | ||
compatible with LogStash's TCP input with the codec set to `json_lines`. | ||
|
||
Arguments: | ||
|
||
- `host`: Hostname or IP address of the log aggregator. | ||
- `port`: Numerical port to contact on the host. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we log before this? I assume that for some reason we can't set up structured logging before this? I'm mainly worried that we'll end up losing any logging that happens while we create the server and set up the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you are logging to the twisted logging system, they go into the
globalLogBeginner
, which stores logs between init/import of twisted and then outputs them when the logging system starts. if you are logging to the stdlib logger before this, they go into the void(so we should use the twisted logger, so they go somewhere reasonable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting. So if we use the stdlib config we don't get those log lines, but if we use the new structured config we don't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we use the structured config we will, yes