Skip to content

create_monitor

create_monitor(
    monitor_name: ResourceName,
    *,
    config_overrides: Optional[NetworkMonitorClientConfig] = None,
    probes: Optional[CreateMonitorProbeInputList] = None,
    aggregation_period: Optional[AggregationPeriod] = None,
    client_token: Optional[str] = None,
    tags: Optional[TagMap] = None,
) -> CreateMonitorOutput

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 is TCP.

  • protocol—The communication protocol between the source and destination. This will be either TCP or ICMP.

  • packetSize—The size of the packets. This must be a number between 56 and 8500.

  • (Optional) tags —Key-value pairs created and assigned to the probe.

Parameters:

  • monitor_name (ResourceName) –

    The name identifying the monitor. It can contain only letters, underscores (_), or dashes (-), and can be up to 200 characters.

  • probes (Optional[CreateMonitorProbeInputList], default: None ) –

    Displays a list of all of the probes created for a monitor.

  • aggregation_period (Optional[AggregationPeriod], default: None ) –

    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.

  • client_token (Optional[str], default: None ) –

    Unique, case-sensitive identifier to ensure the idempotency of the request. Only returned if a client token was provided in the request.

  • tags (Optional[TagMap], default: None ) –

    The list of key-value pairs created and assigned to the monitor.

Raises:

Source code in docs_src/capo_networkmonitor/_services/network_monitor.py
def create_monitor(
    self,
    monitor_name: "capo_networkmonitor.types.resource_name.ResourceName",
    *,
    config_overrides: Optional[NetworkMonitorClientConfig] = None,
    probes: Optional[
        "capo_networkmonitor.types.create_monitor_probe_input_list.CreateMonitorProbeInputList"
    ] = None,
    aggregation_period: Optional[
        "capo_networkmonitor.types.aggregation_period.AggregationPeriod"
    ] = None,
    client_token: Optional[str] = None,
    tags: Optional["capo_networkmonitor.types.tag_map.TagMap"] = None,
) -> "capo_networkmonitor.types.create_monitor_output.CreateMonitorOutput":
    """<p>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.</p> <p>You can also create a monitor with probes using this command. For each probe, you define the following:</p> <ul> <li> <p> <code>source</code>—The subnet IDs where the probes will be created.</p> </li> <li> <p> <code>destination</code>— The target destination IP address for the probe.</p> </li> <li> <p> <code>destinationPort</code>—Required only if the protocol is <code>TCP</code>.</p> </li> <li> <p> <code>protocol</code>—The communication protocol between the source and destination. This will be either <code>TCP</code> or <code>ICMP</code>.</p> </li> <li> <p> <code>packetSize</code>—The size of the packets. This must be a number between <code>56</code> and <code>8500</code>.</p> </li> <li> <p>(Optional) <code>tags</code> —Key-value pairs created and assigned to the probe.</p> </li> </ul>

    Args:
        monitor_name: <p>The name identifying the monitor. It can contain only letters, underscores (_), or dashes (-), and can be up to 200 characters.</p>
        probes: <p>Displays a list of all of the probes created for a monitor.</p>
        aggregation_period: <p>The time, in seconds, that metrics are aggregated and sent to Amazon CloudWatch. Valid values are either <code>30</code> or <code>60</code>. <code>60</code> is the default if no period is chosen.</p>
        client_token: <p>Unique, case-sensitive identifier to ensure the idempotency of the request. Only returned if a client token was provided in the request.</p>
        tags: <p>The list of key-value pairs created and assigned to the monitor.</p>

    Raises:
        capo_networkmonitor.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_networkmonitor.errors.conflict_exception.ConflictException: <p>This operation attempted to create a resource that already exists.</p>
        capo_networkmonitor.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_networkmonitor.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>This request exceeds a service quota.</p>
        capo_networkmonitor.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling</p>
        capo_networkmonitor.errors.validation_exception.ValidationException: <p>One of the parameters for the request is not valid.</p>
        capo_networkmonitor.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_networkmonitor.types.create_monitor_input.CreateMonitorInput]",
    ) -> OperationResponse[
        "capo_networkmonitor.types.create_monitor_output.CreateMonitorOutput"
    ]:
        import capo_networkmonitor._operations.network_monitor.create_monitor

        output, http_response = (
            capo_networkmonitor._operations.network_monitor.create_monitor.create_monitor(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateMonitor")
    )
    input_: capo_networkmonitor.types.create_monitor_input.CreateMonitorInput = {
        "monitor_name": monitor_name
    }
    if probes is not None:
        input_["probes"] = probes
    if aggregation_period is not None:
        input_["aggregation_period"] = aggregation_period
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output