updateMonitor method
- required String monitorName,
- String? clientToken,
- HealthEventsConfig? healthEventsConfig,
- InternetMeasurementsLogDelivery? internetMeasurementsLogDelivery,
- int? maxCityNetworksToMonitor,
- List<
String> ? resourcesToAdd, - List<
String> ? resourcesToRemove, - MonitorConfigState? status,
- int? trafficPercentageToMonitor,
Updates a monitor. You can update a monitor to change the percentage of traffic to monitor or the maximum number of city-networks (locations and ASNs), to add or remove resources, or to change the status of the monitor. Note that you can't change the name of a monitor.
The city-network maximum that you choose is the limit, but you only pay for the number of city-networks that are actually monitored. For more information, see Choosing a city-network maximum value in the Amazon CloudWatch User Guide.
May throw AccessDeniedException.
May throw InternalServerException.
May throw LimitExceededException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter monitorName :
The name of the monitor.
Parameter clientToken :
A unique, case-sensitive string of up to 64 ASCII characters that you
specify to make an idempotent API request. You should not reuse the same
client token for other API requests.
Parameter healthEventsConfig :
The list of health score thresholds. A threshold percentage for health
scores, along with other configuration information, determines when
Internet Monitor creates a health event when there's an internet issue
that affects your application end users.
For more information, see Change health event thresholds in the Internet Monitor section of the CloudWatch User Guide.
Parameter internetMeasurementsLogDelivery :
Publish internet measurements for Internet Monitor to another location,
such as an Amazon S3 bucket. The measurements are also published to Amazon
CloudWatch Logs.
Parameter maxCityNetworksToMonitor :
The maximum number of city-networks to monitor for your application. A
city-network is the location (city) where clients access your application
resources from and the ASN or network provider, such as an internet
service provider (ISP), that clients access the resources through. Setting
this limit can help control billing costs.
Parameter resourcesToAdd :
The resources to include in a monitor, which you provide as a set of
Amazon Resource Names (ARNs). Resources can be VPCs, NLBs, Amazon
CloudFront distributions, or Amazon WorkSpaces directories.
You can add a combination of VPCs and CloudFront distributions, or you can add WorkSpaces directories, or you can add NLBs. You can't add NLBs or WorkSpaces directories together with any other resources.
Parameter resourcesToRemove :
The resources to remove from a monitor, which you provide as a set of
Amazon Resource Names (ARNs).
Parameter status :
The status for a monitor. The accepted values for Status with
the UpdateMonitor API call are the following:
ACTIVE and INACTIVE. The following values are
not accepted: PENDING, and ERROR.
Parameter trafficPercentageToMonitor :
The percentage of the internet-facing traffic for your application that
you want to monitor with this monitor. If you set a city-networks maximum,
that limit overrides the traffic percentage that you set.
To learn more, see Choosing an application traffic percentage to monitor in the Amazon CloudWatch Internet Monitor section of the CloudWatch User Guide.
Implementation
Future<UpdateMonitorOutput> updateMonitor({
required String monitorName,
String? clientToken,
HealthEventsConfig? healthEventsConfig,
InternetMeasurementsLogDelivery? internetMeasurementsLogDelivery,
int? maxCityNetworksToMonitor,
List<String>? resourcesToAdd,
List<String>? resourcesToRemove,
MonitorConfigState? status,
int? trafficPercentageToMonitor,
}) async {
_s.validateNumRange(
'maxCityNetworksToMonitor',
maxCityNetworksToMonitor,
1,
500000,
);
_s.validateNumRange(
'trafficPercentageToMonitor',
trafficPercentageToMonitor,
1,
100,
);
final $payload = <String, dynamic>{
'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
if (healthEventsConfig != null) 'HealthEventsConfig': healthEventsConfig,
if (internetMeasurementsLogDelivery != null)
'InternetMeasurementsLogDelivery': internetMeasurementsLogDelivery,
if (maxCityNetworksToMonitor != null)
'MaxCityNetworksToMonitor': maxCityNetworksToMonitor,
if (resourcesToAdd != null) 'ResourcesToAdd': resourcesToAdd,
if (resourcesToRemove != null) 'ResourcesToRemove': resourcesToRemove,
if (status != null) 'Status': status.value,
if (trafficPercentageToMonitor != null)
'TrafficPercentageToMonitor': trafficPercentageToMonitor,
};
final response = await _protocol.send(
payload: $payload,
method: 'PATCH',
requestUri: '/v20210603/Monitors/${Uri.encodeComponent(monitorName)}',
exceptionFnMap: _exceptionFns,
);
return UpdateMonitorOutput.fromJson(response);
}