DocumentationAPI Reference
Documentation

Usage Data

Send your Prequel usage data to your own data warehouse

Overview

You can receive your Prequel usage data in your own data warehouse, using any of our supported destination vendors. Contact Prequel support to enable and configure this feature.

Once you configure your usage data destination, Prequel syncs three tables to your destination: audit_log, destinations_snapshot, and model_transfers_log. By default, this data is refreshed hourly.

Data format

Right now, Prequel syncs three tables to your destination: audit_log, destinations_snapshot, and model_transfers_log.

audit_log

Each row in this table corresponds to one event in the audit log, and is the same data available via the /logs endpoint. These logs are intended to be a comprehensive record of all write actions taken on your Prequel account. For more information, including the events included in this table, see the audit log documentation.

Field NameData TypeDescription
event_idstringAudit log ID. This ID is the same as the /logs endpoint.
occurred_attimestampTimestamp when event occurred, corresponds to created_at in logs endpoint, reported in UTC.
event_typestringThe type of event.
resource_idstringThe ID of the resource involved in the event.
actor_idstringThe identifier of the actor who initialized the event. Some historical events have the value unknown.
actor_typestringThe type of actor who initialized the event. The possible values are unknown, user, api_key, recipient.
current_resourcejsonNullable JSON object representing the current state of the resource. DELETE operations will never have this field populated. Some historical events do not have this field populated.
previous_resourcejsonNullable JSON object representing the previous state of the resource. CREATE operations will never have this field populated. Some historical events do not have this field populated.

destinations_snapshot

Each entry in this table corresponds to one destination in your Prequel account. Note that this table represents the current state of destinations configured in Prequel. To get a historical record of actions taken on destinations, you can use the audit log data.

Field NameData TypeDescription
destination_idstringDestination ID in the Prequel API.
is_enabledboolWhether scheduled syncs are enabled on this destination.
updated_attimestampTimestamp when the destination was last updated.
created_attimestampTimestamp corresponding to when the destination was first created.
recipient_idstringThe ID of the recipient the destination is assigned to.
id_in_provider_systemstringThe ID in the source provider system, corresponds to the tenant schema in schema tenanting mode.
productsjsonJSON array of objects representing assigned products. Each entry has the fields id and name.
frequency_minutesintThe frequency at which Prequel’s scheduler enqueues transfers to this destination.
enabled_modelsjsonJSON array representing the enabled models for this destination. Each entry has the fields id and name.
has_all_models_enabledboolIndicates whether the destination inherits all current and future models on its products.
destination_namestringThe name of the destination.
destination_vendorstringThe vendor of the destination.
max_concurrent_transfersintMaximum number of simultaneous transfers allowed.
max_concurrent_queries_per_transferintMaximum number of concurrent queries allowed per transfer.

model_transfers_log

Each entry in this table corresponds to one completed model transfer within a transfer job. Model transfers that are pending or in progress are not currently included in this table.

Field NameData TypeDescription
model_transfer_idstringModel ID concatenated with transfer ID. This ID only appears within Prequel's usage data.
transfer_idstringThe ID of the transfer in the API.
model_idstringThe ID of the model being transferred.
model_transfer_idstringA unique ID for the model transfer, combining transfer ID and model ID.
model_namestringThe name of the model being transferred.
source_idstringThe ID of the source from which the model was read.
source_namestringThe name of the source from which the model was read.
source_vendorstringThe vendor of the source from which the model was read.
destination_idstringThe ID of the destination to which the model was written.
recipient_idstringThe ID of the recipient for the destination.
id_in_provider_systemstringThe ID in the provider system, corresponds to the tenant schema.
destination_namestringThe name of the destination.
destination_vendorstringThe vendor type of the destination.
is_full_refreshboolIndicates whether the transfer was a full refresh.
transfer_submitted_attimestampTimestamp when the transfer was submitted.
transfer_started_attimestampTimestamp when the worker began executing the model transfer.
transfer_ended_attimestampTimestamp when the model transfer completed.
transfer_start_window_attimestampLower bound timestamp for the data transferred.
transfer_end_window_attimestampUpper bound timestamp for the data transferred.
statusstringThe status of the model transfer (e.g., SUCCESS, ERROR, CANCELLED).
error_tracestringDetailed error message in case of a transfer error.
error_codestringError code corresponding to the transfer error.
error_blamestringThe party responsible for the error.
error_messagestringError message for the model transfer.
documentation_urlstringURL to documentation for further information on the error.
transfer_logjsonTransfer log information.
billing_datedateThe date on which Prequel will bill for this transfer. This is the date of the transfer ended_at at time zone US/Pacific.
rows_transferredbigintTotal number of rows transferred for this model.
delta_rows_transferredbigintApproximate total number of active rows (inserts and updates) for this model.
volume_transferred_in_mbfloatThe memory footprint of the data transferred.

Example queries

Rows transferred by day

How many rows have we transferred over the past month for this destination, grouped by day?

SELECT
  DATE(transfer_ended_at) AS transfer_date,
  SUM(rows_transferred) AS total_rows_transferred
FROM
  `{{your-schema}}.model_transfers_log`
WHERE
  destination_id = '{{your-destination-id}}'
  AND transfer_ended_at >= CAST(CURRENT_DATE - INTERVAL '1 MONTH' AS TIMESTAMP)
GROUP BY
  transfer_date
ORDER BY
  transfer_date;

Latest transfer status for a model

For a given destination and model, what is the latest transfer status? Has a transfer been triggered? When was it last full-refreshed?

WITH LatestStatus AS (
  SELECT
    model_id,
    MAX(transfer_ended_at) AS last_transfer_time,
    ARRAY_AGG(status ORDER BY transfer_ended_at DESC LIMIT 1)[OFFSET(0)] AS latest_status
    MAX(CASE WHEN is_full_refresh THEN transfer_ended_at ELSE NULL END) AS last_full_refresh_time
  FROM
    `{{your-schema}}.model_transfers_log`
  WHERE
    destination_id = '{{your-destination-id}}'
  GROUP BY
    model_id
)
SELECT
  l.model_id,
  l.latest_status,
  l.last_transfer_time,
  l.last_full_refresh_time,
  CASE
    -- Have we ever triggered a transfer for this model?
    WHEN l.latest_status IS NULL THEN false
    ELSE true
  END AS transfer_has_been_triggered
FROM
  LatestStatus l
LEFT JOIN
  `{{your-schema}}.destinations_snapshot` d
  ON d.destination_id = '{{your-destination-id}}';

Billing metrics

For a given billing date and destination, what are the transfer metrics?

SELECT
  billing_date,
  destination_id,
  COUNT(*) AS count_transfers,
  COUNTIF(status = 'SUCCESS') AS count_transfers_succeeded,
  COUNTIF(status = 'ERROR') AS count_transfers_error,
  SUM(COALESCE(rows_transferred, 0)) AS total_rows_transferred,
  SUM(COALESCE(volume_transferred_in_mb, 0)) AS total_volume_transferred_mb,
  SUM(COALESCE(delta_rows_transferred, 0)) AS total_deltas_transferred,
  SUM(TIMESTAMP_DIFF(transfer_ended_at, transfer_started_at, SECOND)) AS total_transfer_time,
  SUM(TIMESTAMP_DIFF(transfer_started_at, transfer_submitted_at, SECOND)) AS total_queue_wait_time,
  SUM(TIMESTAMP_DIFF(transfer_ended_at, transfer_started_at, SECOND)) AS total_execution_time
FROM
  `prql-dev.testusagereporting.model_transfers_log`
GROUP BY
  billing_date, destination_id
ORDER BY
  billing_date DESC;

Destination update history

What is the update history for a given destination?

SELECT
  DATE(occurred_at) AS update_date,
  occurred_at AS update_timestamp,
  actor_id,
  actor_type,
  resource_id AS destination_id,
  previous_resource,
  current_resource
FROM
  `{{your-schema}}.audit_log`
WHERE
  event_type = 'DESTINATION_UPDATE'
  AND resource_id = '{{your-destination-id}}'
ORDER BY
  occurred_at DESC;