A while ago, we wrote an article where we presented a library written by us that could help you reducing the CloudWatch bill based on a very simple idea: since you are charged per number of API calls, publish metrics in batches instead of publish them one by one.
In the initial release of that library, the channel used to send metrics from producer (your application) to consumer (component that batches metrics and send them to CloudWatch) was a simple queue. This approach has the advantage of being very fast, but one very important minus: it is not tolerant to CloudWatch failures, resulting in loss of records.
To address this, we launched a new version that uses text files as channel between your application and metrics publisher. Records are serialized in these files from where are read and if call to CW is done with success, some file records are updated. Next time that text file is read, records that have been submitted are skipped. In the end, after a period, that text file is deleted from disk. For more details, check the library documentation available here.
If you have any question or idea how to improve this library, write a comment below. If you notice any bug in our library, let is know and we’ll try to fix it as soon as possible.