aerogear / keycloak-metrics-spi

Adds a Metrics Endpoint to Keycloak
Apache License 2.0
560 stars 159 forks source link

no data #135

Open tirelibirefe opened 2 years ago

tirelibirefe commented 2 years ago

Name and Version

bitnami/keycloak:7.1.7

What steps will reproduce the bug?

Hello, This is my metrics configuration:

metrics:
  enabled: true
  service:
    ports:
      http: 9990
    annotations:
      prometheus.io/scrape: "true"
      prometheus.io/port: "{{ .Values.metrics.service.ports.http }}"
  serviceMonitor:
    enabled: true
    namespace: "monitoring"
    interval: 30s
    scrapeTimeout: ""
    labels: {}
    selector: {}
    relabelings: []
    metricRelabelings: []
    honorLabels: false
    jobLabel: ""

I see Keycloak can be scraped by Prometheus:

image

I uploaded following Grafana dashboard https://grafana.com/grafana/dashboards/10441

What is the expected behavior?

I expect to see Prometheus data can be read by Grafana.

What do you see instead?

image

...but Grafana cannot detect variables, data cannot be read, all graphs are empty:

image

Additional information

Could you please advise?

Thanks & Regards

pb82 commented 2 years ago

@tirelibirefe I believe you're using the wrong metrics URL. Your Prometheus config scrapes/metrics when it should look at /auth/realms/master/metrics

tirelibirefe commented 2 years ago

Hello @pb82 Thanks for your response.

My Keycloak installation/upgrade (helm) says:

...
You can access the Prometheus metrics following the steps below:

1. Get the Keycloak Prometheus metrics URL by running:
    kubectl port-forward --namespace keycloak svc/keycloak-metrics 9990:9990 &
    echo "Keycloak Prometheus metrics URL: http://127.0.0.1:9990/metrics"

2. Open a browser and access Keycloak Prometheus metrics using the obtained URL.

Also, when I curl /metrics, I get the output:

curl http://10.61.20.19:9990/metrics
...
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="clientSessions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="ejb",cache="http-remoting-connector"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="loginFailures"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="offlineClientSessions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="offlineSessions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="realmRevisions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="sessions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cac
...

Should I still need to change?

Thanks & Regards

Tim-Schwalbe commented 2 years ago

I have the same issue. The metrics mostly have none values, even when I trigger a specific event e.g. failed login. Can you maybe send a full list of your metrics from this endpoint?

ivosh commented 1 year ago

Hello @pb82 Thanks for your response.

My Keycloak installation/upgrade (helm) says:

...
You can access the Prometheus metrics following the steps below:

1. Get the Keycloak Prometheus metrics URL by running:
    kubectl port-forward --namespace keycloak svc/keycloak-metrics 9990:9990 &
    echo "Keycloak Prometheus metrics URL: http://127.0.0.1:9990/metrics"

2. Open a browser and access Keycloak Prometheus metrics using the obtained URL.

Also, when I curl /metrics, I get the output:

curl http://10.61.20.19:9990/metrics
...
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="clientSessions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="ejb",cache="http-remoting-connector"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="loginFailures"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="offlineClientSessions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="offlineSessions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="realmRevisions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cache="sessions"} 0.0
wildfly_infinispan_average_remove_time_seconds{cache_container="keycloak",cac
...

Should I still need to change?

Thanks & Regards

There are two kind of Prometheus metrics exposed:

I'd say you are interested in the latter.

ivosh commented 1 year ago

I have the same issue. The metrics mostly have none values, even when I trigger a specific event e.g. failed login. Can you maybe send a full list of your metrics from this endpoint?

Response is here: https://github.com/aerogear/keycloak-metrics-spi/issues/139#issuecomment-1450787973