Giter VIP home page Giter VIP logo

Comments (8)

AlexSins avatar AlexSins commented on May 21, 2024 1
  • { "client":"", "method":"", "username":"", "timestamp":"", "host":"", "upstream":"", "url":, "protocol":"", "user_agent":, "status":"", "length":"", "response-time":"", }

maybe the problem is the lack of space between the quotes #

from oauth2-proxy.

Ghazgkull avatar Ghazgkull commented on May 21, 2024 1

@AlexSins Unfortunately, it's not an input problem. The code itself isn't written to support JSON logging because there's no way to tell it to do the required escaping (e.g. double quotes). The problem is tracked here: #1057

from oauth2-proxy.

JoelSpeed avatar JoelSpeed commented on May 21, 2024

Logging has recently been improved with logging formats that will allow users to define their own structure, closing this

from oauth2-proxy.

max-wittig avatar max-wittig commented on May 21, 2024

I don't think this should be closed. json logging seems to be pretty standard these days and should be supported by oauth2-proxy

from oauth2-proxy.

max-wittig avatar max-wittig commented on May 21, 2024

We solved it in a hacky way for now, but using this logging format. Maybe this helps somebody, as long as this is not offically supported.


auth_logging_format = '{"client": "{{.Client}}", "username": "{{.Username}}", "timestamp": "{{.Timestamp}}", "status": {{.Status}}, "message": "{{.Message}}"}'
request_logging_format = '{"client": "{{.Client}}", "username": "{{.Username}}", "timestamp": "{{.Timestamp}}", "host": "{{.Host}}", "request_method": "{{.RequestMethod}}", "upstream": "{{.Upstream}}", "request_uri": {{.RequestURI}}, "protocol": "{{.Protocol}}", "user_agent": {{.UserAgent}}, "status_code": {{.StatusCode}}, "response_size": {{.ResponseSize}}, "request_duration": {{.RequestDuration}}}'
standard_logging_format = '{"timestamp": "{{.Timestamp}}", "file": "{{.File}}", "message": "{{.Message}}"}'

from oauth2-proxy.

JoelSpeed avatar JoelSpeed commented on May 21, 2024

One of the primary goals of introducing customisable logging formats was to allow people to use structured logging in exactly the way you have done in your comment above.

I can't recall if we have an example of a JSON logging template in the docs, but if not, perhaps we could update it to I could your example

from oauth2-proxy.

Ghazgkull avatar Ghazgkull commented on May 21, 2024

@max-wittig Thank you for this example. I'm trying to figure this out right now. The format you provide looks good, but I deploy oauth2-proxy with the helm chart and helm is choking on a value like that... I think because the format string is using the same variable syntax as helm. Have you (or anyone else, @JoelSpeed) configured structured log formatting using the Helm chart?

from oauth2-proxy.

Ghazgkull avatar Ghazgkull commented on May 21, 2024

For anyone coming along in the future, I actually figured out how to set this up in the Helm chart. Here's an example of what I'm doing in my values.yaml:

extraArgs:
  request-logging-format: >-
    {
    "client":"{{.Client}}",
    "method":"{{.RequestMethod}}",
    "username":"{{.Username}}",
    "timestamp":"{{.Timestamp}}",
    "host":"{{.Host}}",
    "upstream":"{{.Upstream}}",
    "url":{{.RequestURI}},
    "protocol":"{{.Protocol}}",
    "user_agent":{{.UserAgent}},
    "status":"{{.StatusCode}}",
    "length":"{{.ResponseSize}}",
    "response-time":"{{.RequestDuration}}",
    }

from oauth2-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.