Nadi Hassan Hassan
Nadi Hassan Hassan

Reputation: 142

CloudFront usage through PHP

I want to monitor how much bandwidth is being used for a time period for each distribution programmatically - Is there any way I can make an API call through PHP to CF and/or CloudWatch to get this value ?

Upvotes: 0

Views: 484

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179364

CloudFront exposes several metrics through CloudWatch.

Specifically, the metrics are Requests (the count of requests), BytesDownloaded, BytesUploaded, TotalErrorRate (percentage of requests with 4xx/5xx HTTP responses combined together), and 4xxErrorRate/5xxErrorRate for the 4xx/5xx HTTP error classes tallied separately.

GetMetricStatistics in the PHP SDK V3 for AWS allows you to fetch the collected data from CloudWatch via the API. You can, according to the docs, fetch up to 1,440 data points.

If you are using the older V2 SDK for PHP it offers getMetricStatistics to interact with CloudWatch, as well.

Upvotes: 1

Related Questions