Skip to main content
Version: NG-2.16

Keycloak

Introduction

Keycloak is an open-source Identity and Access Management (IAM) solution developed by Red Hat. It provides authentication, authorization, and user management capabilities for web applications and services. Keycloak is built on top of widely used standards such as OAuth 2.0, OpenID Connect, and SAML.

Getting Started

Compatibility

Keycloak O11ySource is compatible with Keycloak version 22.0.5, and metrics are collected through the Prometheus endpoint.

Data Collection Method

vuSmartMaps collects health and performance data for Keycloak using VuNet's Internal Data Collector.

Prerequisites

Inputs for Configuring Data Source

  • Keycloak Server: The IP Address/FQDN of the Keycloak server. This field is the key to identify each server you add here.
  • Period (in seconds): How frequently data is gathered. period should be between 60 seconds – 3000 seconds.
  • URL: The base server URL of the Keycloak instance (host and port only, no path). Used to collect global JVM/process metrics from <URL>/metrics and, when Realms are specified below, realm metrics from <URL>/realms/<realm>/metrics. Eg: http://127.0.0.1:8080 or https://127.0.0.1:8443
  • Realm: Realm name to collect realm-specific metrics for (e.g. master,demo). Leave blank to skip realm-level metrics.

Firewall Requirement

To collect data from this O11ySource, ensure the following ports are opened:

Source IPDestination IPDestination PortProtocolDirection
vuSmartMaps IPKeycloak Server8080*TCPOutbound

*Before providing the firewall requirements, please update the port based on the customer environment.

Configuring the Target

Health and Performance metrics from prometheus endpoint. User has to add the Keycloak Metrics SPI - a Service Provider that adds a metrics endpoint to Keycloak. This endpoint returns metrics data ready to be scraped by Prometheus. Please click here to download the keycloak-metrics-spi-5.0.0.jar.

Steps to Install the Keycloak Metrics SPI JAR

Follow the steps below to install and enable the Keycloak Metrics SPI plugin: 1.Download the keycloak-metrics-spi-5.0.0.jar file from the Aerogear GitHub releases page: 2.Mount or copy the downloaded JAR file to the Keycloak providers directory. 3.Restart the Keycloak service or pod for the plugin changes to take effect. 4.Enable the metrics-listener event listener for each required realm using the Keycloak Admin API.

Once these steps are completed, Keycloak will be ready to expose metrics through the installed Metrics SPI plugin.

Two distinct providers are defined:

  • MetricsEventListener to record the internal Keycloak events
  • MetricsEndpoint to expose the data through a custom endpoint

The endpoint is available under <base url>/realms/<realm>/metrics (Quarkus). It will return data for all realms.

Configuration Steps

  • Enable the O11ySource.
  • Select the sources tab and press the + button to add a new instance that has to be monitored.
  • Provide the required configurations:
  • *Keycloak Server
  • *Period (in seconds)
  • *URL
  • Click Save to close the data source window.

Metrics Collected

NameDescriptionData Type
@timestampTime when the metric was collected by TelegrafString
timestampPrecise time when the metric was collected (with milliseconds)DateTime64(3)
vublock_nameName of the VU block in KeycloakLowCardinality(String)
targetTarget system or service being monitoredString
hostName or IP of the Keycloak instance hostString
tenant_idID of the tenant in KeycloakLowCardinality(String)
bu_idID of the business unit in KeycloakLowCardinality(String)
tags_hostHost-related tags in the context of the Keycloak environmentString
tags_poolTags representing the connection pool used by KeycloakLowCardinality(String)
tags_gcTags related to garbage collection within KeycloakLowCardinality(String)
tags_runtimeTags indicating the runtime environment of KeycloakLowCardinality(String)
tags_urlTags related to the URL being accessed in KeycloakLowCardinality(String)
tags_areaTags defining different areas or domains within KeycloakLowCardinality(String)
tags_stateTags related to the state of Keycloak components or servicesLowCardinality(String)
tags_realmTags identifying the realm in KeycloakLowCardinality(String)
tags_resourceTags specifying the resource being accessed or protected in KeycloakLowCardinality(String)
tags_client_idID of the client in KeycloakLowCardinality(String)
tags_providerTags indicating the identity provider (IdP) used in KeycloakLowCardinality(String)
tags_methodHTTP method used in the Keycloak request (GET, POST, etc.)LowCardinality(String)
tags_codeHTTP status code returned by KeycloakLowCardinality(String)
tags_errorError returned by KeycloakLowCardinality(String)
tags_leLatency-related tags used to track Keycloak request durationsLowCardinality(String)
nameName of the specific Keycloak metricLowCardinality(String)
metric_nameIdentifier for the metric being collectedLowCardinality(String)
metric_valueThe actual value of the Keycloak metricFloat64
metric_value_diffDifference in metric value since the last collectionFloat64
tags_actionGC action reported for JVM garbage collection pauses (e.g. end of minor GC, end of major GC)LowCardinality(String)
tags_causeCause of the JVM garbage collection event (e.g. Allocation Failure, Ergonomics)LowCardinality(String)
tags_datasourceName of the Keycloak/Quarkus datasource connection pool (Agroal) the metric belongs toLowCardinality(String)
tags_idIdentifier of the JVM buffer pool or memory area the metric belongs to (e.g. direct, mapped, PS Eden Space)LowCardinality(String)
tags_pool_nameName of the Vert.x worker thread pool the metric belongs toLowCardinality(String)
tags_pool_typeType of the Vert.x worker thread pool (e.g. worker)LowCardinality(String)
tags_vendorJVM vendor running the Keycloak instance (e.g. Red Hat, Inc.)LowCardinality(String)
tags_versionJVM runtime version running the Keycloak instanceLowCardinality(String)
tags_nameName of the garbage collector reported by the JVM base GC metrics (e.g. PS MarkSweep, PS Scavenge)LowCardinality(String)