-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
postgres scaler uses full connection string in metric name #1200
Comments
@ycabrer we are doing this, because we need a way how to generate unique Metric Name for each Trigger in the ScaledObject. Do you have any idea how to modify that part to not contain full connection string, but the resulting Metric Name is unique (and always the same for the same Trigger?). |
@zroubalik That makes sense, I don't think it will work though if multiple triggers use the same connection string. Two triggers with separate queries and the same connection will end up with the same name. What would be truly unique is somehow a combination of the query being used, database host, and name. A hash value? That's not very human friendly. Ideally, the metric name would be easy to identify and correlate with the trigger. Maybe this isn't a problem Keda should be trying to solve programmatically. The Prometheus scaler allows you to define a metric name. Like Postgres, Prometheus can potentially have many triggers associated with the same host. I think the same approach should be taken here and have it documented that it must be unique. |
@ycabrer yeah, that's true. We were thinking about this and the benefit is, that user don't have to care about this setting (as it is KEDA internal only) and another point is, that other scalers solve this programatically as well, so we have the same experience for all scalers. Looking at the code, you are right about the the connection setting and uniqueness, we should fix that first, so it is a combination of both, so it is not broken and than we can try to find a solution for this particular issue (maybe a combination of hashed connection string + query?) |
Issue 1 (Password in Metric Name): Issue 2 (Uniqueness of Metric Name): I can't think of a better way without adding a metric name field to Postgres metadata struct like the Prometheus scaler. It is kind of a pain though to make a change like that after v2 Keda scaler has already been defined. |
Let me know your thoughts. I can't seem to get out of my thought loop. There might be a better way. |
@ycabrer sorry for the delay. It seems like you are right, for Postres scaler it would make sense to add a metric name field the same way it has been added to Prometheus, as both scalers are based on a long query. And we cannot assure uniqueness from the other fields, am I right? To mitigate the problems with changing the scaler API, we could do:
wdyt? |
@zroubalik That's a good idea! I will open a PR for the metric name issue. I will also look into the reconciler loop check. |
@zroubalik Is this what you were thinking of for the metric name uniqueness check? It only checks for uniqueness within the same ScaledObject. |
@ycabrer yeah that's exactly what I was thinking about :) |
@ycabrer just checking the status. Are you planning to open another PR with the check, please? Or should we track it in some issue as something that's needs to be done. Thanks :) |
@zroubalik Yes! Let me add a couple of tests for it first and update the changelog/docs. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed due to inactivity. |
The metric name is exposing the full connection string as the metric name. Ideally, we wouldn't have a metric name with the credentials and URL to hit postgres.
Expected Behavior
A metric name that does not expose DB credentials
Actual Behavior
A metric name that exposes DB credentials
Steps to Reproduce the Problem
s.metadata.connection
definedExternal Metric Names
statuskeda/pkg/scalers/postgresql_scaler.go
Line 186 in 934d309
Specifications
The text was updated successfully, but these errors were encountered: