Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
1958f9de
Unverified
Commit
1958f9de
authored
2 years ago
by
David Robertson
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
lnav config for synpase logs (#14953)
parent
73403d5e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/14953.misc
+1
-0
1 addition, 0 deletions
changelog.d/14953.misc
contrib/lnav/README.md
+47
-0
47 additions, 0 deletions
contrib/lnav/README.md
contrib/lnav/synapse-log-format.json
+67
-0
67 additions, 0 deletions
contrib/lnav/synapse-log-format.json
with
115 additions
and
0 deletions
changelog.d/14953.misc
0 → 100644
+
1
−
0
View file @
1958f9de
Add an [lnav](https://lnav.org) config file for Synapse logs to `/contrib/lnav`.
This diff is collapsed.
Click to expand it.
contrib/lnav/README.md
0 → 100644
+
47
−
0
View file @
1958f9de
# `lnav` config for Synapse logs
[
lnav
](
https://lnav.org/
)
is a log-viewing tool. It is particularly useful when
you need to interleave multiple log files, or for exploring a large log file
with regex filters. The downside is that it is not as ubiquitous as tools like
`less`
,
`grep`
, etc.
This directory contains an
`lnav`
[
log format definition
](
https://docs.lnav.org/en/v0.10.1/formats.html#defining-a-new-format
)
for Synapse logs as
emitted by Synapse with the default
[
logging configuration
](
https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#log_config
)
. It supports lnav 0.10.1 because that's what's packaged by my distribution.
This should allow lnav:
-
to interpret timestamps, allowing log interleaving;
-
to interpret log severity levels, allowing colouring by log level(!!!);
-
to interpret request IDs, allowing you to skip through a specific request; and
-
to highlight room, event and user IDs in logs.
See also https://gist.github.com/benje/e2ab750b0a81d11920d83af637d289f7 for a
similar example.
## Example
[

](https://asciinema.org/a/556133)
## Tips
-
`lnav -i /path/to/synapse/checkout/contrib/lnav/synapse-log-format.json`
-
`lnav my_synapse_log_file`
or
`lnav synapse_log_files.*`
, etc.
-
`lnav --help`
for CLI help.
Within lnav itself:
-
`?`
for help within lnav itself.
-
`q`
to quit.
-
`/`
to search a-la
`less`
and
`vim`
, then
`n`
and
`N`
to continue searching
down and up.
-
Use
`o`
and
`O`
to skip through logs based on the request ID (
`POST-1234`
, or
else the value of the
[
`request_id_header`
](
https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html?highlight=request_id_header#listeners
)
header). This may get confused if the same request ID is repeated among
multiple files or process restarts.
-
???
-
Profit
This diff is collapsed.
Click to expand it.
contrib/lnav/synapse-log-format.json
0 → 100644
+
67
−
0
View file @
1958f9de
{
"$schema"
:
"https://lnav.org/schemas/format-v1.schema.json"
,
"synapse"
:
{
"title"
:
"Synapse logs"
,
"description"
:
"Logs output by Synapse, a Matrix homesever, under its default logging config."
,
"regex"
:
{
"log"
:
{
"pattern"
:
".*(?<timestamp>
\\
d{4}-
\\
d{2}-
\\
d{2}
\\
d{2}:
\\
d{2}:
\\
d{2},
\\
d{3}) - (?<logger>.+) - (?<lineno>
\\
d+) - (?<level>
\\
w+) - (?<context>.+) - (?<body>.*)"
}
},
"json"
:
false
,
"timestamp-field"
:
"timestamp"
,
"timestamp-format"
:
[
"%Y-%m-%d %H:%M:%S,%L"
],
"level-field"
:
"level"
,
"body-field"
:
"body"
,
"opid-field"
:
"context"
,
"level"
:
{
"critical"
:
"CRITICAL"
,
"error"
:
"ERROR"
,
"warning"
:
"WARNING"
,
"info"
:
"INFO"
,
"debug"
:
"DEBUG"
},
"sample"
:
[
{
"line"
:
"my-matrix-server-generic-worker-4 | 2023-01-27 09:47:09,818 - synapse.replication.tcp.client - 381 - ERROR - PUT-32992 - Timed out waiting for stream receipts"
,
"level"
:
"error"
},
{
"line"
:
"my-matrix-server-federation-sender-1 | 2023-01-25 20:56:20,995 - synapse.http.matrixfederationclient - 709 - WARNING - federation_transaction_transmission_loop-3 - {PUT-O-3} [example.com] Request failed: PUT matrix://example.com/_matrix/federation/v1/send/1674680155797: HttpResponseException('403: Forbidden')"
,
"level"
:
"warning"
},
{
"line"
:
"my-matrix-server | 2023-01-25 20:55:54,433 - synapse.storage.databases - 66 - INFO - main - [database config 'master']: Checking database server"
,
"level"
:
"info"
},
{
"line"
:
"my-matrix-server | 2023-01-26 15:08:40,447 - synapse.access.http.8008 - 460 - INFO - PUT-74929 - 0.0.0.0 - 8008 - {@alice:example.com} Processed request: 0.011sec/0.000sec (0.000sec, 0.000sec) (0.001sec/0.008sec/3) 2B 200
\"
PUT /_matrix/client/r0/user/%40alice%3Atexample.com/account_data/im.vector.setting.breadcrumbs HTTP/1.0
\"
\"
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Element/1.11.20 Chrome/108.0.5359.179 Electron/22.0.3 Safari/537.36
\"
[0 dbevts]"
,
"level"
:
"info"
}
],
"highlights"
:
{
"user_id"
:
{
"pattern"
:
"(@|%40)[^:% ]+(:|%3A)[
\\
[
\\
]0-9a-zA-Z.
\\
-:]+(:
\\
d{1,5})?(?<!:)"
,
"underline"
:
true
},
"room_id"
:
{
"pattern"
:
"(!|%21)[^:% ]+(:|%3A)[
\\
[
\\
]0-9a-zA-Z.
\\
-:]+(:
\\
d{1,5})?(?<!:)"
,
"underline"
:
true
},
"room_alias"
:
{
"pattern"
:
"(#|%23)[^:% ]+(:|%3A)[
\\
[
\\
]0-9a-zA-Z.
\\
-:]+(:
\\
d{1,5})?(?<!:)"
,
"underline"
:
true
},
"event_id_v1_v2"
:
{
"pattern"
:
"(
\\
$|%25)[^:% ]+(:|%3A)[
\\
[
\\
]0-9a-zA-Z.
\\
-:]+(:
\\
d{1,5})?(?<!:)"
,
"underline"
:
true
},
"event_id_v3_plus"
:
{
"pattern"
:
"(
\\
$|%25)([A-Za-z0-9+/_]|-){43}"
,
"underline"
:
true
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment