[keycloak-dev] Metrics Endpoint
Stian Thorgersen
sthorger at redhat.com
Thu Jan 25 14:53:40 EST 2018
Would be good to have support for Prometheus. This is also information that
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 at apache.org> wrote:
> On Mon, Jan 22, 2018 at 12:45 PM, Peter Braun <pbraun at redhat.com> wrote:
>
> > Hey everybody,
> >
> > we (the AeroGear/Mobile team) have created a SPI that adds a metrics
> > endpoint to KeyCloak[1]. It’s inspired by a similar project named
> > keycloak-metrics-prometheus[2] 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 in
> > the KeyCloak JIRA about a such an endpoint. We’re happy about any
> > suggestions/opinions. We’re also open to an upstream contribution if the
> > opportunity arises and you are interested.
> >
>
> +1 for having this directly in Keycloak :-)
>
>
>
> >
> >
> > Regards,
> > Peter
> >
> > [1] https://github.com/aerogear/keycloak-metrics-spi <
> > https://github.com/aerogear/keycloak-metrics-spi>
> > [2] https://github.com/larscheid-schmitzhermes/keycloak-
> > monitoring-prometheus <https://github.com/larscheid-
> > schmitzhermes/keycloak-monitoring-prometheus>
> > _______________________________________________
> > keycloak-dev mailing list
> > keycloak-dev at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>
More information about the keycloak-dev
mailing list