Keep your query history longer than 45 days - Amazon Athena

Keep your query history longer than 45 days

If you want to keep the query history longer than 45 days, you can retrieve the query history and save it to a data store such as Amazon S3. To automate this process, you can use Athena and Amazon S3 API actions and CLI commands. The following procedure summarizes these steps.

To retrieve and save query history programmatically
  1. Use Athena ListQueryExecutions API action or the list-query-executions CLI command to retrieve the query IDs.

  2. Use the Athena GetQueryExecution API action or the get-query-execution CLI command to retrieve information about each query based on its ID.

  3. Use the Amazon S3 PutObject API action or the put-object CLI command to save the information in Amazon S3.