Łukasz
Łukasz

Reputation: 2162

Cloudwatch generates a lot of costs due to large number of PutMetricData requests

cost-wise, the majority of our invoice comes from PutMetricData. I can't really see which piece sends that huge amount. According to https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/logging_cw_api_calls.html, cloud trail does not trace it. I am looking for some sort of a sum-up to find out where all that requests come from.

Any help will be appreciated, thanks in advance

EDIT attaching API cost spreadout enter image description here

Upvotes: 0

Views: 1343

Answers (1)

guest
guest

Reputation: 11

When you say "the majority of our invoice," do you mean that CloudWatch metrics cost more than or a significant percentage of all of the other AWS services that you use?

This is extremely surprising: you can call PutMetricData 100,000 times for $1, so your usage numbers must be astronomical (calling once per second is only 86,400 per day). So surprising that I have to ask are you sure that it's the API calls that are running up the cost, and not the number of metrics? (and are you aware that each combination of dimensions represents a distinct metric?)

If it really is the number of PutMetricData calls, then the only way that you could accumulate those numbers is to be making a call from within a loop -- one that executes many times per second. So I would start by using your IDE (or grep) to find all references to the SDK function, and determining which of those is called in a loop.

There are very few reasons to call PutMetricData from within a loop, unless you expect the body of the loop to take a significant amount of time (seconds to minutes) and are using metrics to track the amount of time this takes.

Upvotes: 1

Related Questions