Skip to main content

Data sources

Data sources: usage data stored in your systems

A data source is a system in your data infrastructure that stores usage data. Zenskar reads each data source through one data-source connector, such as PostgreSQL. The connection settings of the data source, such as its address and credentials, tell the data-source connector how to reach it. Zenskar reads the usage data in a data source, such as the table api_calls in your data system, in one of two ways: A billable metric then aggregates the usage data. The data-source connector and the connection settings of a data source cannot change after the data source is created, so a different connection needs a new data source. A data source cannot be deleted. See Add a data source.

Data-source connectors: how Zenskar reads a data source

A data-source connector is the software component through which Zenskar reads one kind of data source, such as PostgreSQL. Zenskar has 16 data-source connectors, in three groups. Each data-source connector has its own connection settings, which its document explains:

Data-source access: synced or remote

A data source gives Zenskar access to its usage data in one of two ways:
  • A synced data source is a data source whose usage data Zenskar copies on a schedule.
  • A remote data source is a data source whose usage data Zenskar queries in place.
Synced usage data is the row-and-column representation of a synced data source that Zenskar stores. The data-source connector shows each kind of data that a synced data source holds as a table, with one column for each field, such as a database table, a MongoDB collection, a sheet in Google Sheets, or the orders of a Shopify store. You choose the tables and columns after the data source is created, and each sync copies them into the synced usage data.

This conceptual diagram shows how a data-source connector turns the usage data of a synced data source into synced usage data.

For a remote data source, a billable metric reads the usage data each time Zenskar runs it for one customer and one period. Zenskar first fills in the Zenskar SQL variables of the SQL query, such as the dates of the period. The data-source connector then passes the query to the remote data source unchanged. The remote data source runs the query in its own SQL.
Zenskar does not translate the query, so you write it in the SQL of the remote data source, such as GoogleSQL for BigQuery.
The remote data source returns the rows of the result. Zenskar takes the number of the billable metric from those rows. See SQL builder: a billable metric as an SQL query.

This conceptual diagram shows how a billable metric reads the usage data of a remote data source.

The data-source connector decides which access is possible: When both are possible, a remote data source is the default. The access is part of the connection settings, so it cannot change after the data source is created.

Sync frequency: how current the synced usage data is

The sync frequency is how often Zenskar updates the synced usage data of a synced data source. The sync frequency is every 1, 2, 3, 4, 6, 12, or 24 hours, and the default is every 12 hours. A sync can also run on demand, between scheduled syncs. Syncing can be paused and resumed. While syncing is paused, the synced usage data stays as it was at the last sync. Usage data that reaches the data source after the last sync is not in the synced usage data until the next sync, so a billable metric does not see it yet. See Change the sync frequency. See Sync now, pause, or resume syncing.

Cursor columns: which rows a sync adds

A cursor column is a column of a chosen table whose values tell Zenskar which rows are new since the last sync. With a cursor column, each sync adds the new rows to the table in the synced usage data. For example, with the cursor column timestamp, each sync adds the rows of api_calls whose timestamp is later than any row at the last sync. Without a cursor column, each sync replaces the whole table. A cursor column must be one of the chosen columns. See Choose the tables and columns to sync.