Skip to content

Instantly share code, notes, and snippets.

@vjanssens
Last active June 22, 2024 16:20
Show Gist options
  • Save vjanssens/3c6fb8393d87346323d939f1728ca293 to your computer and use it in GitHub Desktop.
Save vjanssens/3c6fb8393d87346323d939f1728ca293 to your computer and use it in GitHub Desktop.
lnav log definition for Caddy server
# 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 {} +
{
"$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