Skip to content

Commit

Permalink
feat(ec2): allow users to specify EC2 instance IDs to monitor (#122)
Browse files Browse the repository at this point in the history
Allows users to specify instance IDs in the EC2 monitoring and combine them with ASG property.

Fixes #43 

---

_By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
  • Loading branch information
voho authored Apr 22, 2022
1 parent 7c5459e commit 5316f56
Show file tree
Hide file tree
Showing 5 changed files with 682 additions and 107 deletions.
182 changes: 149 additions & 33 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -12739,6 +12739,51 @@ public readonly addUnhealthyTaskCountAlarm: {[ key: string ]: UnhealthyTaskCount

---

### EC2MetricFactoryProps <a name="EC2MetricFactoryProps" id="cdk-monitoring-constructs.EC2MetricFactoryProps"></a>

#### Initializer <a name="Initializer" id="cdk-monitoring-constructs.EC2MetricFactoryProps.Initializer"></a>

```typescript
import { EC2MetricFactoryProps } from 'cdk-monitoring-constructs'

const eC2MetricFactoryProps: EC2MetricFactoryProps = { ... }
```

#### Properties <a name="Properties" id="Properties"></a>

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#cdk-monitoring-constructs.EC2MetricFactoryProps.property.autoScalingGroup">autoScalingGroup</a></code> | <code>aws-cdk-lib.aws_autoscaling.IAutoScalingGroup</code> | Auto-Scaling Group to monitor. |
| <code><a href="#cdk-monitoring-constructs.EC2MetricFactoryProps.property.instanceIds">instanceIds</a></code> | <code>string[]</code> | Selected IDs of EC2 instances to monitor. |

---

##### `autoScalingGroup`<sup>Optional</sup> <a name="autoScalingGroup" id="cdk-monitoring-constructs.EC2MetricFactoryProps.property.autoScalingGroup"></a>

```typescript
public readonly autoScalingGroup: IAutoScalingGroup;
```

- *Type:* aws-cdk-lib.aws_autoscaling.IAutoScalingGroup
- *Default:* no Auto-Scaling Group filter

Auto-Scaling Group to monitor.

---

##### `instanceIds`<sup>Optional</sup> <a name="instanceIds" id="cdk-monitoring-constructs.EC2MetricFactoryProps.property.instanceIds"></a>

```typescript
public readonly instanceIds: string[];
```

- *Type:* string[]
- *Default:* no instance filter

Selected IDs of EC2 instances to monitor.

---

### EC2MonitoringOptions <a name="EC2MonitoringOptions" id="cdk-monitoring-constructs.EC2MonitoringOptions"></a>

#### Initializer <a name="Initializer" id="cdk-monitoring-constructs.EC2MonitoringOptions.Initializer"></a>
Expand All @@ -12753,14 +12798,41 @@ const eC2MonitoringOptions: EC2MonitoringOptions = { ... }

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.autoScalingGroup">autoScalingGroup</a></code> | <code>aws-cdk-lib.aws_autoscaling.IAutoScalingGroup</code> | Auto-Scaling Group to monitor. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.instanceIds">instanceIds</a></code> | <code>string[]</code> | Selected IDs of EC2 instances to monitor. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.alarmFriendlyName">alarmFriendlyName</a></code> | <code>string</code> | Plain name, used in naming alarms. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.humanReadableName">humanReadableName</a></code> | <code>string</code> | Human-readable name is a freeform string, used as a caption or description. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.localAlarmNamePrefixOverride">localAlarmNamePrefixOverride</a></code> | <code>string</code> | If this is defined, the local alarm name prefix used in naming alarms for the construct will be set to this value. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.addToAlarmDashboard">addToAlarmDashboard</a></code> | <code>boolean</code> | Flag indicating if the widgets should be added to alarm dashboard. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.addToDetailDashboard">addToDetailDashboard</a></code> | <code>boolean</code> | Flag indicating if the widgets should be added to detailed dashboard. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.addToSummaryDashboard">addToSummaryDashboard</a></code> | <code>boolean</code> | Flag indicating if the widgets should be added to summary dashboard. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.useCreatedAlarms">useCreatedAlarms</a></code> | <code><a href="#cdk-monitoring-constructs.IAlarmConsumer">IAlarmConsumer</a></code> | Calls provided function to process all alarms created. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringOptions.property.autoScalingGroup">autoScalingGroup</a></code> | <code>aws-cdk-lib.aws_autoscaling.IAutoScalingGroup</code> | *No description.* |

---

##### `autoScalingGroup`<sup>Optional</sup> <a name="autoScalingGroup" id="cdk-monitoring-constructs.EC2MonitoringOptions.property.autoScalingGroup"></a>

```typescript
public readonly autoScalingGroup: IAutoScalingGroup;
```

- *Type:* aws-cdk-lib.aws_autoscaling.IAutoScalingGroup
- *Default:* no Auto-Scaling Group filter

Auto-Scaling Group to monitor.

---

##### `instanceIds`<sup>Optional</sup> <a name="instanceIds" id="cdk-monitoring-constructs.EC2MonitoringOptions.property.instanceIds"></a>

```typescript
public readonly instanceIds: string[];
```

- *Type:* string[]
- *Default:* no instance filter

Selected IDs of EC2 instances to monitor.

---

Expand Down Expand Up @@ -12862,16 +12934,6 @@ Calls provided function to process all alarms created.

---

##### `autoScalingGroup`<sup>Optional</sup> <a name="autoScalingGroup" id="cdk-monitoring-constructs.EC2MonitoringOptions.property.autoScalingGroup"></a>

```typescript
public readonly autoScalingGroup: IAutoScalingGroup;
```

- *Type:* aws-cdk-lib.aws_autoscaling.IAutoScalingGroup

---

### EC2MonitoringProps <a name="EC2MonitoringProps" id="cdk-monitoring-constructs.EC2MonitoringProps"></a>

#### Initializer <a name="Initializer" id="cdk-monitoring-constructs.EC2MonitoringProps.Initializer"></a>
Expand All @@ -12886,14 +12948,41 @@ const eC2MonitoringProps: EC2MonitoringProps = { ... }

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.autoScalingGroup">autoScalingGroup</a></code> | <code>aws-cdk-lib.aws_autoscaling.IAutoScalingGroup</code> | Auto-Scaling Group to monitor. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.instanceIds">instanceIds</a></code> | <code>string[]</code> | Selected IDs of EC2 instances to monitor. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.alarmFriendlyName">alarmFriendlyName</a></code> | <code>string</code> | Plain name, used in naming alarms. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.humanReadableName">humanReadableName</a></code> | <code>string</code> | Human-readable name is a freeform string, used as a caption or description. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.localAlarmNamePrefixOverride">localAlarmNamePrefixOverride</a></code> | <code>string</code> | If this is defined, the local alarm name prefix used in naming alarms for the construct will be set to this value. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.addToAlarmDashboard">addToAlarmDashboard</a></code> | <code>boolean</code> | Flag indicating if the widgets should be added to alarm dashboard. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.addToDetailDashboard">addToDetailDashboard</a></code> | <code>boolean</code> | Flag indicating if the widgets should be added to detailed dashboard. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.addToSummaryDashboard">addToSummaryDashboard</a></code> | <code>boolean</code> | Flag indicating if the widgets should be added to summary dashboard. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.useCreatedAlarms">useCreatedAlarms</a></code> | <code><a href="#cdk-monitoring-constructs.IAlarmConsumer">IAlarmConsumer</a></code> | Calls provided function to process all alarms created. |
| <code><a href="#cdk-monitoring-constructs.EC2MonitoringProps.property.autoScalingGroup">autoScalingGroup</a></code> | <code>aws-cdk-lib.aws_autoscaling.IAutoScalingGroup</code> | *No description.* |

---

##### `autoScalingGroup`<sup>Optional</sup> <a name="autoScalingGroup" id="cdk-monitoring-constructs.EC2MonitoringProps.property.autoScalingGroup"></a>

```typescript
public readonly autoScalingGroup: IAutoScalingGroup;
```

- *Type:* aws-cdk-lib.aws_autoscaling.IAutoScalingGroup
- *Default:* no Auto-Scaling Group filter

Auto-Scaling Group to monitor.

---

##### `instanceIds`<sup>Optional</sup> <a name="instanceIds" id="cdk-monitoring-constructs.EC2MonitoringProps.property.instanceIds"></a>

```typescript
public readonly instanceIds: string[];
```

- *Type:* string[]
- *Default:* no instance filter

Selected IDs of EC2 instances to monitor.

---

Expand Down Expand Up @@ -12995,16 +13084,6 @@ Calls provided function to process all alarms created.

---

##### `autoScalingGroup`<sup>Optional</sup> <a name="autoScalingGroup" id="cdk-monitoring-constructs.EC2MonitoringProps.property.autoScalingGroup"></a>

```typescript
public readonly autoScalingGroup: IAutoScalingGroup;
```

- *Type:* aws-cdk-lib.aws_autoscaling.IAutoScalingGroup

---

### Ec2NetworkLoadBalancerMonitoringProps <a name="Ec2NetworkLoadBalancerMonitoringProps" id="cdk-monitoring-constructs.Ec2NetworkLoadBalancerMonitoringProps"></a>

Monitoring props for EC2 service with network load balancer and plain service.
Expand Down Expand Up @@ -38549,13 +38628,13 @@ Returns widgets to be placed on the main dashboard.
```typescript
import { EC2MetricFactory } from 'cdk-monitoring-constructs'

new EC2MetricFactory(metricFactory: MetricFactory, autoScalingGroup?: IAutoScalingGroup)
new EC2MetricFactory(metricFactory: MetricFactory, props: EC2MetricFactoryProps)
```

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#cdk-monitoring-constructs.EC2MetricFactory.Initializer.parameter.metricFactory">metricFactory</a></code> | <code><a href="#cdk-monitoring-constructs.MetricFactory">MetricFactory</a></code> | *No description.* |
| <code><a href="#cdk-monitoring-constructs.EC2MetricFactory.Initializer.parameter.autoScalingGroup">autoScalingGroup</a></code> | <code>aws-cdk-lib.aws_autoscaling.IAutoScalingGroup</code> | *No description.* |
| <code><a href="#cdk-monitoring-constructs.EC2MetricFactory.Initializer.parameter.props">props</a></code> | <code><a href="#cdk-monitoring-constructs.EC2MetricFactoryProps">EC2MetricFactoryProps</a></code> | *No description.* |

---

Expand All @@ -38565,9 +38644,9 @@ new EC2MetricFactory(metricFactory: MetricFactory, autoScalingGroup?: IAutoScali

---

##### `autoScalingGroup`<sup>Optional</sup> <a name="autoScalingGroup" id="cdk-monitoring-constructs.EC2MetricFactory.Initializer.parameter.autoScalingGroup"></a>
##### `props`<sup>Required</sup> <a name="props" id="cdk-monitoring-constructs.EC2MetricFactory.Initializer.parameter.props"></a>

- *Type:* aws-cdk-lib.aws_autoscaling.IAutoScalingGroup
- *Type:* <a href="#cdk-monitoring-constructs.EC2MetricFactoryProps">EC2MetricFactoryProps</a>

---

Expand All @@ -38588,7 +38667,7 @@ new EC2MetricFactory(metricFactory: MetricFactory, autoScalingGroup?: IAutoScali
##### `metricAverageCpuUtilisationPercent` <a name="metricAverageCpuUtilisationPercent" id="cdk-monitoring-constructs.EC2MetricFactory.metricAverageCpuUtilisationPercent"></a>

```typescript
public metricAverageCpuUtilisationPercent(): IMetric
public metricAverageCpuUtilisationPercent(): IMetric[]
```

The percentage of allocated EC2 compute units that are currently in use on the instance.
Expand All @@ -38600,7 +38679,7 @@ CloudWatch when the instance is not allocated a full processor core.
##### `metricAverageDiskReadBytes` <a name="metricAverageDiskReadBytes" id="cdk-monitoring-constructs.EC2MetricFactory.metricAverageDiskReadBytes"></a>

```typescript
public metricAverageDiskReadBytes(): IMetric
public metricAverageDiskReadBytes(): IMetric[]
```

Bytes read from all instance store volumes available to the instance.
Expand All @@ -38611,15 +38690,15 @@ This can be used to determine the speed of the application.
##### `metricAverageDiskReadOps` <a name="metricAverageDiskReadOps" id="cdk-monitoring-constructs.EC2MetricFactory.metricAverageDiskReadOps"></a>

```typescript
public metricAverageDiskReadOps(): IMetric
public metricAverageDiskReadOps(): IMetric[]
```

Completed read operations from all instance store volumes available to the instance in a specified period of time.

##### `metricAverageDiskWriteBytes` <a name="metricAverageDiskWriteBytes" id="cdk-monitoring-constructs.EC2MetricFactory.metricAverageDiskWriteBytes"></a>

```typescript
public metricAverageDiskWriteBytes(): IMetric
public metricAverageDiskWriteBytes(): IMetric[]
```

Bytes written to all instance store volumes available to the instance.
Expand All @@ -38630,15 +38709,15 @@ This can be used to determine the speed of the application.
##### `metricAverageDiskWriteOps` <a name="metricAverageDiskWriteOps" id="cdk-monitoring-constructs.EC2MetricFactory.metricAverageDiskWriteOps"></a>

```typescript
public metricAverageDiskWriteOps(): IMetric
public metricAverageDiskWriteOps(): IMetric[]
```

Completed write operations to all instance store volumes available to the instance in a specified period of time.

##### `metricAverageNetworkInRateBytes` <a name="metricAverageNetworkInRateBytes" id="cdk-monitoring-constructs.EC2MetricFactory.metricAverageNetworkInRateBytes"></a>

```typescript
public metricAverageNetworkInRateBytes(): IMetric
public metricAverageNetworkInRateBytes(): IMetric[]
```

The number of bytes received on all network interfaces by the instance.
Expand All @@ -38648,7 +38727,7 @@ This metric identifies the volume of incoming network traffic to a single instan
##### `metricAverageNetworkOutRateBytes` <a name="metricAverageNetworkOutRateBytes" id="cdk-monitoring-constructs.EC2MetricFactory.metricAverageNetworkOutRateBytes"></a>

```typescript
public metricAverageNetworkOutRateBytes(): IMetric
public metricAverageNetworkOutRateBytes(): IMetric[]
```

The number of bytes sent out on all network interfaces by the instance.
Expand Down Expand Up @@ -48104,6 +48183,43 @@ Returns all widgets.
These should go to the detailed service dashboard.


### IEC2MetricFactoryStrategy <a name="IEC2MetricFactoryStrategy" id="cdk-monitoring-constructs.IEC2MetricFactoryStrategy"></a>

- *Implemented By:* <a href="#cdk-monitoring-constructs.IEC2MetricFactoryStrategy">IEC2MetricFactoryStrategy</a>

#### Methods <a name="Methods" id="Methods"></a>

| **Name** | **Description** |
| --- | --- |
| <code><a href="#cdk-monitoring-constructs.IEC2MetricFactoryStrategy.createMetrics">createMetrics</a></code> | *No description.* |

---

##### `createMetrics` <a name="createMetrics" id="cdk-monitoring-constructs.IEC2MetricFactoryStrategy.createMetrics"></a>

```typescript
public createMetrics(metricFactory: MetricFactory, metricName: string, statistic: MetricStatistic): IMetric[]
```

###### `metricFactory`<sup>Required</sup> <a name="metricFactory" id="cdk-monitoring-constructs.IEC2MetricFactoryStrategy.createMetrics.parameter.metricFactory"></a>

- *Type:* <a href="#cdk-monitoring-constructs.MetricFactory">MetricFactory</a>

---

###### `metricName`<sup>Required</sup> <a name="metricName" id="cdk-monitoring-constructs.IEC2MetricFactoryStrategy.createMetrics.parameter.metricName"></a>

- *Type:* string

---

###### `statistic`<sup>Required</sup> <a name="statistic" id="cdk-monitoring-constructs.IEC2MetricFactoryStrategy.createMetrics.parameter.statistic"></a>

- *Type:* <a href="#cdk-monitoring-constructs.MetricStatistic">MetricStatistic</a>

---


### ILoadBalancerMetricFactory <a name="ILoadBalancerMetricFactory" id="cdk-monitoring-constructs.ILoadBalancerMetricFactory"></a>

- *Implemented By:* <a href="#cdk-monitoring-constructs.ApplicationLoadBalancerMetricFactory">ApplicationLoadBalancerMetricFactory</a>, <a href="#cdk-monitoring-constructs.NetworkLoadBalancerMetricFactory">NetworkLoadBalancerMetricFactory</a>, <a href="#cdk-monitoring-constructs.ILoadBalancerMetricFactory">ILoadBalancerMetricFactory</a>
Expand Down
Loading

0 comments on commit 5316f56

Please sign in to comment.