aerogear / keycloak-metrics-spi

Adds a Metrics Endpoint to Keycloak
Apache License 2.0
526 stars 151 forks source link

Option to clear/reset metrics ? #154

Closed heartofrevel closed 1 year ago

heartofrevel commented 1 year ago

Hi,

Is there any option to clear/reset metrics. Or does metric reset in specific intervals or does metric only reset at restart of keycloak ?

My concern here is that I want to create an alarm on keycloak_failed_login_attempts, so that if numbr goes above a certain value, I will see an alarm on my monitoring dashboard. keycloak_failed_login_attempts{realm="5f59671b-ef3d-4919-b1a9-ce35503320a1",provider="keycloak",error="invalid_user_credentials",client_id="test_client",} 2.0

But, if this metric is not resetting and will keep on growing, it won't help me to create the alarm.

s-diez commented 1 year ago

Can't you just use the increase over a given time? For example the increase in the last 60 minutes.

increase(keycloak_failed_login_attempts{realm="5f59671b-ef3d-4919-b1a9-ce35503320a1",provider="keycloak",error="invalid_user_credentials",client_id="test_client",}[60m])