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

handle empty Cloudwatch metrics #34

Open
Mortinke opened this issue Sep 30, 2019 · 1 comment
Open

handle empty Cloudwatch metrics #34

Mortinke opened this issue Sep 30, 2019 · 1 comment

Comments

@Mortinke
Copy link
Contributor

Cloudwatch doesn't return values for some resource metrics if the resource was not used e.g. TargetResponseTime for AWS/ApplicationELB.

Elastic Load Balancing reports metrics to CloudWatch only when requests are flowing through the load balancer. If there are requests flowing through the load balancer, Elastic Load Balancing measures and sends its metrics in 60-second intervals. If there are no requests flowing through the load balancer or no data for a metric, the metric is not reported.

As a result, CloudWatchErrors are always thrown here if the resource is not used

[ERROR] 2019-09-29T18:50:04.383Z ff7065bb-29de-4073-a4f1-0a48bb5d6ea1 Error retreiving CloudWatch statistics, no datapoints found:
=> Namespace: AWS/ApplicationELB
=> MetricName: TargetResponseTime
=> Dimensions: [{'Name': 'TargetGroup', 'Value': 'targetgroup/ac-re-Targe-13P06UAEX2W9Y/f9002d01ab9053e0'}]
=> Period: 60
=> Statistics: ['Average']
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 94, in lambda_handler
services = gather_services(cluster_name, cluster_def)
File "/var/task/ecsautoscale/services.py", line 248, in gather_services
max_tasks=service["max"]
File "/var/task/ecsautoscale/services.py", line 89, in __init__
res = source.get_data(**item)
File "/var/task/ecsautoscale/metric_sources/cloudwatch.py", line 76, in get_data
namespace, metric_name, dimensions_, period, statistics_)
ecsautoscale.exceptions.CloudWatchError: Error retreiving CloudWatch statistics, no datapoints found:
=> Namespace: AWS/ApplicationELB
=> MetricName: TargetResponseTime
=> Dimensions: [{'Name': 'TargetGroup', 'Value': 'targetgroup/ac-re-Targe-13P06UAEX2W9Y/f9002d01ab9053e0'}]
=> Period: 60
=> Statistics: ['Average']
@Mortinke
Copy link
Contributor Author

a simple solution for this issue: #35

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

1 participant