Skip to content

Commit c60e2ea

Browse files
committed
[formats] add some mysql formats
1 parent 12e10da commit c60e2ea

21 files changed

Lines changed: 557 additions & 287 deletions

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
## lnav v0.13.1
23

34
Features:
@@ -12,6 +13,10 @@ Features:
1213
`:annotate` on a statement error line (e.g. syntax error
1314
at or near "null" at character 522) to attach an annotation
1415
with the statement and a pointer to the location of the error.
16+
* Added the mysql_error_log and mysql_slow_log formats. There
17+
is also a `mysql_slow_stats` search table that captures the
18+
various statistics available in a slow query log message
19+
(e.g. `query_time`, `lock_time`, ...).
1520
* Annotation handlers can now be lnav scripts if the "handler"
1621
field starts with a pipe ("|").
1722
* The `<span>` tag in a markdown now supports

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,16 @@ set(FORMAT_FILES
188188
formats/journald_json_log.json
189189
formats/katello_log.json
190190
formats/lnav_debug_log.json
191+
formats/mysql_error_log.json
192+
formats/mysql_slow_log.json
191193
formats/nextcloud_log.json
192194
formats/nextflow_log.json
193195
formats/openam_log.json
194196
formats/openamdb_log.json
195197
formats/openstack_log.json
196198
formats/page_log.json
197199
formats/pcap_log.json
200+
formats/postgres_log.json
198201
formats/procstate_log.json
199202
formats/proxifier_log.json
200203
formats/redis_log.json

src/formats/formats.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ FORMAT_FILES = \
2525
$(srcdir)/%reldir%/journald_json_log.json \
2626
$(srcdir)/%reldir%/katello_log.json \
2727
$(srcdir)/%reldir%/lnav_debug_log.json \
28+
$(srcdir)/%reldir%/mysql_error_log.json \
29+
$(srcdir)/%reldir%/mysql_slow_log.json \
2830
$(srcdir)/%reldir%/nextcloud_log.json \
2931
$(srcdir)/%reldir%/nextflow_log.json \
3032
$(srcdir)/%reldir%/openam_log.json \

src/formats/mysql_error_log.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
3+
"mysql_error_log": {
4+
"title": "MySQL Error Log",
5+
"description": "Format for MySQL error logs",
6+
"url": ["https://dev.mysql.com/doc/refman/8.4/en/error-log-format.html"],
7+
"regex": {
8+
"std": {
9+
"pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}[^ ]+)\\s+(?<thread>\\d+)\\s+\\[(?<level>\\w+)\\](?:\\s+\\[(?<err_code>[^\\]]+)\\]\\s+\\[(?<subsystem>[^\\]]+)\\])?\\s+(?<body>.*)"
10+
}
11+
},
12+
"value": {
13+
"err_code": {
14+
"kind": "string",
15+
"identifier": true
16+
},
17+
"level": {
18+
"kind": "string"
19+
},
20+
"subsystem": {
21+
"kind": "string",
22+
"identifier": true
23+
},
24+
"thread": {
25+
"kind": "string",
26+
"identifier": true
27+
},
28+
"timestamp": {
29+
"kind": "string"
30+
}
31+
},
32+
"sample": [
33+
{
34+
"line": "2020-08-06T14:25:02.835618Z 0 [Note] [MY-012487] [InnoDB] DDL log recovery : begin"
35+
},
36+
{
37+
"line": "2020-08-06T14:25:02.835618Z 0 [Note] DDL log recovery : begin"
38+
}
39+
]
40+
}
41+
}

src/formats/mysql_slow_log.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
3+
"mysql_slow_log": {
4+
"title": "MySQL Slow Query",
5+
"description": "Format for the MySQL slow query log",
6+
"regex": {
7+
"std": {
8+
"pattern": "^# Time: (?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}.*)$"
9+
},
10+
"abbrev": {
11+
"pattern": "^# Time: (?<timestamp>\\d{6} \\d{2}:\\d{2}:\\d{2})$"
12+
}
13+
},
14+
"value": {
15+
"timestamp": {
16+
"kind": "string"
17+
}
18+
},
19+
"search-table": {
20+
"mysql_slow_stats": {
21+
"pattern": "^#\\s+Time:\\s+[^\\n]+\\n# User@Host: (?<user>[^\\s]+)\\s+@\\s(?<host>[^ ]*)\\s\\[[^\\]]*\\]\\s+Id:\\s+(?<conn_id>\\d+)\\n(?:#\\s+Schema:\\s+(?<schema>[^\\s]+)\\s+Last_errno:\\s+(?<last_errno>\\d+)\\s+Killed:\\s+(?<killed>\\d+)\\n)?# Query_time:\\s+(?<query_time>\\d+\\.\\d+)\\s+Lock_time:\\s+(?<lock_time>\\d+\\.\\d+)\\s+Rows_sent:\\s+(?<rows_sent>\\d+)\\s+Rows_examined:\\s+(?<rows_examined>\\d+)(?:\\s+Rows_affected:\\s+(?<rows_affected>\\d+))?\\n(?:#\\s+Bytes_sent:\\s+(?<bytes_sent>\\d+)\\n)?(?<query>.*)"
22+
}
23+
},
24+
"sample": [
25+
{
26+
"line": "# Time: 2021-01-26T23:45:57.678222Z"
27+
},
28+
{
29+
"line": "# Time: 170213 16:00:33"
30+
}
31+
]
32+
}
33+
}

src/formats/postgres_log.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Format for PostgreSQL logs",
66
"regex": {
77
"std": {
8-
"pattern": "(?<timestamp>^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(\\.\\d{3})? \\S+) \\[(?<pid>[\\d\\-]+)\\](?<host>\\s+\\[[^\\]]+\\])?(?:\\s+(?<user>[^@]+)@(?<db_name>\\S+))? (?<level>DEBUG\\d?|DETAIL|CONTEXT|INFO|NOTICE|WARNING|ERROR|LOG|FATAL|PANIC|STATEMENT): *(?<body>.*)$"
8+
"pattern": "^(?<timestamp>^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(\\.\\d{3})? \\S+) \\[(?<pid>[\\d\\-]+)\\](?<host>\\s+\\[[^\\]]+\\])?(?:\\s+(?<user>[^@]+)@(?<db_name>\\S+))? (?<level>DEBUG\\d?|DETAIL|CONTEXT|INFO|NOTICE|WARNING|ERROR|LOG|FATAL|PANIC|STATEMENT): *(?<body>.*)$"
99
}
1010
},
1111
"value": {

0 commit comments

Comments
 (0)