1
1
mirror of https://github.com/tstack/lnav.git synced 2024-08-16 08:20:29 +03:00

[formats] add caddy log

Related to #1268
This commit is contained in:
Tim Stack 2024-05-28 11:08:58 -07:00
parent a28ddb7196
commit 937a4588f7
4 changed files with 114 additions and 1 deletions

View File

@ -119,6 +119,7 @@ multiplex_matcher::match(const string_fragment& line)
return found{demux_pair.first};
}
#if 0
auto partial_size = df.dd_pattern.pp_value->match_partial(line);
if (partial_size > 0) {
log_info(" only partial match by pattern: %s",
@ -126,6 +127,7 @@ multiplex_matcher::match(const string_fragment& line)
log_info(" %s",
line.sub_range(0, partial_size).to_string().c_str());
}
#endif
}
if (df.dd_control_pattern.pp_value) {
md = df.dd_control_pattern.pp_value->create_match_data();

110
src/formats/caddy_log.json Normal file
View File

@ -0,0 +1,110 @@
{
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
"caddy_log": {
"title": "Caddy log format",
"description": "",
"file-type": "json",
"timestamp-field": "ts",
"line-format": [
{
"field": "__timestamp__"
},
{
"prefix": " ",
"field": "request/client_ip"
},
{
"prefix": " ",
"field": "user_id",
"default-value": ""
},
{
"prefix": " \"",
"field": "request/method"
},
{
"prefix": " ",
"field": "request/host"
},
{
"field": "request/uri"
},
{
"prefix": " ",
"field": "request/proto",
"suffix": "\""
},
{
"prefix": " ",
"field": "status"
},
{
"prefix": " ",
"field": "size"
},
{
"prefix": " ",
"field": "msg"
}
],
"value": {
"bytes_read": {
"kind": "integer"
},
"duration": {
"kind": "integer"
},
"level": {
"kind": "string",
"hidden": true
},
"logger": {
"kind": "string",
"hidden": true
},
"request": {
"kind": "json",
"hidden": true
},
"request/client_ip": {
"kind": "string",
"collate": "ipaddress",
"identifier": true
},
"request/host": {
"kind": "string",
"identifier": true
},
"request/method": {
"kind": "string",
"identifier": true
},
"request/proto": {
"kind": "string",
"identifier": true
},
"request/uri": {
"kind": "string",
"identifier": true
},
"resp_headers": {
"kind": "json",
"hidden": true
},
"msg": {
"kind": "string"
},
"size": {
"kind": "integer"
},
"status": {
"kind": "integer",
"foreign-key": true
},
"user_id": {
"kind": "string",
"identifier": true
}
}
}
}

View File

@ -4,6 +4,7 @@ FORMAT_FILES = \
$(srcdir)/%reldir%/alb_log.json \
$(srcdir)/%reldir%/block_log.json \
$(srcdir)/%reldir%/bunyan_log.json \
$(srcdir)/%reldir%/caddy_log.json \
$(srcdir)/%reldir%/candlepin_log.json \
$(srcdir)/%reldir%/choose_repo_log.json \
$(srcdir)/%reldir%/cloudflare_log.json \

View File

@ -5252,7 +5252,7 @@
"demux": {
"container": {
"enabled": true,
"pattern": "^(?:\\x1b\\[\\d*K)?(?<mux_id>[a-zA-Z0-9][a-zA-Z0-9_\\.\\-]*)\\s+\\| (?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{9}Z )?(?<body>.*)",
"pattern": "^(?:\\x1b\\[\\d*K)?(?<mux_id>[a-zA-Z0-9][\\@a-zA-Z0-9_\\.\\-]*)\\s+\\| (?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{9}Z )?(?<body>.*)",
"control-pattern": ""
},
"container-with-type": {