Redacting or Dropping Logged Headers

Hi all,

I'm currently attempting to not log or redact a header value called 'request_Secret' using the following configuration:

accessLog:
  format: json
  filePath: "/dev/stdout"
  fields:
    defaultMode: keep
    names:
      request_Secret: drop
    headers:
      defaultMode: keep
      names:
        request_Secret: drop

However, traefik continues to log the header and value.

I've tried using redact instead with no luck. I've tried using this in just the fields or just the 'headers' sections (what is the difference???) without success.

Am I doing something wrong?

I think "fields" are the key names of the regular Traefik JSON access log.

The "headers" should be http request headers.

Are you sure your spelling is correct?

From the doc:

# Limiting the Logs to Specific Fields
accessLog:
  filePath: "/path/to/access.log"
  format: json
  fields:
    defaultMode: keep
    names:
      ClientUsername: drop
    headers:
      defaultMode: keep
      names:
        User-Agent: redact
        Authorization: drop
        Content-Type: keep

Hey bluepuma77,

OK, that's a bit clearer on fields and headers - thank you. What spelling are you referring to? If it's the header name, yes, it's correct. I've tried as shown above and all lowercase, just in case.

Cheers

Resolved this. The header I was trying to remove or redact was called Secret, but the logs were showing request_Secret so that's the header name I used in the configuration. Now I've dropped the request_ prefix it's works just fine. This works;

accessLog:
  format: json
  filePath: "/dev/stdout"
  fields:
    defaultMode: keep
    headers:
      defaultMode: keep
      names:
        Secret: redacted

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.