createMonitor method
Creates a monitor between a source subnet and destination IP address. Within a monitor you'll create one or more probes that monitor network traffic between your source Amazon Web Services VPC subnets and your destination IP addresses. Each probe then aggregates and sends metrics to Amazon CloudWatch.
You can also create a monitor with probes using this command. For each probe, you define the following:
-
source—The subnet IDs where the probes will be created. -
destination— The target destination IP address for the probe. -
destinationPort—Required only if the protocol isTCP. -
protocol—The communication protocol between the source and destination. This will be eitherTCPorICMP. -
packetSize—The size of the packets. This must be a number between56and8500. -
(Optional)
tags—Key-value pairs created and assigned to the probe.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter monitorName :
The name identifying the monitor. It can contain only letters, underscores
(_), or dashes (-), and can be up to 200 characters.
Parameter aggregationPeriod :
The time, in seconds, that metrics are aggregated and sent to Amazon
CloudWatch. Valid values are either 30 or 60.
60 is the default if no period is chosen.
Parameter clientToken :
Unique, case-sensitive identifier to ensure the idempotency of the
request. Only returned if a client token was provided in the request.
Parameter probes :
Displays a list of all of the probes created for a monitor.
Parameter tags :
The list of key-value pairs created and assigned to the monitor.
Implementation
Future<CreateMonitorOutput> createMonitor({
required String monitorName,
int? aggregationPeriod,
String? clientToken,
List<CreateMonitorProbeInput>? probes,
Map<String, String>? tags,
}) async {
_s.validateNumRange(
'aggregationPeriod',
aggregationPeriod,
30,
1152921504606846976,
);
final $payload = <String, dynamic>{
'monitorName': monitorName,
if (aggregationPeriod != null) 'aggregationPeriod': aggregationPeriod,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (probes != null) 'probes': probes,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/monitors',
exceptionFnMap: _exceptionFns,
);
return CreateMonitorOutput.fromJson(response);
}