Repository navigation
Replies: 9 comments 10 replies
|
I also agree we should go for
W.r.t. to the initial scope. I wouldn't include any additional extension in the first iteration but enable the properties we want to support. My point is that we should enable JSON format, integration those 3rd party logging services, depending on the feedback we get from the community. W.r.t. to the changing log settings. I'm more in favor of But I'm really not sure about doing this via HTTP. For now, I would start simple and just go for watching logging changes in |
|
I just tried it out a bit on this branch: https://github.com/DGuhr/keycloak/tree/PoC_Logging Here are some visuals, maybe it helps some ppl:
|
|
Thanks for creating a discussion for logging. There are also some comments in this Spec PR that might be helpful: keycloak/keycloak-community#238 |
|
Hi, |
|
I support KC as part of my day to day job and have a background in data engineering in security logging scenarios. Regarding @DGuhr and @fidgi comments on format (GELF or ECS) I would rather not have format definition nor specific pipeline framework integration bundled out of the box. The rationale is simple: Places using Splunk are unlikely to use ECS, while places using ArcSight are unlikely to use JSON. The overall idea of configuration and extensibility is to be able to use a particular set of features you depend on without having to recompile stuff from zero. Today, wildfly logging makes using either JSON or KV delimited logging particularly simple. Even multiline logging, the worst logging challenge in java, can be solved by configuring the logging framework to to replace \n with \u2028. Happy days. Having written a parser for CEF (one of the earliest interactions of log schema standards) I can honestly say that logging formats are set to fail. Trying to make anything standard across a single enterprise is already hard enough, let aside across different organisations. To make it worse, most places with high volume logging needs already realised that JSON is terrible for data storage and handling. As consequence I am seeing an increasing number of shops moving to different encoding such as avro or protobufs. Things gets messy very quickly in logging world. Like REALLY messy. We, KC users, already struggle with the current dependency injections arising from Wildfly, so my view is, keep things as simple as possible, allow people to extend as they need. this seems to be aligned with overall quarkus modularity principles, so we may just need to figure out a way of configuring them during kc.sh config or similar. |
|
I am not sure that all this complex log feature is needed. However, you need to support simple log features that is now difficult with current Keycloak. |
|
Hey everyone. First of all thank you all for the very valuable Feedback. Just a heads up: I'm looking forward to create some issues out of this discussion and start with a v1 integration early next year, or even this year (when I get bored over christmas ;) ). If anyone is willing to help, feel free to reach out and we'll figure out a work mode (I come from a more "onsite" background, so love to do pairing/ensemble programming if you want). |
|
Hi, is there any option how to switch Keycloak 17 logs to the JSON format, please? Naive solution, e.g.: doesn't work very well. |
|
I'm going to lock this thread as it is becoming rather lengthy and doesn't have a proper summary/description at the top. @DGuhr will create a new general logging proposal in https://github.com/keycloak/keycloak/discussions/categories/keycloak-x-quarkus-distribution, but in the meantime feel free to open separate discussions about different topics (such as json logging format). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Locked - please open new separate discussions in https://github.com/keycloak/keycloak/discussions/categories/keycloak-x-quarkus-distribution
Hey 👋
I want to revive the discussion around logging, and logging only, bc. at the moment we totally rely on the (good) features quarkus gives us, but I think we can do even better and hope for input from your side to help us.
Why:
Out of Scope:
How:
note: the (?) means I am not sure myself if it is a good idea, so please provide feedback on this especially
Have a consistent syntax abstraction for different loggers.
Either:
-
kc.log.<category>.<level/min-level/format/...>=...- where category is optional, as it is ith quarkus, and e.g.
kc.log.min-levelsets the overall log-minlevel.- Example: -
kc.log.db.level=...-> for hibernate related loggingOR:
e.g.:
-
kc.db.log.<level/min-level/format/...>=...kc.log.level/min-level/format=...would map internally toquarkus.log.level/min-level/format=...as a base abstraction to not havequarkusprefixed values in keycloak.properties together withkcprefixed.Opinion: Imo we should go with
kc.log.<category>.<...>approach, bc. it is in line with how quarkus does logging[1] and may make it easier to maintain / integrate, bc. both follow the same approach.- provide meaningful abstractions around quarkus category logging
- e.g.
kc.log.db.level=<...>instead ofquarkus.log.category."org.hibernate".level=<...>- I think it may be a good idea to get rid of these
"quarkus uses for its categories, where applicable, bc. these make it hard to e.g. parse them via CLI, and also we wouldn't be able to provide them via envvars. Good inputs for "where applicable" wanted, I think of the following for a start (usinglevelfor the sake of simplicity):-
kc.log.db.level-> maps toquarkus.log."org.hibernate".levelinternally-
kc.log.request-log-> maps internally to 2 quarkus props, and sets internallyquarkus.http.access-log.enabled=true quarkus.http.access-log.category=org.keycloak.request-log- ...? (e.g. infinispan, but also things like SAML/OIDC related logs may be interesting)
- provide support for plain/json logging
- leverage the quarkus extension quarkus-logging-json for this and map it to be
kcprefixed- support for file/console logging
- only mapping to
kcprefix needed.- support for syslog(?)
- provide ootb support for Logstash/Graylog/FluentD via gelf appender (?)
- note: there's an extension for it, which should make integration relatively easy -> quarkus-logging-gelf[2]
References:
[1] https://quarkus.io/guides/logging
[2] https://quarkus.io/guides/centralized-log-management
Second Topic:
I also have some ideas about changing the log level dynamically when keycloak is running:
Allow dynamical change of log level when keycloak runs(?)
Option 1: filewatcher, and set level it via kc.sh
- pro: easy to setup via cli.
- con: in a cloud native env., you would not want to log into the container, more something for the "classic" dist onprem.
- Also, from my experience this could lead to some dark places in terms of edge cases where it doesn't behave as it should.
Option 2: Have an endpoint for setting/getting log lvl in keycloaks quarkus dist.
Assumption: We don't want to use /q/ as non-app endpoint, and this endpoint should be protected
Possibility 1: Talk to quarkus ppl, -> There is an open issue Separate binding/port config for non application endpoints quarkusio/quarkus#13602, which is basically about another vert.x for a somewhat "wildfly-like" mgmt port approach for metrics/health/logging endpoints. Still, we may want to provide our own protection nevertheless.
Possibility 2: Have our vert.x requestfilter check for this endpoint(s)/path(s) and only allow requests from a whitelist of hosts, usually only containing e.g. localhost. But this could be a performance degradation, and possibly insecure. Example how this could look like, see @thomasdarimont implementation in [1]
Possibility 2a: integrate sth like https://github.com/quarkiverse/quarkus-logging-manager which has its own basic security, and make it better in following iterations
Option 3:
Imo all options are applicable, but option2 in whatever taste is preferrable, bc it gives us more flexibility, but also needs to be properly secured for sure.
[1] https://github.com/thomasdarimont/keycloak-project-example/blob/main/keycloak/extensionsx/src/main/java/com/github/thomasdarimont/keycloakx/custom/security/AccessFilter.java#L19
All reactions