View a markdown version of this page

AWS SDK ListSyslogConfigurationsで を使用する - Amazon CloudWatch Logs

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWS SDK ListSyslogConfigurationsで を使用する

次の例は、ListSyslogConfigurations を使用する方法を説明しています。

アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。

Python
SDK for Python (Boto3)
注記

GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

def list_syslog_configurations( self, log_group_identifier: Optional[str] = None, vpc_endpoint_id: Optional[str] = None, ) -> list[dict[str, Any]]: """ Lists syslog configurations, optionally filtered by log group or VPC endpoint. Handles pagination by following nextToken until all results are returned. :param log_group_identifier: Optional log group name or ARN to filter by. :param vpc_endpoint_id: Optional VPC endpoint ID to filter by. :return: A list of syslog configuration dictionaries. :raises ClientError: If a filter parameter is invalid. """ try: configurations = list() params = dict() if log_group_identifier is not None: params["logGroupIdentifier"] = log_group_identifier if vpc_endpoint_id is not None: params["vpcEndpointId"] = vpc_endpoint_id while True: response = self.logs_client.list_syslog_configurations(**params) configurations.extend(response.get("syslogConfigurations", list())) next_token = response.get("nextToken", None) if next_token is None: break params["nextToken"] = next_token logger.info("Listed %d syslog configuration(s).", len(configurations)) return configurations except ClientError as error: if error.response["Error"]["Code"] == "InvalidParameterException": logger.error( "Invalid filter parameter: %s. Ensure the log group identifier " "or VPC endpoint ID is correctly formatted.", error.response["Error"]["Message"], ) else: logger.error( "Failed to list syslog configurations: %s", error.response["Error"]["Message"], ) raise
  • API の詳細については、 AWS SDK for Python (Boto3) API リファレンスのListSyslogConfigurations」を参照してください。

AWS SDK 開発者ガイドとコード例の完全なリストについては、「」を参照してくださいAWS SDK での CloudWatch Logs の使用。このトピックには、使用開始方法に関する情報と、以前の SDK バージョンの詳細も含まれています。