-
Notifications
You must be signed in to change notification settings - Fork 545
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
Feature Proposal: Allow External Metrics to return metrics for a different namespace #324
Comments
I have a very similar use case, and I wonder if there is any workaround for this !. |
@h4ckroot There is! I have already written code to do this. But I want to make sure that the proposed design is acceptable to @DirectXMan12 |
I'd also be interested in something exactly like this, and am curious if there's a workaround until your code lands. I've tried several things over the last day or so: I wondered if I could use a cluster-scoped CRD as the target of a custom metric, but so far nothing seems to have worked out. |
@carsonoid (note: I took over maintainership of prometheus-adapter): agreed I think we need to support the use cases of non-namespace bound external metrics better in prometheus-adapter. Your solution (I think) though relies on underlying metrics to have a namespace present as a label. However, if we want to support non-namespaced metrics isn't it legit to demand from the underlying label that it doesn't have a namespace label too? Taking
And we would leave the adapter to decide the implementation details. More formally it would: cc @dgrisonnet |
I agree with @s-urbaniak here, external metrics may not have a namespace label present so we would still end up with the same issue. The reason why metrics from different namespaces are not scrapable right now lies down to the namespace label being enforced by the adapter from the HPA query. Introducing a way to drop it, would allow both supporting external metrics from different namespaces and external metrics not having a namespace label. |
@dgrisonnet that's a good idea. My only concern is that it could be a bit confusing. AFAIK, the only place we can pass information to the adapter is in the labels of the metric query, which would also be where we would set the
That would absolutely work. But might be a bit confusing to say "ignore the namespace" and then also have a "namespace" key. This is a minor gripe though, and could be solved with a better label key or value. Label key/value ideas:
Those are just off the top of my head, I would be interested in other proposals. |
Not exactly, I meant to drop the enforcement by setting You would end up with the following adapter and HPA configurations:
|
Oh! Yeah that makes a lot more sense and would be much cleaner.
I can take a run at a PR for it if you want. It would get me closer to not
needing a fork of the adapter to handle my autoscaling configuration.
…On Tue, Nov 3, 2020 at 9:02 AM Damien Grisonnet ***@***.***> wrote:
Not exactly, I meant to drop the enforcement by setting namespaced: false
in the adapter config as @s-urbaniak <https://github.com/s-urbaniak>
suggested. From the adapter perspective, that would mean that the external
metric is accepted from all namespaces.
Then, if the metrics needed by your HPA need to be selected with a
specific namespace label value, nothing prevents you from setting it in the
HPA's label selector.
You would end up with the following adapter and HPA configurations:
externalRules:
- seriesQuery: 'nsq_topic_depth'
resources:
namespaced: false
- type: External
external:
metric:
name: nsq_topic_depth
selector:
labelSelector:
topic: my-topic
namespace: nsq
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#324 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWV6SI5BKK7L35J3S6RYFDSOASSLANCNFSM4SFJ74CA>
.
|
@carsonoid @dgrisonnet thank you for the great discussion! Yes @carsonoid if you want to contribute, that would be great! Side note: as we are in the process of moving this repository to kubernetes-sigs, do you mind to sign the CNCF CLA as described in kubernetes/org#2182 (comment) ? (If you haven't done already) |
Just to sum up, enforcing the namespace for this scenario can be achieved imho in many ways:
|
Oh! Yeah the recording rule is an interesting idea. Those should probably all be in a "dealing with namespaces" section in the docs. |
Hello, I have a similar problem - we have our external metrics work across many namespaces, based only on labels. Is there currently any workarounds that allow to achieve this? |
I ran in to this exact issue as well, caused a lot of headscratching as to why all of my HPAs suddenly stopped working when I upgraded from 0.5.0 to 0.6.0. Since #197 was listed as a BUGFIX in the changelog I didn't pay attention, and didn't realise I was relying on a bug for all of my production scaling >.< . This is a critical feature for us and I will have to stay on 0.5.0 until we figure something out in this thread. Happy to help in any way I can to move this along. |
Hello @fxposter, unfortunately there is no workaround for this. The only way to allow external metrics to work across different namespaces would be to implement the feature mentioned above. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
/remove-lifecycle stale |
It seems to me that "external metrics" should be In fact, specifying I have a use case that requires external metrics. I can get it working for a singular namespace by hardcoding the namespace in the prometheus scraper rule as a label; but this is useless data added to the series that is 100% wrong, and actively misleading; and doing the same in a second namespace is impossible without duplicating the scraper and adapter rules. |
I think @leviathanbadger you have a good point indeed 🤔 having said that my intuition is that we should leave the choice to the user whether external metrics are supposed to be namespaced or not. Hence, my suggestion would be, instead of having this set implicitely, we could have the |
This used to be how this worked in 0.5.0; though perhaps that was a "bug". I'm only encountering this problem now that I'm trying to upgrade to the latest version. |
Fixed by #380 |
Issue
I have a single nsq installation in a K8s namespace named
nsq
. But I have many deployments in different namespaces that need to autoscale using a topic and/or channel depth from the central installation.The external metrics proposal requires that a namespace is in the path. And the HPA will always put it's own namespace into the external metrics query.
This makes it impossible to use the adapter to scale a pod based on metrics from a different namespace than the HPA.
Proposed Solution
Allow a special target label (
metrics_target_namespace
) to override the namespace that will be used in the Prometheus query.Example HPA:
So with the example above, even though the HPA is in the
example
namespace. It will scale based on the topic in thensq
namespace. This simple override allows much greater flexibility for metrics while still fitting withing the Kubernetes API spec.I have a fork of the adapter with this code running in production and would be happy to upstream the changes if the feature proposal is accepted. I have only implemented the change in
external
metrics but it could also be implemented for all the other metric providers supported by the adapter.The text was updated successfully, but these errors were encountered: