Skip to content

Commit

Permalink
Adds additional metrics for many other packages. (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Apr 11, 2019
1 parent 839c6ce commit 69f889f
Show file tree
Hide file tree
Showing 34 changed files with 2,882 additions and 1 deletion.
47 changes: 47 additions & 0 deletions resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -1875,18 +1875,44 @@ func Provider() tfbridge.ProviderInfo {
"utils.ts", // Helpers,
},
Modules: map[string]*tfbridge.OverlayInfo{
"acmpca": {
DestFiles: []string{
"metrics.ts",
},
},
"apigateway": {
DestFiles: []string{
"metrics.ts",
},
},
"autoscaling": {
DestFiles: []string{
"metrics.ts", // Metric and MetricsGranularity union types and constants
"notificationType.ts", // NotificationType union type and constants
},
},
"cloudfront": {
DestFiles: []string{
"metrics.ts",
},
},
"cloudwatch": {
DestFiles: []string{
"cloudwatchMixins.ts",
"eventRuleMixins.ts",
"logGroupMixins.ts",
"metric.ts",
"metrics.ts",
},
},
"codebuild": {
DestFiles: []string{
"metrics.ts",
},
},
"cognito": {
DestFiles: []string{
"metrics.ts",
},
},
"config": {
Expand All @@ -1897,6 +1923,12 @@ func Provider() tfbridge.ProviderInfo {
"dynamodb": {
DestFiles: []string{
"dynamodbMixins.ts",
"metrics.ts",
},
},
"ebs": {
DestFiles: []string{
"metrics.ts",
},
},
"ec2": {
Expand All @@ -1905,11 +1937,18 @@ func Provider() tfbridge.ProviderInfo {
"instancePlatform.ts", // InstancePlatform union type and constants
"placementStrategy.ts", // PlacementStrategy union type and constants
"tenancy.ts", // Tenancy union type and constants
"metrics.ts",
},
},
"ecs": {
DestFiles: []string{
"container.ts", // Container definition JSON schema
"metrics.ts",
},
},
"efs": {
DestFiles: []string{
"metrics.ts",
},
},
"iam": {
Expand All @@ -1931,10 +1970,16 @@ func Provider() tfbridge.ProviderInfo {
"metrics.ts",
},
},
"rds": {
DestFiles: []string{
"metrics.ts",
},
},
"s3": {
DestFiles: []string{
"cannedAcl.ts", // a union type and constants for canned ACL names.
"s3Mixins.ts",
"metrics.ts",
},
},
"serverless": {
Expand All @@ -1945,12 +1990,14 @@ func Provider() tfbridge.ProviderInfo {
"sns": {
DestFiles: []string{
"snsMixins.ts",
"metrics.ts",
},
},
"sqs": {
DestFiles: []string{
"redrive.ts", // schema definitions for SQS redrive policies.
"sqsMixins.ts",
"metrics.ts",
},
},
},
Expand Down
1 change: 1 addition & 0 deletions sdk/nodejs/acmpca/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
// Export members:
export * from "./certificateAuthority";
export * from "./getCertificateAuthority";
export * from "./metrics";
76 changes: 76 additions & 0 deletions sdk/nodejs/acmpca/metrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2016-2018, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// 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.

import * as pulumi from "@pulumi/pulumi";
import * as cloudwatch from "../cloudwatch";

export module metrics {
export type AcmpcaMetricName =
"CRLGenerated" | "MisconfiguredCRLBucket" | "Time" | "Success" | "Failure";

/**
* Creates an AWS/ACMPrivateCA metric with the requested [metricName]. See
* https://docs.aws.amazon.com/acm-pca/latest/userguide/PcaCloudWatch.html for list of all
* metric-names.
*
* Note, individual metrics can easily be obtained without supplying the name using the other
* [metricXXX] functions.
*/
export function metric(metricName: AcmpcaMetricName, change: cloudwatch.MetricChange = {}) {
return new cloudwatch.Metric({
namespace: "AWS/ACMPrivateCA",
name: metricName,
...change,
});
}

/**
* A certificate revocation list (CRL) was generated. This metric applies only to a private CA.
*/
export function crlGenerated(change: cloudwatch.MetricChange) {
return metric("CRLGenerated", change);
}

/**
* The S3 bucket specified for the CRL is not correctly configured. Check the bucket policy. This
* metric applies only to a private CA.
*/
export function misconfiguredCRLBucket(change?: cloudwatch.MetricChange) {
return metric("MisconfiguredCRLBucket", change);
}

/**
* The time at which the certificate was issued. This metric applies only to the
* [IssueCertificate](https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_IssueCertificate.html)
* operation.
*/
export function time(change?: cloudwatch.MetricChange) {
return metric("Time", change);
}

/**
* Specifies whether a certificate was successfully issued. This metric applies only to the
* IssueCertificate operation.
*/
export function success(change?: cloudwatch.MetricChange) {
return metric("Success", change);
}

/**
* Indicates that an operation failed. This metric applies only to the IssueCertificate operation.
*/
export function failure(change?: cloudwatch.MetricChange) {
return metric("Failure", change);
}
}
1 change: 1 addition & 0 deletions sdk/nodejs/apigateway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export * from "./integrationResponse";
export * from "./method";
export * from "./methodResponse";
export * from "./methodSettings";
export * from "./metrics";
export * from "./model";
export * from "./requestValidator";
export * from "./resource";
Expand Down
126 changes: 126 additions & 0 deletions sdk/nodejs/apigateway/metrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Copyright 2016-2018, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// 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.

import * as pulumi from "@pulumi/pulumi";
import * as cloudwatch from "../cloudwatch";

export module metrics {
export type ApigatewayMetricName =
"4XXError" | "5XXError" | "CacheHitCount" | "CacheMissCount" |
"Count" | "IntegrationLatency" | "Latency";

/**
* Creates an AWS/ApiGateway metric with the requested [metricName]. See
* https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-metrics-and-dimensions.html
* for list of all metric-names.
*
* Note, individual metrics can easily be obtained without supplying the name using the other
* [metricXXX] functions.
*
* You can use the dimensions in the following table to filter API Gateway metrics.
*
* 1. "ApiName": Filters API Gateway metrics for an API of the specified API name.
* 2. "ApiName, Method, Resource, Stage": Filters API Gateway metrics for an API method of the
* specified API, stage, resource, and method.
*
* API Gateway will not send such metrics unless you have explicitly enabled detailed CloudWatch
* metrics. You can do this in the console by selecting Enable CloudWatch Metrics under a stage
* Settings tab. Alternatively, you can call the stage:update action of the API Gateway REST API
* to update the metricsEnabled property to true.
*
* Enabling such metrics will incur additional charges to your account. For pricing information,
* see Amazon CloudWatch Pricing.
* 3. "ApiName, Stage": Filters API Gateway metrics for an API stage of the specified API and stage.
*/
export function metric(metricName: ApigatewayMetricName, change: cloudwatch.MetricChange = {}) {
return new cloudwatch.Metric({
namespace: "AWS/ApiGateway",
name: metricName,
...change,
});
}

/**
* The number of client-side errors captured in a specified period.
*
* The Sum statistic represents this metric, namely, the total count of the 4XXError errors in the
* given period. The Average statistic represents the 4XXError error rate, namely, the total count
* of the 4XXError errors divided by the total number of requests during the period. The denominator
* corresponds to the Count metric (below).
*/
export function error4XX(change: cloudwatch.MetricChange = {}) {
return metric("4XXError", { unit: "Count", ...change });
}

/**
* The number of server-side errors captured in a given period.
*
* The Sum statistic represents this metric, namely, the total count of the 5XXError errors in the
* given period. The Average statistic represents the 5XXError error rate, namely, the total count
* of the 5XXError errors divided by the total number of requests during the period. The denominator
* corresponds to the Count metric (below).
*/
export function error5XX(change: cloudwatch.MetricChange = {}) {
return metric("5XXError", { unit: "Count", ...change });
}

/**
* The number of requests served from the API cache in a given period.
*
* The Sum statistic represents this metric, namely, the total count of the cache hits in the
* specified period. The Average statistic represents the cache hit rate, namely, the total count of
* the cache hits divided by the total number of requests during the period. The denominator
* corresponds to the Count metric (below).
*/
export function cacheHitCount(change: cloudwatch.MetricChange = {}) {
return metric("CacheHitCount", { unit: "Count", ...change });
}

/**
* The number of requests served from the back end in a given period, when API caching is enabled.
*
* The Sum statistic represents this metric, namely, the total count of the cache misses in the
* specified period. The Average statistic represents the cache miss rate, namely, the total count
* of the cache hits divided by the total number of requests during the period. The denominator
* corresponds to the Count metric (below).
*/
export function cacheMissCount(change: cloudwatch.MetricChange = {}) {
return metric("CacheMissCount", { unit: "Count", ...change });
}

/**
* The total number API requests in a given period.
*
* The SampleCount statistic represents this metric.
*/
export function count(change: cloudwatch.MetricChange = {}) {
return metric("Count", { unit: "Count", ...change });
}

/**
* The time between when API Gateway relays a request to the back end and when it receives a
* response from the back end.
*/
export function integrationLatency(change: cloudwatch.MetricChange = {}) {
return metric("IntegrationLatency", { unit: "Milliseconds", ...change });
}

/**
* The time between when API Gateway receives a request from a client and when it returns a response
* to the client. The latency includes the integration latency and other API Gateway overhead.
*/
export function latency(change: cloudwatch.MetricChange = {}) {
return metric("Latency", { unit: "Milliseconds", ...change });
}
}
Loading

0 comments on commit 69f889f

Please sign in to comment.