Skip to content

CloudWatchLogsClient#

Index > CloudWatchLogs > CloudWatchLogsClient

Auto-generated documentation for CloudWatchLogs type annotations stubs module mypy-boto3-logs.

CloudWatchLogsClient#

Type annotations and code completion for boto3.client("logs"). boto3 documentation

# CloudWatchLogsClient usage example

from boto3.session import Session
from mypy_boto3_logs.client import CloudWatchLogsClient

def get_logs_client() -> CloudWatchLogsClient:
    return Session().client("logs")

Exceptions#

boto3 client exceptions are generated in runtime. This class provides code completion for boto3.client("logs").exceptions structure.

# Exceptions.exceptions usage example

client = boto3.client("logs")

try:
    do_something(client)
except (
    client.exceptions.AccessDeniedException,
    client.exceptions.ClientError,
    client.exceptions.ConflictException,
    client.exceptions.DataAlreadyAcceptedException,
    client.exceptions.InvalidOperationException,
    client.exceptions.InvalidParameterException,
    client.exceptions.InvalidSequenceTokenException,
    client.exceptions.LimitExceededException,
    client.exceptions.MalformedQueryException,
    client.exceptions.OperationAbortedException,
    client.exceptions.ResourceAlreadyExistsException,
    client.exceptions.ResourceNotFoundException,
    client.exceptions.ServiceQuotaExceededException,
    client.exceptions.ServiceUnavailableException,
    client.exceptions.ThrottlingException,
    client.exceptions.TooManyTagsException,
    client.exceptions.UnrecognizedClientException,
    client.exceptions.ValidationException,
) as e:
    print(e)
# Exceptions.exceptions type checking example

from mypy_boto3_logs.client import Exceptions

def handle_error(exc: Exceptions.AccessDeniedException) -> None:
    ...

Methods#

associate_kms_key#

Associates the specified KMS key with either one log group in the account, or with all stored CloudWatch Logs query insights results in the account.

Type annotations and code completion for boto3.client("logs").associate_kms_key method. boto3 documentation

# associate_kms_key method definition

def associate_kms_key(
    self,
    *,
    kmsKeyId: str,
    logGroupName: str = ...,
    resourceIdentifier: str = ...,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# associate_kms_key method usage example with argument unpacking

kwargs: AssociateKmsKeyRequestRequestTypeDef = {  # (1)
    "kmsKeyId": ...,
}

parent.associate_kms_key(**kwargs)
  1. See AssociateKmsKeyRequestRequestTypeDef

can_paginate#

Check if an operation can be paginated.

Type annotations and code completion for boto3.client("logs").can_paginate method. boto3 documentation

# can_paginate method definition

def can_paginate(
    self,
    operation_name: str,
) -> bool:
    ...

cancel_export_task#

Cancels the specified export task.

Type annotations and code completion for boto3.client("logs").cancel_export_task method. boto3 documentation

# cancel_export_task method definition

def cancel_export_task(
    self,
    *,
    taskId: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# cancel_export_task method usage example with argument unpacking

kwargs: CancelExportTaskRequestRequestTypeDef = {  # (1)
    "taskId": ...,
}

parent.cancel_export_task(**kwargs)
  1. See CancelExportTaskRequestRequestTypeDef

close#

Closes underlying endpoint connections.

Type annotations and code completion for boto3.client("logs").close method. boto3 documentation

# close method definition

def close(
    self,
) -> None:
    ...

create_delivery#

Creates a delivery.

Type annotations and code completion for boto3.client("logs").create_delivery method. boto3 documentation

# create_delivery method definition

def create_delivery(
    self,
    *,
    deliverySourceName: str,
    deliveryDestinationArn: str,
    tags: Mapping[str, str] = ...,
) -> CreateDeliveryResponseTypeDef:  # (1)
    ...
  1. See CreateDeliveryResponseTypeDef
# create_delivery method usage example with argument unpacking

kwargs: CreateDeliveryRequestRequestTypeDef = {  # (1)
    "deliverySourceName": ...,
    "deliveryDestinationArn": ...,
}

parent.create_delivery(**kwargs)
  1. See CreateDeliveryRequestRequestTypeDef

create_export_task#

Creates an export task so that you can efficiently export data from a log group to an Amazon S3 bucket.

Type annotations and code completion for boto3.client("logs").create_export_task method. boto3 documentation

# create_export_task method definition

def create_export_task(
    self,
    *,
    logGroupName: str,
    fromTime: int,
    to: int,
    destination: str,
    taskName: str = ...,
    logStreamNamePrefix: str = ...,
    destinationPrefix: str = ...,
) -> CreateExportTaskResponseTypeDef:  # (1)
    ...
  1. See CreateExportTaskResponseTypeDef
# create_export_task method usage example with argument unpacking

kwargs: CreateExportTaskRequestRequestTypeDef = {  # (1)
    "logGroupName": ...,
    "fromTime": ...,
    "to": ...,
    "destination": ...,
}

parent.create_export_task(**kwargs)
  1. See CreateExportTaskRequestRequestTypeDef

create_log_anomaly_detector#

Creates an anomaly detector that regularly scans one or more log groups and look for patterns and anomalies in the logs.

Type annotations and code completion for boto3.client("logs").create_log_anomaly_detector method. boto3 documentation

# create_log_anomaly_detector method definition

def create_log_anomaly_detector(
    self,
    *,
    logGroupArnList: Sequence[str],
    detectorName: str = ...,
    evaluationFrequency: EvaluationFrequencyType = ...,  # (1)
    filterPattern: str = ...,
    kmsKeyId: str = ...,
    anomalyVisibilityTime: int = ...,
    tags: Mapping[str, str] = ...,
) -> CreateLogAnomalyDetectorResponseTypeDef:  # (2)
    ...
  1. See EvaluationFrequencyType
  2. See CreateLogAnomalyDetectorResponseTypeDef
# create_log_anomaly_detector method usage example with argument unpacking

kwargs: CreateLogAnomalyDetectorRequestRequestTypeDef = {  # (1)
    "logGroupArnList": ...,
}

parent.create_log_anomaly_detector(**kwargs)
  1. See CreateLogAnomalyDetectorRequestRequestTypeDef

create_log_group#

Creates a log group with the specified name.

Type annotations and code completion for boto3.client("logs").create_log_group method. boto3 documentation

# create_log_group method definition

def create_log_group(
    self,
    *,
    logGroupName: str,
    kmsKeyId: str = ...,
    tags: Mapping[str, str] = ...,
    logGroupClass: LogGroupClassType = ...,  # (1)
) -> EmptyResponseMetadataTypeDef:  # (2)
    ...
  1. See LogGroupClassType
  2. See EmptyResponseMetadataTypeDef
# create_log_group method usage example with argument unpacking

kwargs: CreateLogGroupRequestRequestTypeDef = {  # (1)
    "logGroupName": ...,
}

parent.create_log_group(**kwargs)
  1. See CreateLogGroupRequestRequestTypeDef

create_log_stream#

Creates a log stream for the specified log group.

Type annotations and code completion for boto3.client("logs").create_log_stream method. boto3 documentation

# create_log_stream method definition

def create_log_stream(
    self,
    *,
    logGroupName: str,
    logStreamName: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# create_log_stream method usage example with argument unpacking

kwargs: CreateLogStreamRequestRequestTypeDef = {  # (1)
    "logGroupName": ...,
    "logStreamName": ...,
}

parent.create_log_stream(**kwargs)
  1. See CreateLogStreamRequestRequestTypeDef

delete_account_policy#

Deletes a CloudWatch Logs account policy.

Type annotations and code completion for boto3.client("logs").delete_account_policy method. boto3 documentation

# delete_account_policy method definition

def delete_account_policy(
    self,
    *,
    policyName: str,
    policyType: PolicyTypeType,  # (1)
) -> EmptyResponseMetadataTypeDef:  # (2)
    ...
  1. See PolicyTypeType
  2. See EmptyResponseMetadataTypeDef
# delete_account_policy method usage example with argument unpacking

kwargs: DeleteAccountPolicyRequestRequestTypeDef = {  # (1)
    "policyName": ...,
    "policyType": ...,
}

parent.delete_account_policy(**kwargs)
  1. See DeleteAccountPolicyRequestRequestTypeDef

delete_data_protection_policy#

Deletes the data protection policy from the specified log group.

Type annotations and code completion for boto3.client("logs").delete_data_protection_policy method. boto3 documentation

# delete_data_protection_policy method definition

def delete_data_protection_policy(
    self,
    *,
    logGroupIdentifier: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# delete_data_protection_policy method usage example with argument unpacking

kwargs: DeleteDataProtectionPolicyRequestRequestTypeDef = {  # (1)
    "logGroupIdentifier": ...,
}

parent.delete_data_protection_policy(**kwargs)
  1. See DeleteDataProtectionPolicyRequestRequestTypeDef

delete_delivery#

Deletes s delivery.

Type annotations and code completion for boto3.client("logs").delete_delivery method. boto3 documentation

# delete_delivery method definition

def delete_delivery(
    self,
    *,
    id: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# delete_delivery method usage example with argument unpacking

kwargs: DeleteDeliveryRequestRequestTypeDef = {  # (1)
    "id": ...,
}

parent.delete_delivery(**kwargs)
  1. See DeleteDeliveryRequestRequestTypeDef

delete_delivery_destination#

Deletes a delivery destination.

Type annotations and code completion for boto3.client("logs").delete_delivery_destination method. boto3 documentation

# delete_delivery_destination method definition

def delete_delivery_destination(
    self,
    *,
    name: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# delete_delivery_destination method usage example with argument unpacking

kwargs: DeleteDeliveryDestinationRequestRequestTypeDef = {  # (1)
    "name": ...,
}

parent.delete_delivery_destination(**kwargs)
  1. See DeleteDeliveryDestinationRequestRequestTypeDef

delete_delivery_destination_policy#

Deletes a delivery destination policy.

Type annotations and code completion for boto3.client("logs").delete_delivery_destination_policy method. boto3 documentation

# delete_delivery_destination_policy method definition

def delete_delivery_destination_policy(
    self,
    *,
    deliveryDestinationName: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# delete_delivery_destination_policy method usage example with argument unpacking

kwargs: DeleteDeliveryDestinationPolicyRequestRequestTypeDef = {  # (1)
    "deliveryDestinationName": ...,
}

parent.delete_delivery_destination_policy(**kwargs)
  1. See DeleteDeliveryDestinationPolicyRequestRequestTypeDef

delete_delivery_source#

Deletes a delivery source.

Type annotations and code completion for boto3.client("logs").delete_delivery_source method. boto3 documentation

# delete_delivery_source method definition

def delete_delivery_source(
    self,
    *,
    name: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# delete_delivery_source method usage example with argument unpacking

kwargs: DeleteDeliverySourceRequestRequestTypeDef = {  # (1)
    "name": ...,
}

parent.delete_delivery_source(**kwargs)
  1. See DeleteDeliverySourceRequestRequestTypeDef

delete_destination#

Deletes the specified destination, and eventually disables all the subscription filters that publish to it.

Type annotations and code completion for boto3.client("logs").delete_destination method. boto3 documentation

# delete_destination method definition

def delete_destination(
    self,
    *,
    destinationName: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# delete_destination method usage example with argument unpacking

kwargs: DeleteDestinationRequestRequestTypeDef = {  # (1)
    "destinationName": ...,
}

parent.delete_destination(**kwargs)
  1. See DeleteDestinationRequestRequestTypeDef

delete_log_anomaly_detector#

Deletes the specified CloudWatch Logs anomaly detector.

Type annotations and code completion for boto3.client("logs").delete_log_anomaly_detector method. boto3 documentation

# delete_log_anomaly_detector method definition

def delete_log_anomaly_detector(
    self,
    *,
    anomalyDetectorArn: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# delete_log_anomaly_detector method usage example with argument unpacking

kwargs: DeleteLogAnomalyDetectorRequestRequestTypeDef = {  # (1)
    "anomalyDetectorArn": ...,
}

parent.delete_log_anomaly_detector(**kwargs)
  1. See DeleteLogAnomalyDetectorRequestRequestTypeDef

delete_log_group#

Deletes the specified log group and permanently deletes all the archived log events associated with the log group.

Type annotations and code completion for boto3.client("logs").delete_log_group method.