> ## Documentation Index
> Fetch the complete documentation index at: https://zenskar.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Concepts: How data sources work

> This document explains data sources, the data-source connectors that Zenskar reads them through, synced and remote data sources, and how the sync frequency and cursor columns keep a synced data source current.

## Data sources

> [accordion] Map of concepts
>
> | Concept | What it is | What it is used for |
> | - | - | - |
> | [Data source](#data-sources-usage-data-stored-in-your-systems) | A system in your data infrastructure that stores usage data | Zenskar reads each data source through one data-source connector. |
> | [Data-source connector](#data-source-connectors-how-zenskar-reads-a-data-source) | The software component through which Zenskar reads one kind of data source | The data-source connector of a data source decides which access the data source can have. |
> | [Synced data source](#data-source-access-synced-or-remote) | A data source whose usage data Zenskar copies on a schedule | If a data source is a synced data source, a billable metric reads its synced usage data with the visual builder or the SQL builder. |
> | [Remote data source](#data-source-access-synced-or-remote) | A data source whose usage data Zenskar queries in place | If a data source is a remote data source, a billable metric reads it only with the SQL builder. |
> | [Synced usage data](#data-source-access-synced-or-remote) | The row-and-column representation of a synced data source that Zenskar stores | Each sync copies the chosen tables and columns of a synced data source into its synced usage data. |
> | [Sync frequency](#sync-frequency-how-current-the-synced-usage-data-is) | How often Zenskar updates the synced usage data of a synced data source | The sync frequency of a synced data source decides how current its synced usage data is. |
> | [Cursor column](#cursor-columns-which-rows-a-sync-adds) | A column of a chosen table whose values tell Zenskar which rows are new since the last sync | If a table has a cursor column, each sync adds the new rows to the synced usage data instead of replacing the table. |

## Data sources: usage data stored in your systems

A **data source** is a system in your data infrastructure that stores [usage data](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#usage).

Zenskar reads each data source through one [data-source connector](#data-source-connectors-how-zenskar-reads-a-data-source), such as [PostgreSQL](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/postgresql.md). 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:

* It copies the usage data on a schedule. The data source is then a [synced data source](#data-source-access-synced-or-remote).
* It queries the usage data in place. The data source is then a [remote data source](#data-source-access-synced-or-remote).

A [billable metric](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#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](https://zenskar.com/docs/20260301/zenskar-modules/usage/how-to-guides/data-sources.md#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](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/postgresql.md).

Zenskar has 16 data-source connectors, in three groups. Each data-source connector has its own connection settings, which its document explains:

| Group | Data-source connectors |
| - | - |
| Databases and data warehouses | [Amazon Athena](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/amazon-athena.md), [Amazon Redshift](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/amazon-redshift.md), [BigQuery](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/bigquery.md), [ClickHouse](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/clickhouse.md), [CockroachDB](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/cockroachdb.md), [Databricks](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/databricks-lakehouse.md), [MongoDB](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/mongodb.md), [MySQL](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/mysql.md), [PostgreSQL](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/postgresql.md), [Snowflake](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/snowflake.md) |
| Analytics tools | [Looker](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/looker.md), [Metabase](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/metabase.md) |
| Business apps | [Auth0](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/auth0.md), [Google Sheets](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/google-sheets.md), [QuickBooks](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/quickbooks.md), [Shopify](https://zenskar.com/docs/20260301/third-party-integrations/data-sources/shopify.md) |

## 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](https://en.wikipedia.org/wiki/Table_\(database\)) 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.

```mermaid theme={null}
sequenceDiagram
  autonumber
  participant S as Synced data source
  participant C as Data-source connector
  participant U as Synced usage data
  participant B as Billable metric
  C->>S: Reads each kind of data,<br/>such as a table, a MongoDB collection,<br/>or Shopify orders
  C->>C: Shows each kind of data as a table,<br/>with one column for each field
  C->>U: Copies the chosen tables and columns<br/>on each sync
  B->>U: Aggregates 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](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#zenskar-sql-variable) 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.

> [!NOTE]
>
> Zenskar does not translate the query, so you write it in the SQL of the remote data source, such as [GoogleSQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax) 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](https://zenskar.com/docs/20260301/zenskar-modules/usage/concepts/billable-metrics.md#sql-builder-a-billable-metric-as-an-sql-query).

```mermaid theme={null}
sequenceDiagram
  autonumber
  participant B as Billable metric
  participant C as Data-source connector
  participant R as Remote data source
  B->>B: Fills in the Zenskar SQL variables for one customer and period
  B->>C: Sends the SQL query
  C->>R: Passes the query unchanged
  R->>R: Runs the query in its own SQL
  R->>C: Returns the rows of the result
  C->>B: Returns the rows
  B->>B: Takes its number from the rows
```

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

| | Synced data source | Remote data source |
| - | - | - |
| Where a billable metric reads the usage data | In the synced usage data | In the data source itself |
| How current the usage data is | As current as the last sync. See [Sync frequency: how current the synced usage data is](#sync-frequency-how-current-the-synced-usage-data-is). | Current at each query |
| How a billable metric is built | With the [visual builder](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#visual-builder) or the [SQL builder](https://zenskar.com/docs/20260301/zenskar-modules/usage/glossary.md#sql-builder) | Only with the SQL builder |
| When it fits | It fits small to medium amounts of usage data that change on a regular cycle. | It fits large amounts of usage data, and usage data that changes in real time. |

The data-source connector decides which access is possible:

| Access | Data-source connectors |
| - | - |
| Synced data source or remote data source | Amazon Athena, Amazon Redshift, Databricks, MySQL, PostgreSQL, Snowflake |
| Remote data source only | BigQuery |
| Synced data source only | Auth0, ClickHouse, CockroachDB, Google Sheets, Looker, Metabase, MongoDB, QuickBooks, Shopify |

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](https://zenskar.com/docs/20260301/zenskar-modules/usage/how-to-guides/data-sources.md#change-the-sync-frequency).

See [Sync now, pause, or resume syncing](https://zenskar.com/docs/20260301/zenskar-modules/usage/how-to-guides/data-sources.md#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](https://zenskar.com/docs/20260301/zenskar-modules/usage/how-to-guides/data-sources.md#choose-the-tables-and-columns-to-sync).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.