@pulumi/awsx
Version:
[](https://github.com/pulumi/pulumi-awsx/actions) [](https://slack.pulumi.com) [;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.metrics = void 0;
const cloudwatch = __importStar(require("../cloudwatch"));
var metrics;
(function (metrics) {
/**
* Creates an AWS/CloudFront metric with the requested [metricName]. See
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/monitoring-using-cloudwatch.html
* for list of all metric-names.
*
* Note, individual metrics can easily be obtained without supplying the name using the other
* [metricXXX] functions.
*
* CloudFront metrics use the CloudFront namespace and provide metrics for two dimensions:
*
* 1. "DistributionId": The CloudFront ID of the distribution for which you want to display metrics.
* 2. "Region": The region for which you want to display metrics. This value must be Global. The
* Region dimension is different from the region in which CloudFront metrics are stored, which is
* US East (N. Virginia).
*/
function metric(metricName, change = {}) {
const dimensions = {};
if (change.distribution !== undefined) {
dimensions.DistributionId = change.distribution.id;
}
if (change.region !== undefined) {
dimensions.Region = change.region;
}
return new cloudwatch.Metric({
namespace: "AWS/CloudFront",
name: metricName,
...change,
}).withDimensions(dimensions);
}
/**
* The number of requests for all HTTP methods and for both HTTP and HTTPS requests.
*
* Valid Statistics: Sum
* Units: None
*/
function requests(change) {
return metric("Requests", { statistic: "Sum", unit: "None", ...change });
}
metrics.requests = requests;
/**
* The number of bytes downloaded by viewers for GET, HEAD, and OPTIONS requests.
*
* Valid Statistics: Sum
* Units: None
*/
function bytesDownloaded(change) {
return metric("BytesDownloaded", { statistic: "Sum", unit: "None", ...change });
}
metrics.bytesDownloaded = bytesDownloaded;
/**
* The number of bytes uploaded to your origin with CloudFront using POST and PUT requests.
*
* Valid Statistics: Sum
* Units: None
*/
function bytesUploaded(change) {
return metric("BytesUploaded", { statistic: "Sum", unit: "None", ...change });
}
metrics.bytesUploaded = bytesUploaded;
/**
* The percentage of all requests for which the HTTP status code is 4xx or 5xx.
*
* Valid Statistics: Average
* Units: Percent
*/
function totalErrorRate(change) {
return metric("TotalErrorRate", { statistic: "Average", unit: "Percent", ...change });
}
metrics.totalErrorRate = totalErrorRate;
/**
* The percentage of all requests for which the HTTP status code is 4xx.
*
* Valid Statistics: Average
* Units: Percent
*/
function errorRate4xx(change) {
return metric("4xxErrorRate", { statistic: "Average", unit: "Percent", ...change });
}
metrics.errorRate4xx = errorRate4xx;
/**
* The percentage of all requests for which the HTTP status code is 5xx.
*
* Valid Statistics: Average
* Units: Percent
*/
function errorRate5xx(change) {
return metric("5xxErrorRate", { statistic: "Average", unit: "Percent", ...change });
}
metrics.errorRate5xx = errorRate5xx;
})(metrics || (exports.metrics = metrics = {}));
//# sourceMappingURL=metrics.js.map