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

AWS Cloudwatch Scaler, do nothing on empty metric data received #5352

Open
robpickerill opened this issue Jan 5, 2024 · 9 comments · May be fixed by #5635 or kedacore/keda-docs#1346
Open

AWS Cloudwatch Scaler, do nothing on empty metric data received #5352

robpickerill opened this issue Jan 5, 2024 · 9 comments · May be fixed by #5635 or kedacore/keda-docs#1346
Labels
feature-request All issues for new features that have not been committed to needs-discussion stale All issues that are marked as stale due to inactivity

Comments

@robpickerill
Copy link

robpickerill commented Jan 5, 2024

Proposal

Is there a way to do nothing when an empty metric response is returned from AWS CloudWatch? The current behaviour appears to be to return the minMetricValue, but would it be possible to do nothing in this case? I may of overlooked the option for this though

https://github.com/kedacore/keda/blob/main/pkg/scalers/aws_cloudwatch_scaler.go#L385-L386

Happy to implement this if functionality doesn't exist in the current AWS CloudWatch scaler options.

Use-Case

We are experimenting with the AWS Scaler and custom metrics. The use case here is when the system producing metrics is offline and unable to produce metrics, we would want no scaling actions to take place.

Is this a feature you are interested in implementing yourself?

Yes

Anything else?

No response

@robpickerill robpickerill added feature-request All issues for new features that have not been committed to needs-discussion labels Jan 5, 2024
@zroubalik
Copy link
Member

Hi @robpickerill could you please draft here the empty response? It is a null or empty array and it is something that is expected from CloudWatch? Also, what is the value that should be reported in this case?

@robpickerill
Copy link
Author

robpickerill commented Jan 8, 2024

Hi, thanks for the follow up @zroubalik.

It is an empty response, so in this case, there are no metrics being returned from the GetMetricData call. We fall into this branch: https://github.com/kedacore/keda/blob/main/pkg/scalers/aws_cloudwatch_scaler.go#L386, as the MetricDataResults has zero length.

The wider scenario here is that another system is producing custom metrics, by which a ScaledObject is being used to query that metric and scale a separate system, which is a deployment, to the relevant capacity. In the case whereby the system producing the custom metrics is offline, no metrics are being returned from the GetMetricData call. In this scenario, no metrics in the GetMetricData call is normal behaviour from CloudWatch.

What I wanted to guard against in this scenario is further scaling activity. I'd like the deployment to remain at the current scale. From what I've observed, in the case whereby a single AWS CloudWatch scaler exists, the deployment will scale down to the largest value of the minReplicaCount, or the evaluation of the minMetricValue in the scaling policy.

I don't know if this is a viable approach, but one way I could see working from what I understand so far is to have an option on the AWS CloudWatch scaler to handle an empty result as an error. Thus marking that scaler/trigger in an error state. This option would therefore be mutually exclusive to the minMetricValue option.


Edit: if you'd want to inspect the GetMetricData json payload here to understand further, I can share some example responses with you tomorrow.

Copy link

stale bot commented Mar 8, 2024

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.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Mar 8, 2024
Copy link

stale bot commented Mar 16, 2024

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Mar 16, 2024
@zroubalik zroubalik reopened this Mar 27, 2024
@stale stale bot removed the stale All issues that are marked as stale due to inactivity label Mar 27, 2024
@zroubalik
Copy link
Member

Sorry for the delay, I missed the reply somehow.

Having an option setting that would allow AWS CloudWatch scaler to handle an empty result as an error is okay with me. We just need to be backwards compatible.

@robpickerill
Copy link
Author

Thanks @zroubalik -- just to check, would the backwards compatibility be enough to add a new metadata option for the cloudwatch scaler: errorWhenMetricValuesEmpty, that's optional, and defaults to false to maintain previous behaviour if the user supplies no options when upgrading?

@zroubalik
Copy link
Member

Thanks @zroubalik -- just to check, would the backwards compatibility be enough to add a new metadata option for the cloudwatch scaler: errorWhenMetricValuesEmpty, that's optional, and defaults to false to maintain previous behaviour if the user supplies no options when upgrading?

Yes, that's enough :)

@robpickerill
Copy link
Author

Thanks, you can assign this to me, I'll send over a PR for review soon

@robpickerill robpickerill linked a pull request Mar 28, 2024 that will close this issue
7 tasks
Copy link

stale bot commented May 27, 2024

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.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request All issues for new features that have not been committed to needs-discussion stale All issues that are marked as stale due to inactivity
Projects
Status: Proposed
2 participants