Skip to content

[Feature] Proxy logging improvements #1143

@arthurwozniak

Description

@arthurwozniak

Hi there!

I recently attempted to migrate from kamal version 1.9.1 to 2.2.2 and encountered a couple of issues that require some workaround configurations for kamal and rsyslog to maintain the original behavior.

1. Compliance with logging.driver

It seems that the container running kamal-proxy is not utilizing the specified logging.driver configuration (if set) and is instead writing logs to a file. This change is unexpected, as traefik adhered to the logging driver specified in the configuration.

Current Configuration:

logging:
  driver: syslog
  options:
    tag: '{{ index (split .Name "-") 1 }}'

2. Passing custom docker options to proxy

To address the logging issue, I attempted to set docker options using the boot_config command.

$ kamal proxy boot_config set --docker_options log-driver=syslog -d staging
$ kamal proxy reboot -d staging
Note: This may cause a brief outage on each host. Are you sure? [y, N] (N) y
...

However, I encountered an error:

INFO [e1b4c244] Running docker run --name kamal-proxy --network kamal --detach --restart unless-stopped --volume kamal-proxy-config:/home/kamal-proxy/.config/kamal-proxy $(cat .kamal/proxy/options || echo "--publish 80:80 --publish 443:443 --log-opt max-size=10m") basecamp/kamal-proxy:v0.8.1 on A.B.C.D
Releasing the deploy lock...
ERROR (SSHKit::Command::Failed): Exception while executing on host A.B.C.D: docker exit status: 125
docker stdout: Nothing written
docker stderr: docker: Error response from daemon: unknown log opt 'max-size' for syslog log driver.
See 'docker run --help'.

It appears that Kamal internally sets the max-size option, which conflicts with the syslog log driver. This can be resolved by manually editing .kamal/proxy/options on host to remove --log-opt max-size=10m.

3. Definition of unwanted log fields

Another useful feature would be the ability to specify fields to exclude from log entries. Currently, the log entries contain many fields that may not be necessary for certain use cases, such as:

{
  "time": "some_val",
  "level": "some_val",
  "msg": "some_val",
  "host": "some_val",
  "port": "some_val",
  "path": "some_val",
  "request_id": "some_val",
  "status": "some_val",
  "service": "some_val",
  "target": "some_val",
  "duration": "some_val",
  "method": "some_val",
  "req_content_length": "some_val",
  "req_content_type": "some_val",
  "resp_content_length": "some_val",
  "resp_content_type": "some_val",
  "client_addr": "some_val",
  "client_port": "some_val",
  "remote_addr": "some_val",
  "user_agent": "some_val",
  "proto": "some_val",
  "scheme": "some_val",
  "query": "some_val",
  "resp_x_runtime": "some_val"
}

Since we can already define proxy.logging.request_headers and proxy.logging.response_headers, I suggest adding a proxy.logging.dropped_fields array for this purpose.

Fields can be filtered out in the rsyslog configuration, but this introduces significant complexity to what is otherwise a straightforward tool.

However, this is likely a feature request for the kamal-proxy repo as logging is handled there.

Thank you for your hard work on this project! Keep rolling! 🚀 💪

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions