A while ago I did a proposal for a dashboard page for the Keycloak admin
console that build on such metrics:
Would be great to have such a metrics API that would also work in clustered
2018-01-25 20:53 GMT+01:00 Stian Thorgersen <sthorger(a)redhat.com>:
Would be good to have support for Prometheus. This is also
would be good to display in the Keycloak admin console.
I don't think using an event listener is the right approach though. One
issue here is that this will only work for a single node and not in a
cluster. The numbers should also be per-realm, not for all realms.
A better option may be to add an MetricsSPI where the default provider
would get the details from Keycloak itself. Useful details could be:
* Number of active sessions - we can get this from counting number of open
sessions (not sure if that will be a costly query to do as user sessions
are stored in a distributed cache)
* Number of failed logins - we can get this from events storage when
enabled and it can be made configurable to only consider events for the
last X days
* Number of logins - same as above
We could add a new endpoint /realms/<realm-name>/metrics/<provider>. That
would allow adding whatever provider for the format you want (i.e.
prometheus). I don't think this info should be available publicly though so
it has to be protected somehow.
I'm also not to keen on using io.prometheus.client library for this if that
can be avoided. We don't like having to maintain additional libraries and
prefer to use things that are already available in EAP/WilldFly.
On 22 January 2018 at 13:45, Matthias Wessendorf <matzew(a)apache.org>
> On Mon, Jan 22, 2018 at 12:45 PM, Peter Braun <pbraun(a)redhat.com> wrote:
> > Hey everybody,
> > we (the AeroGear/Mobile team) have created a SPI that adds a metrics
> > endpoint to KeyCloak. It’s inspired by a similar project named
> > keycloak-metrics-prometheus but does not require an extra service.
> > Metrics data is based on internal events and is exposed in Prometheus
> > format.
> > Just wanted to share this with you since there are a number of tickets
> > the KeyCloak JIRA about a such an endpoint. We’re happy about any
> > suggestions/opinions. We’re also open to an upstream contribution if
> > opportunity arises and you are interested.
> +1 for having this directly in Keycloak :-)
> > Regards,
> > Peter
> >  https://github.com/aerogear/keycloak-metrics-spi
> > https://github.com/aerogear/keycloak-metrics-spi>
> >  https://github.com/larscheid-schmitzhermes/keycloak-
> > monitoring-prometheus <https://github.com/larscheid-
> > schmitzhermes/keycloak-monitoring-prometheus>
> > _______________________________________________
> > keycloak-dev mailing list
> > keycloak-dev(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/keycloak-dev
> Matthias Wessendorf
> github: https://github.com/matzew
> twitter: http://twitter.com/mwessendorf
> keycloak-dev mailing list
keycloak-dev mailing list