Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keycloak 25 / keycloakx - ServiceMonitor does not work with default port property #796

Open
maximilian-krauss opened this issue Sep 18, 2024 · 9 comments

Comments

@maximilian-krauss
Copy link

maximilian-krauss commented Sep 18, 2024

Heyho,
after the upgrade to Keycloak 25 and Chartversion 2.5.1 we are not getting any metrics via the Prometheus Operator.

We noticed that since Keycloak 25 metrics are being exposed only on Port 9000. We had to change port in the ServiceMonitor to targetPort in order to make it work.

Unfortunately it is not possible to overwrite this property in this chart. But before sending a PullRequest to change it here I want to ask if someone is able to pull the metrics with the default chart configuration?

@maximilian-krauss maximilian-krauss changed the title Keycloak 25 - ServiceMonitor does not work with new http-internal port Keycloak 25 - ServiceMonitor does not work with default port property Sep 18, 2024
@maximilian-krauss maximilian-krauss changed the title Keycloak 25 - ServiceMonitor does not work with default port property Keycloak 25 / keycloakx - ServiceMonitor does not work with default port property Sep 18, 2024
@Tim-Schwalbe
Copy link

Tim-Schwalbe commented Sep 20, 2024

No, I just have the same problem. I don't get any metrics and not the UP metric. Where do you change to port to targetPort?

@maximilian-krauss
Copy link
Author

Hah, if it's not just us, then I will send a PR to fix it 🙂

I changed it directly via kubectl in the ServiceMonitor after the helm deployment.

You need to replace port with targetPort and then it should work after a few minutes.

@Tim-Schwalbe
Copy link

Tim-Schwalbe commented Sep 20, 2024

It's not working for me this way. I get the Up Metrics now, but somehow it's always 0, but keycloak started and all seems to work.

@Tim-Schwalbe
Copy link

Tim-Schwalbe commented Sep 20, 2024

okay I think I see the problem here. The service is not even listening to port http-internal aka 9000. So I had to extend the service-http.yaml

but I am really asking myself how it could work for you @maximilian-krauss

  ports:
    - name: '{{ .Values.http.internalPort }}'
      port: 9000
      protocol: TCP
      targetPort: '{{ .Values.http.internalPort }}' 

@maximilian-krauss
Copy link
Author

That's weird. Does it work with the port property on the service monitor after you added the port to the service?

As far as I understood that's the difference between port and targetPort:
CleanShot 2024-09-20 at 12 44 48@2x
from: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#endpoint

By using targetPort in the service monitor it uses the pod to get metrics, port tries to use the service.

I will also try on my setup which combination works, if it's the service its easy to add via the 'extraPorts' property

@Tim-Schwalbe
Copy link

Tim-Schwalbe commented Sep 20, 2024

Yes once I added the port to the service it worked. I am just tried with targetPort and it's also working :D
So both is fine! I think I will go with the targetPort Version. Looks cleaner for me. I think I had also to fix my networkpolicies that's why it was not working in the first place.

@maximilian-krauss
Copy link
Author

The additional port in the service alone did the trick. Thanks for pointing that out 👍

Copy link

This issue has been marked as stale because it has been open for 30 days with no activity. It will be automatically closed in 10 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Nov 20, 2024
@maximilian-krauss
Copy link
Author

Do not close - issue is still relevant until #798 has been merged

@github-actions github-actions bot removed the Stale label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants