describe_error_logs
Retrieve error logs for Alibaba Cloud RDS instances by specifying region, instance ID, time range, and pagination. Use this tool to analyze and troubleshoot database issues efficiently.
Instructions
Query error logs of an RDS instance.
Args:
region_id: The region ID of the RDS instance.
db_instance_id: The ID of the RDS instance.
start_time: The start time of the query. Format: yyyy-MM-dd HH:mm.
end_time: The end time of the query. Format: yyyy-MM-dd HH:mm.
page_size: The number of records per page. Range: 30~100. Default: 30.
page_number: The page number. Default: 1.
Returns:
Dict[str, Any]: A dictionary containing error log information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| db_instance_id | Yes | ||
| end_time | Yes | ||
| page_number | No | ||
| page_size | No | ||
| region_id | Yes | ||
| start_time | Yes |
Input Schema (JSON Schema)
{
"properties": {
"db_instance_id": {
"title": "Db Instance Id",
"type": "string"
},
"end_time": {
"title": "End Time",
"type": "string"
},
"page_number": {
"default": 1,
"title": "Page Number",
"type": "integer"
},
"page_size": {
"default": 30,
"title": "Page Size",
"type": "integer"
},
"region_id": {
"title": "Region Id",
"type": "string"
},
"start_time": {
"title": "Start Time",
"type": "string"
}
},
"required": [
"region_id",
"db_instance_id",
"start_time",
"end_time"
],
"title": "describe_error_logsArguments",
"type": "object"
}
Implementation Reference
- The core handler function for the 'describe_error_logs' tool. It constructs a DescribeErrorLogsRequest using the provided parameters, calls the Alibaba Cloud RDS client's async method to fetch error logs, processes the response by joining the error_info fields, and returns pagination details.async def describe_error_logs( region_id: str, db_instance_id: str, start_time: str, end_time: str, page_size: int = 30, page_number: int = 1 ) -> Dict[str, Any]: """ Query error logs of an RDS instance. Args: region_id: The region ID of the RDS instance. db_instance_id: The ID of the RDS instance. start_time: The start time of the query. Format: yyyy-MM-dd HH:mm. end_time: The end time of the query. Format: yyyy-MM-dd HH:mm. page_size: The number of records per page. Range: 30~100. Default: 30. page_number: The page number. Default: 1. Returns: Dict[str, Any]: A dictionary containing error log information """ try: start_time = transform_to_datetime(start_time) end_time = transform_to_datetime(end_time) client = get_rds_client(region_id) request = rds_20140815_models.DescribeErrorLogsRequest( dbinstance_id=db_instance_id, start_time=transform_to_iso_8601(start_time, "minutes"), end_time=transform_to_iso_8601(end_time, "minutes"), page_size=page_size, page_number=page_number ) response = await client.describe_error_logs_async(request) return { "Logs": "\n".join([log.error_info for log in response.body.items.error_log]), "PageNumber": response.body.page_number, "PageRecordCount": response.body.page_record_count, "TotalRecordCount": response.body.total_record_count } except Exception as e: logger.error(f"Failed to describe error logs: {str(e)}") raise OpenAPIError(f"Failed to describe error logs: {str(e)}")