aerogear / keycloak-metrics-spi

Adds a Metrics Endpoint to Keycloak
Apache License 2.0
549 stars 156 forks source link

A lot of _created metrics provide huge values with Keycloak 18.0.2 #142

Open dj-wasabi opened 2 years ago

dj-wasabi commented 2 years ago

Description

Add a brief and meaningful description.

Several _created metrics provides huge values, which doesn't make any sense.

Expected Behavior

I expect actual representative values that shows how many are created. The values for _created are way higher than the _total metrics.

Actual Behavior

See in steps to reproduce, where I pasted output of metrics.

Environment

Steps to reproduce

Updated the gradle.properties to:

keycloakVersion=18.0.2
prometheusVersion=0.15.0

Then executed:

./gradlew jar

Copy the jar file to a path that was mounted as /opt/keycloak/providers/ in the Official Keycloak 18.0.2 Docker image. Enabled the metrics-listener event in the realm, added environment variable where to find the pushgateway.

I then get the following when doing a curl on pushgateway metrics endpoint:

# TYPE keycloak_admin_event_UPDATE_created gauge
keycloak_admin_event_UPDATE_created{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="AUTHENTICATOR_CONFIG"} 1.659006505979e+09
keycloak_admin_event_UPDATE_created{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="AUTH_EXECUTION"} 1.659006497181e+09
keycloak_admin_event_UPDATE_created{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="CLIENT"} 1.659006482397e+09
keycloak_admin_event_UPDATE_created{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="CLIENT_SCOPE"} 1.659006481065e+09
keycloak_admin_event_UPDATE_created{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="REALM"} 1.659006468085e+09
keycloak_admin_event_UPDATE_created{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="REALM_ROLE"} 1.659006475777e+09
keycloak_admin_event_UPDATE_created{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="USER"} 1.659006483917e+09
# HELP keycloak_admin_event_UPDATE_total Generic KeyCloak Admin event
# TYPE keycloak_admin_event_UPDATE_total counter
keycloak_admin_event_UPDATE_total{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="AUTHENTICATOR_CONFIG"} 3
keycloak_admin_event_UPDATE_total{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="AUTH_EXECUTION"} 10
keycloak_admin_event_UPDATE_total{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="CLIENT"} 3
keycloak_admin_event_UPDATE_total{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="CLIENT_SCOPE"} 1
keycloak_admin_event_UPDATE_total{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="REALM"} 24
keycloak_admin_event_UPDATE_total{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="REALM_ROLE"} 8
keycloak_admin_event_UPDATE_total{instance="172.16.2.1",job="keycloak",realm="myrealm",resource="USER"} 1
# HELP keycloak_login_attempts_created Total number of login attempts
# TYPE keycloak_login_attempts_created gauge
keycloak_login_attempts_created{client_id="security-admin-console",instance="172.16.2.1",job="keycloak",provider="keycloak",realm="master"} 1.6590166233e+09
# HELP keycloak_login_attempts_total Total number of login attempts
# TYPE keycloak_login_attempts_total counter
keycloak_login_attempts_total{client_id="security-admin-console",instance="172.16.2.1",job="keycloak",provider="keycloak",realm="master"} 4
# HELP keycloak_logins_created Total successful logins
# TYPE keycloak_logins_created gauge
keycloak_logins_created{client_id="security-admin-console",instance="172.16.2.1",job="keycloak",provider="keycloak",realm="master"} 1.6590166233e+09
# HELP keycloak_logins_total Total successful logins
# TYPE keycloak_logins_total counter
keycloak_logins_total{client_id="security-admin-console",instance="172.16.2.1",job="keycloak",provider="keycloak",realm="master"} 4
# HELP keycloak_refresh_tokens_created Total number of successful token refreshes
# TYPE keycloak_refresh_tokens_created gauge
keycloak_refresh_tokens_created{client_id="security-admin-console",instance="172.16.2.1",job="keycloak",provider="keycloak",realm="master"} 1.65901695502e+09
# HELP keycloak_refresh_tokens_total Total number of successful token refreshes
# TYPE keycloak_refresh_tokens_total counter
keycloak_refresh_tokens_total{client_id="security-admin-console",instance="172.16.2.1",job="keycloak",provider="keycloak",realm="master"} 3

I get a really high value for the items that ends with _created items. This info is shown via "https://FQDN/auth/realms/master/metrics" and via the pushgateway metrics endpoint.

souravs17031999 commented 1 year ago

@dj-wasabi did you find any solution ? I am facing the same issue with KC 21 with latest spi 3.0.0.

dj-wasabi commented 1 year ago

@dj-wasabi did you find any solution ? I am facing the same issue with KC 21 with latest spi 3.0.0.

Hi, no I let it go back then as I believe I was not able to fix it.

avi-ran commented 11 months ago

Hi!

Just noticed it also. It seems like these values are timestamps!

Markus- commented 4 months ago

Those are unix-timestamps in science notation.