Exporting Cloud Database Logs

How to export logs for your Cloud Database Instance

One of the difficulties in operating and managing a Rackspace Cloud Database instance is that you do not have direct filesystem level access to the database in order to look at the logs that would typically be saved on your server. However, it is possible to use an API call to export the mysqld.log, mysql-slow.log, and /var/log/daemon.log to a Cloud Files container on your account for troubleshooting. The guide below will walk you through this process.

Prerequisites

Obtaining Your API Token

  1. Using cURL, replace $username and $api_key with your own credentials.
curl -s -X "POST" "https://identity.api.rackspacecloud.com/v2.0/tokens" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
  "auth": {
    "RAX-KSKEY:apiKeyCredentials": {
      "username": "$username",
      "apiKey": "$api_key"
    }
  }
}' | jq -cr '.access.token.id'

  1. After running the cURL command above, if successful you'll get a long string of alpha-numeric characters. This is your API Token, so save this somewhere you can grab it again. Be aware that this token is only valid for 24 hours before you'll need to obtain a new one.

Exporting and Saving the Logs

Now that you've got your API token, you can send the API call to initiate the export and saving of the Cloud Database logs. You'll just need to replace the following values with your own:

  • $REGION: The region your Cloud Database is in. (ex: iad)
  • $TENANT_ID: Your Cloud Account Number
  • $DB_INSTANCE_ID: Your Cloud Database ID
  • $TOKEN: Your API Token
curl -X POST https://$REGION.databases.api.rackspacecloud.com/v1.0/$TENANT_ID/instances/$DB_INSTANCE_ID/action \
-H "x-auth-token: $TOKEN" \
-H "Content-type: application/json" \
-d '{
  "save_logs": {
    "allow_ha": true
  }
}'

Viewing the Logs

After you've run the export call, you'll be able to find your logs in your account under the Cloud Files Container named z_MYSQL_LOGS. You can find this under the Storage > Files section of your Control Panel.