Skip to content

enable_logging

enable_logging(
    *,
    config_overrides: Optional[RedshiftClientConfig] = None,
    cluster_identifier: Optional[String] = None,
    bucket_name: Optional[String] = None,
    s3_key_prefix: Optional[S3KeyPrefixValue] = None,
    log_destination_type: Optional[LogDestinationType] = None,
    log_exports: Optional[LogTypeList] = None,
    s3_table_kms_key_id: Optional[String] = None,
    s3_table_granularity: Optional[String] = None,
) -> LoggingStatus

Starts logging information, such as queries and connection attempts, for the specified Amazon Redshift cluster.

Parameters:

  • cluster_identifier (Optional[String], default: None ) –

    The identifier of the cluster on which logging is to be started.

    Example: examplecluster

  • bucket_name (Optional[String], default: None ) –

    The name of an existing S3 bucket where the log files are to be stored.

    Constraints:

    • Must be in the same region as the cluster

    • The cluster must have read bucket and put object permissions

  • s3_key_prefix (Optional[S3KeyPrefixValue], default: None ) –

    The prefix applied to the log file names.

    Valid characters are any letter from any language, any whitespace character, any numeric character, and the following characters: underscore (_), period (.), colon (:), slash (/), equal (=), plus (+), backslash (\), hyphen (-), at symbol (@).

  • log_destination_type (Optional[LogDestinationType], default: None ) –

    The log destination type. An enum with possible values of s3, cloudwatch, and s3table.

  • log_exports (Optional[LogTypeList], default: None ) –

    The collection of exported log types. When LogDestinationType is s3 or cloudwatch, possible values are connectionlog, useractivitylog, and userlog. When LogDestinationType is s3table, the values are the names of the system tables to publish. Omitting this parameter, passing an empty list, or including the value all publishes all current and future system tables.

  • s3_table_kms_key_id (Optional[String], default: None ) –

    The identifier of a customer managed KMS key used to encrypt the S3 tables. This parameter is valid only when LogDestinationType is s3table.

  • s3_table_granularity (Optional[String], default: None ) –

    The scope of system table publishing. Valid values are cluster and account. A value of cluster scopes publishing to the individual cluster. A value of account scopes publishing to the Amazon Web Services account. This parameter is valid only when LogDestinationType is s3table.

Raises:

Source code in docs_src/capo_redshift/_services/redshift.py
def enable_logging(
    self,
    *,
    config_overrides: Optional[RedshiftClientConfig] = None,
    cluster_identifier: Optional["capo_redshift.types.string.String"] = None,
    bucket_name: Optional["capo_redshift.types.string.String"] = None,
    s3_key_prefix: Optional[
        "capo_redshift.types.s3_key_prefix_value.S3KeyPrefixValue"
    ] = None,
    log_destination_type: Optional[
        "capo_redshift.types.log_destination_type.LogDestinationType"
    ] = None,
    log_exports: Optional["capo_redshift.types.log_type_list.LogTypeList"] = None,
    s3_table_kms_key_id: Optional["capo_redshift.types.string.String"] = None,
    s3_table_granularity: Optional["capo_redshift.types.string.String"] = None,
) -> "capo_redshift.types.logging_status.LoggingStatus":
    r"""<p>Starts logging information, such as queries and connection attempts, for the specified Amazon Redshift cluster.</p>

    Args:
        cluster_identifier: <p>The identifier of the cluster on which logging is to be started.</p> <p>Example: <code>examplecluster</code> </p>
        bucket_name: <p>The name of an existing S3 bucket where the log files are to be stored.</p> <p>Constraints:</p> <ul> <li> <p>Must be in the same region as the cluster</p> </li> <li> <p>The cluster must have read bucket and put object permissions</p> </li> </ul>
        s3_key_prefix: <p>The prefix applied to the log file names.</p> <p>Valid characters are any letter from any language, any whitespace character, any numeric character, and the following characters: underscore (<code>_</code>), period (<code>.</code>), colon (<code>:</code>), slash (<code>/</code>), equal (<code>=</code>), plus (<code>+</code>), backslash (<code>\</code>), hyphen (<code>-</code>), at symbol (<code>@</code>).</p>
        log_destination_type: <p>The log destination type. An enum with possible values of <code>s3</code>, <code>cloudwatch</code>, and <code>s3table</code>.</p>
        log_exports: <p>The collection of exported log types. When <code>LogDestinationType</code> is <code>s3</code> or <code>cloudwatch</code>, possible values are <code>connectionlog</code>, <code>useractivitylog</code>, and <code>userlog</code>. When <code>LogDestinationType</code> is <code>s3table</code>, the values are the names of the system tables to publish. Omitting this parameter, passing an empty list, or including the value <code>all</code> publishes all current and future system tables.</p>
        s3_table_kms_key_id: <p>The identifier of a customer managed KMS key used to encrypt the S3 tables. This parameter is valid only when <code>LogDestinationType</code> is <code>s3table</code>.</p>
        s3_table_granularity: <p>The scope of system table publishing. Valid values are <code>cluster</code> and <code>account</code>. A value of <code>cluster</code> scopes publishing to the individual cluster. A value of <code>account</code> scopes publishing to the Amazon Web Services account. This parameter is valid only when <code>LogDestinationType</code> is <code>s3table</code>.</p>

    Raises:
        capo_redshift.errors.bucket_not_found_fault.BucketNotFoundFault: <p>Could not find the specified S3 bucket.</p>
        capo_redshift.errors.cluster_not_found_fault.ClusterNotFoundFault: <p>The <code>ClusterIdentifier</code> parameter does not refer to an existing cluster. </p>
        capo_redshift.errors.insufficient_s3_bucket_policy_fault.InsufficientS3BucketPolicyFault: <p>The cluster does not have read bucket or put object permissions on the S3 bucket specified when enabling logging.</p>
        capo_redshift.errors.invalid_cluster_state_fault.InvalidClusterStateFault: <p>The specified cluster is not in the <code>available</code> state. </p>
        capo_redshift.errors.invalid_s3_bucket_name_fault.InvalidS3BucketNameFault: <p>The S3 bucket name is invalid. For more information about naming rules, go to <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html">Bucket Restrictions and Limitations</a> in the Amazon Simple Storage Service (S3) Developer Guide.</p>
        capo_redshift.errors.invalid_s3_key_prefix_fault.InvalidS3KeyPrefixFault: <p>The string specified for the logging S3 key prefix does not comply with the documented constraints.</p>
        capo_redshift.errors.unsupported_operation_fault.UnsupportedOperationFault: <p>The requested operation isn't supported.</p>
        capo_redshift.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_redshift.types.enable_logging_message.EnableLoggingMessage]",
    ) -> OperationResponse["capo_redshift.types.logging_status.LoggingStatus"]:
        import capo_redshift._operations.redshift_service_version20121201.enable_logging

        output, http_response = (
            capo_redshift._operations.redshift_service_version20121201.enable_logging.enable_logging(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("EnableLogging")
    )
    input_: capo_redshift.types.enable_logging_message.EnableLoggingMessage = {}
    if cluster_identifier is not None:
        input_["cluster_identifier"] = cluster_identifier
    if bucket_name is not None:
        input_["bucket_name"] = bucket_name
    if s3_key_prefix is not None:
        input_["s3_key_prefix"] = s3_key_prefix
    if log_destination_type is not None:
        input_["log_destination_type"] = log_destination_type
    if log_exports is not None:
        input_["log_exports"] = log_exports
    if s3_table_kms_key_id is not None:
        input_["s3_table_kms_key_id"] = s3_table_kms_key_id
    if s3_table_granularity is not None:
        input_["s3_table_granularity"] = s3_table_granularity

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