diff --git a/webapp/src/main/java/org/apache/atlas/web/security/AtlasKeycloakAuthenticationProvider.java b/webapp/src/main/java/org/apache/atlas/web/security/AtlasKeycloakAuthenticationProvider.java index 367839b82a..40b9fba612 100644 --- a/webapp/src/main/java/org/apache/atlas/web/security/AtlasKeycloakAuthenticationProvider.java +++ b/webapp/src/main/java/org/apache/atlas/web/security/AtlasKeycloakAuthenticationProvider.java @@ -16,6 +16,8 @@ */ package org.apache.atlas.web.security; +import io.micrometer.core.instrument.Counter; +import org.apache.atlas.service.metrics.MetricUtils; import org.apache.atlas.ApplicationProperties; import org.apache.commons.configuration.Configuration; import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider; @@ -66,6 +68,11 @@ public Authentication authenticate(Authentication authentication) { } } + if(authentication.getName().startsWith("service-account-apikey")) { + // Increment the counter when the authentication is for a service account. + Counter.builder("service_account_apikey_request_counter").register(MetricUtils.getMeterRegistry()).increment(); + } + return authentication; }