I want to rename the ts
field in logs emitted by Caddy in order to be able to ingest them into Loki, a log ingestion tool that uses the ts
field to note down the ingest time of the log. This is easily achieved through the time_key
option as shown below:
test.example.app {
reverse_proxy 127.0.0.1:8080
log {
format json {
time_key timestamp
}
output file /var/log/caddy/access.log {
roll_size 4MiB
roll_keep 3
}
}
}
However, I also don’t want the common_log
field and want to delete it, but I’m not sure how to get both format filter { wrap }
and the time_key
option working. I tried the following but it doesn’t work:
test.example.app {
reverse_proxy 127.0.0.1:8080
log {
format filter {
wrap json {
fields {
common_log delete
}
time_key timestamp
}
}
output file /var/log/caddy/access.log {
roll_size 4MiB
roll_keep 3
}
}
}
Is there a way to combine these two directives?