Last active
October 21, 2024 12:39
-
-
Save vjanssens/3c6fb8393d87346323d939f1728ca293 to your computer and use it in GitHub Desktop.
lnav log definition for Caddy server
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
# download the caddy.json lnav configuration file and install it in lnav | |
wget https://gist.githubusercontent.com/vjanssens/3c6fb8393d87346323d939f1728ca293/raw/caddy.json | |
lnav -i caddy.json | |
# now you can query the caddy log directories | |
lnav . | |
# find logfiles not older than 7 days and pipe them to lnav | |
find . -mtime -7 -type f -exec lnav {} + |
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
{ | |
"$schema": "https://lnav.org/schemas/format-v1.schema.json", | |
"caddy": { | |
"title": "Caddy Server", | |
"description": "Caddy Server JSON access logs format", | |
"url": [ | |
"https://caddyserver.com/docs/caddyfile/directives/log" | |
], | |
"json": true, | |
"timestamp-field": "ts", | |
"level-field": "level", | |
"hide-extra": true, | |
"opid-field": "request/remote_ip", | |
"value": { | |
"level": { | |
"kind": "string", | |
"identifier": true, | |
"hidden": true | |
}, | |
"ts": { | |
"kind": "string", | |
"hidden": true | |
}, | |
"logger": { | |
"kind": "string", | |
"hidden": true | |
}, | |
"msg": { | |
"kind": "string", | |
"hidden": true | |
}, | |
"bytes_read": { | |
"kind": "string", | |
"hidden": true | |
}, | |
"duration": { | |
"kind": "float", | |
"hidden": true | |
}, | |
"size": { | |
"kind": "integer", | |
"hidden": true | |
}, | |
"status": { | |
"kind": "integer" | |
}, | |
"request": { | |
"kind": "json", | |
"hidden": true | |
}, | |
"resp_headers": { | |
"kind": "json", | |
"hidden": true | |
}, | |
"request/remote_ip": { | |
"kind": "string", | |
"identifier": true | |
}, | |
"request/method": { | |
"kind": "string", | |
"identifier": true | |
}, | |
"request/host": { | |
"kind": "string", | |
"identifier": true | |
}, | |
"request/uri": { | |
"kind": "string" | |
}, | |
"request/headers": { | |
"kind": "json", | |
"hidden": true | |
}, | |
"request/headers/Referer#": { | |
"kind": "string" | |
} | |
}, | |
"line-format": [ | |
{ | |
"field": "__timestamp__" | |
}, | |
" ", | |
{ | |
"field": "request/remote_ip" | |
}, | |
" ", | |
{ | |
"field": "request/method" | |
}, | |
" ", | |
{ | |
"field": "request/host" | |
}, | |
{ | |
"field": "request/uri" | |
}, | |
" ", | |
{ | |
"field": "status" | |
}, | |
" ", | |
{ | |
"field": "request/headers/Referer#" | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment