Skip to main content
You can use Query History export to bring Query History data to an external monitoring solution for further analysis. In this recipe, we will show you how to export Query History data to Amazon S3, and then analyze it using Cube by reading the data from S3 using DuckDB.

Configuration

Vector configuration for exporting Query History to Amazon S3 and also outputting it to the console of the Vector agent in your Cube Cloud deployment. In the example below, we are using the aws_s3 sink to export the cube-query-history-export-demo bucket in Amazon S3, but you can use any other storage solution that Vector supports.
You’d also need to set the following environment variables in the Settings → Environment variables page of your Cube Cloud deployment:
The aws_s3 sink can also authenticate with the deployment’s OIDC identity instead of an access key pair — the credentials apply to the whole Vector agent. See Keyless authentication.This replaces the CUBE_CLOUD_MONITORING_AWS_* pair above, which is Vector’s write path only. The CUBEJS_DB_DUCKDB_S3_* variables are separate — they belong to the DuckDB data source that reads the exported files back in Data modeling, and are still required.

Data modeling

Example data model for analyzing data from Query History export that is brought to a bucket in Amazon S3. The data is accessed directly from S3 using DuckDB. With this data model, you can run queries that aggregate data by dimensions such as status, environment_name, api_type, etc. and also calculate metrics like count, total_duration, or avg_duration:

Result

Example query in Playground: