Skip to content

Commit

Permalink
feat(aws-elasticloadbalancingv2): add metrics
Browse files Browse the repository at this point in the history
Add `metricsXxx()` methods to construct Metric objects for the metrics exposed
by Application and Network Load Balancers.

Fixes #853.
  • Loading branch information
rix0rrr committed Nov 14, 2018
1 parent cdebe2a commit 81c1617
Show file tree
Hide file tree
Showing 8 changed files with 702 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic
return new cloudwatch.Metric({
namespace: 'AWS/ApplicationELB',
metricName,
dimensions: { LoadBalancer: this.loadBalancerName },
dimensions: { LoadBalancer: this.fullName },
...props
});
}
Expand Down Expand Up @@ -156,6 +156,316 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic
...props
});
}

/**
* The number of load balancer capacity units (LCU) used by your load balancer.
*
* @default Sum over 5 minutes
*/
public metricConsumedLCUs(props?: cloudwatch.MetricCustomization) {
return this.metric('ConsumedLCUs', {
statistic: 'sum',
...props
});
}

/**
* The number of fixed-response actions that were successful.
*
* @default Sum over 5 minutes
*/
public metricHttpFixedResponseCount(props?: cloudwatch.MetricCustomization) {
return this.metric('HTTP_Fixed_Response_Count', {
statistic: 'Sum',
...props
});
}

/**
* The number of redirect actions that were successful.
*
* @default Sum over 5 minutes
*/
public metricHttpRedirectCount(props?: cloudwatch.MetricCustomization) {
return this.metric('HTTP_Redirect_Count', {
statistic: 'Sum',
...props
});
}

/**
* The number of redirect actions that couldn't be completed because the URL in the response location header is larger than 8K.
*
* @default Sum over 5 minutes
*/
public metricHttpRedirectUrlLimitExceededCount(props?: cloudwatch.MetricCustomization) {
return this.metric('HTTP_Redirect_Url_Limit_Exceeded_Count', {
statistic: 'Sum',
...props
});
}

/**
* The number of HTTP 3xx/4xx/5xx codes that originate from the load balancer.
*
* This does not include any response codes generated by the targets.
*
* @default Sum over 5 minutes
*/
public metricHttpCodeElb(code: HttpCodeElb, props?: cloudwatch.MetricCustomization) {
return this.metric(code, {
statistic: 'Sum',
...props
});
}

/**
* The number of HTTP 2xx/3xx/4xx/5xx response codes generated by all targets in the load balancer.
*
* This does not include any response codes generated by the load balancer.
*
* @default Sum over 5 minutes
*/
public metricHttpCodeTarget(code: HttpCodeTarget, props?: cloudwatch.MetricCustomization) {
return this.metric(code, {
statistic: 'Sum',
...props
});
}

/**
* The total number of bytes processed by the load balancer over IPv6.
*
* @default Sum over 5 minutes
*/
public metricIPv6ProcessedBytes(props?: cloudwatch.MetricCustomization) {
return this.metric('IPv6ProcessedBytes', {
statistic: 'Sum',
...props
});
}

/**
* The number of IPv6 requests received by the load balancer.
*
* @default Sum over 5 minutes
*/
public metricIPv6RequestCount(props?: cloudwatch.MetricCustomization) {
return this.metric('IPv6RequestCount', {
statistic: 'Sum',
...props
});
}

/**
* The total number of new TCP connections established from clients to the load balancer and from the load balancer to targets.
*
* @default Sum over 5 minutes
*/
public metricNewConnectionCount(props?: cloudwatch.MetricCustomization) {
return this.metric('NewConnectionCount', {
statistic: 'Sum',
...props
});
}

/**
* The total number of bytes processed by the load balancer over IPv4 and IPv6.
*
* @default Sum over 5 minutes
*/
public metricProcessedBytes(props?: cloudwatch.MetricCustomization) {
return this.metric('ProcessedBytes', {
statistic: 'Sum',
...props
});
}

/**
* The number of connections that were rejected because the load balancer had reached its maximum number of connections.
*
* @default Sum over 5 minutes
*/
public metricRejectedConnectionCount(props?: cloudwatch.MetricCustomization) {
return this.metric('RejectedConnectionCount', {
statistic: 'Sum',
...props
});
}

/**
* The number of requests processed over IPv4 and IPv6.
*
* This count includes only the requests with a response generated by a target of the load balancer.
*
* @default Sum over 5 minutes
*/
public metricRequestCount(props?: cloudwatch.MetricCustomization) {
return this.metric('RequestCount', {
statistic: 'Sum',
...props
});
}

/**
* The number of rules processed by the load balancer given a request rate averaged over an hour.
*
* @default Sum over 5 minutes
*/
public metricRuleEvaluations(props?: cloudwatch.MetricCustomization) {
return this.metric('RuleEvaluations', {
statistic: 'Sum',
...props
});
}

/**
* The number of connections that were not successfully established between the load balancer and target.
*
* @default Sum over 5 minutes
*/
public metricTargetConnectionErrorCount(props?: cloudwatch.MetricCustomization) {
return this.metric('TargetConnectionErrorCount', {
statistic: 'Sum',
...props
});
}

/**
* The time elapsed, in seconds, after the request leaves the load balancer until a response from the target is received.
*
* @default Average over 5 minutes
*/
public metricTargetResponseTime(props?: cloudwatch.MetricCustomization) {
return this.metric('TargetResponseTime', {
statistic: 'Average',
...props
});
}

/**
* The number of TLS connections initiated by the load balancer that did not establish a session with the target.
*
* Possible causes include a mismatch of ciphers or protocols.
*
* @default Sum over 5 minutes
*/
public metricTargetTLSNegotiationErrorCount(props?: cloudwatch.MetricCustomization) {
return this.metric('TargetTLSNegotiationErrorCount', {
statistic: 'Sum',
...props
});
}

/**
* The number of user authentications that could not be completed
*
* Because an authenticate action was misconfigured, the load balancer
* couldn't establish a connection with the IdP, or the load balancer
* couldn't complete the authentication flow due to an internal error.
*
* @default Sum over 5 minutes
*/
public metricElbAuthError(props?: cloudwatch.MetricCustomization) {
return this.metric('ELBAuthError', {
statistic: 'Sum',
...props
});
}

/**
* The number of user authentications that could not be completed because the
* IdP denied access to the user or an authorization code was used more than
* once.
*
* @default Sum over 5 minutes
*/
public metricElbAuthFailure(props?: cloudwatch.MetricCustomization) {
return this.metric('ELBAuthFailure', {
statistic: 'Sum',
...props
});
}

/**
* The time elapsed, in milliseconds, to query the IdP for the ID token and user info.
*
* If one or more of these operations fail, this is the time to failure.
*
* @default Average over 5 minutes
*/
public metricElbAuthLatency(props?: cloudwatch.MetricCustomization) {
return this.metric('ELBAuthLatency', {
statistic: 'Average',
...props
});
}

/**
* The number of authenticate actions that were successful.
*
* This metric is incremented at the end of the authentication workflow,
* after the load balancer has retrieved the user claims from the IdP.
*
* @default Sum over 5 minutes
*/
public metricElbAuthSuccess(props?: cloudwatch.MetricCustomization) {
return this.metric('ELBAuthSuccess', {
statistic: 'Sum',
...props
});
}
}

/**
* Count of HTTP status originating from the load balancer
*
* This count does not include any response codes generated by the targets.
*/
export enum HttpCodeElb {
/**
* The number of HTTP 3XX redirection codes that originate from the load balancer.
*/
Elb3xxCount = 'HTTPCode_ELB_3XX_Count',

/**
* The number of HTTP 4XX client error codes that originate from the load balancer.
*
* Client errors are generated when requests are malformed or incomplete.
* These requests have not been received by the target. This count does not
* include any response codes generated by the targets.
*/
Elb4xxCount = 'HTTPCode_ELB_4XX_Count',

/**
* The number of HTTP 5XX server error codes that originate from the load balancer.
*/
Elb5xxCount = 'HTTPCode_ELB_5XX_Count',
}

/**
* Count of HTTP status originating from the targets
*/
export enum HttpCodeTarget {
/**
* The number of 2xx response codes from targets
*/
Target2xxCount = 'HTTPCode_Target_2XX_Count',

/**
* The number of 3xx response codes from targets
*/
Target3xxCount = 'HTTPCode_Target_3XX_Count',

/**
* The number of 4xx response codes from targets
*/
Target4xxCount = 'HTTPCode_Target_4XX_Count',

/**
* The number of 5xx response codes from targets
*/
Target5xxCount = 'HTTPCode_Target_5XX_Count'
}

/**
Expand Down
Loading

0 comments on commit 81c1617

Please sign in to comment.