Connect Query History

Set up daily query history ingestion from Trino, Spark, and Athena to power Query Acceleration recommendations.

Query History Connections tell Granica where to find your engine's query logs. Granica reads those logs daily, analyzes query patterns, and surfaces Query Acceleration recommendations — such as optimal sort keys, Z-ordering, and file right-sizing — for your most frequently queried tables.

Each connection targets a single query-log prefix (S3, GCS, or ABFS) and runs once per UTC day at a configured time. An initial sync runs immediately when a connection is created.

Granica Query History Connections — connection list and Add Connection dialog

Query History Connections require Admin access. Viewers and Editors cannot create or manage connections.

Supported engines

EngineLog formatNotes
TrinoTrino event listener logsPoint to the root prefix where Trino writes its query event JSON files
SparkSpark event logsPoint to the Spark History Server log directory (e.g. the eventlog prefix on S3/GCS)
AthenaAthena query execution historyPoint to the S3 prefix where Athena writes query results and execution metadata

Add a connection

  1. Navigate to Query History Connections in the Granica Console sidebar.
  2. Click Add Connection.
  3. Fill in the connection form:
FieldDescription
NameOptional label shown in the connections table (e.g. prod-trino-logs). If left blank, Granica uses the last segment of the log prefix URI.
EngineThe query engine that produced the logs: Trino, Spark, or Athena.
Query logs prefixS3, GCS, or ABFS URI pointing to the root of the engine's query log output (e.g. s3://my-bucket/trino-logs/).
Lookback (days)How many days of query logs to scan on each daily run. Range: 1–365 days. Default: 7 days.
Daily sync time (UTC)The UTC time at which the daily sync should run (e.g. 06:00). The scheduler checks every 15 minutes and fires the sync the first time it ticks past this time.
  1. Click Create & sync now.

Granica immediately starts an initial sync regardless of the configured daily sync time. Subsequent syncs run daily at the configured UTC time.

Monitor connections

The connections table shows the status of each configured connection:

ColumnDescription
ConnectionThe connection name (or log prefix if no name was set) and the full URI
EngineThe query engine type (Trino, Spark, or Athena)
LookbackThe number of days of logs scanned per run
Daily sync (UTC)The scheduled time for the daily sync
Last syncStatus of the most recent run: Never synced, Syncing, Succeeded, or Failed (hover over Failed for the error detail)
StateActive or Paused

While a sync is in progress, the Last sync column shows Syncing with a spinner. The table auto-refreshes every 5 seconds when any sync is running.

Manage connections

Click the menu on any connection row to access management options:

  • Edit — Update the name, log prefix, engine type, lookback window, or sync time. Changes take effect on the next sweep tick.
  • Pause / Resume — Suspend daily syncs without deleting the connection. Paused connections are dimmed in the table and cannot be manually synced.
  • Delete — Permanently remove the connection and all associated historical recommendations. This cannot be undone.

To trigger an immediate sync outside of the scheduled time, click the sync (↻) icon on any active connection row.

Log prefix requirements

Granica needs read access to the configured log prefix in your cloud storage. Ensure the IAM role or service account used by Granica's data plane has s3:GetObject / storage.objects.get permissions on the log bucket.

Trino

Configure Trino's event listener to write query events to a cloud storage prefix. Point the connection at the root of that prefix.

Spark

Set spark.eventLog.enabled=true and spark.eventLog.dir=s3://your-bucket/spark-logs/ in your Spark configuration. Point the connection at the same spark.eventLog.dir prefix.

Athena

Athena writes query execution metadata to the Query result location configured in your workgroup settings. Point the connection at that S3 prefix (e.g. s3://your-bucket/athena-results/).

See also

Was this page helpful?

On this page