Concepts
Query directly from source
Zenskar can connect to a data source by syncing it into Zenskar, or by querying it live. With Directly from source, no data is copied into Zenskar. Each time a billable metric runs, Zenskar sends the SQL straight to your Redshift cluster or workgroup and returns the live result. This means no sync lag and no duplicate copy of your data, but it also means Redshift must be reachable from Zenskar’s servers for every query, not just during initial setup.Why network access matters
Since queries run live, Zenskar’s servers need an open path to your cluster or workgroup on every request. That is why the endpoint must be reachable (publicly, or via private networking), and why the VPC security group must allow inbound traffic from Zenskar’s IP address on port 5439. If this path is missing, a connection typically hangs and times out rather than failing with a clear error, so it is worth confirming before setup.How SSL fits in
Redshift presents a trusted certificate by default, so encryption works out of the box with SSL mode and certificate fields left blank. Full certificate verification (verify-ca or verify-full) is an extra layer for organizations whose security policy requires it, not a replacement for the default encryption, and most setups do not need it.
How billable metrics use a remote data source
A metric’s SQL builder can pull from synced data or remote data. Choosing Remote data and a Redshift source created with Directly from source is what lets the metric query Redshift each time it runs. Zenskar variables, such as customer external ID and billing start and end dates, are placeholders substituted at run time, so one query can serve every customer and billing period instead of needing a separate query for each.How-to guides
How to add Amazon Redshift as a data source
Before you begin, gather your connection details and confirm your Redshift endpoint is reachable from Zenskar’s servers. You can find the endpoint in the AWS console, under Amazon Redshift > your cluster or Redshift Serverless > Workgroup configuration > General information. Copy only the endpoint host, the part before:5439/dev.
1
Open the data sources page
From the left navigation, go to Data sources, then click Add new data source in the top right.
2
Select Amazon Redshift
In the source type list, choose Amazon Redshift.
3
Choose direct access
Under Source access, select Directly from source. This is the option that lets a billable metric query Redshift live, without syncing data into Zenskar.
4
Enter the connection details
Fill in the connection fields using the values you gathered: host, port, database name, username, schema, and password.
5
Configure SSL
Leave SSL connection enabled. For a standard setup, leave SSL mode and the certificate fields blank. Only set SSL mode to
verify-ca or verify-full, and paste your Amazon Redshift CA certificate, if your security policy requires full certificate verification. Client certificate and client key fields are not used by Redshift and should stay blank.6
Save
Click Save. The new data source appears in your list with status Active and is immediately ready to query.
Connection and SSL reference
Look up every connection field, network access requirement, and SSL option.
How to query Redshift from a billable metric
1
Open the SQL builder
Go to Usage > Billable metrics, create a new metric or open an existing one, then switch to the SQL builder tab.
2
Set the source to remote data
Under Source of data, select Remote data instead of Synced data. From the Remote datasource dropdown, choose the Amazon Redshift source you created earlier.
If the dropdown is empty, the source was not created with Directly from source access. Go back and check the previous how-to guide.
3
Browse your tables
Use the Data Navigator panel to browse the tables Zenskar can see in your Redshift database. Click a table to insert its name into the query editor.
4
Write your query
Write standard SQL against your Redshift tables. Use the Zenskar Variables tab to insert billing context values, such as Customer External ID, Billing Start Date, and Billing End Date, that Zenskar fills in at run time.
5
Preview the result
In the Query preview bar, pick a customer and a billing period, then click Run query to see the rows Zenskar returns from Redshift.
Make sure your test data falls inside the chosen billing period, or the result will be empty.
6
Save the metric
When the preview looks correct, click Save changes. The metric now queries Redshift live whenever it runs.
Zenskar variables reference
See every variable available in the SQL builder and what each one does.
Redshift SQL notes
Check syntax rules and unsupported functions before you write your query.
Reference
Connection detail fields
Network access requirements
SSL options
Zenskar variables available in the SQL builder
Redshift SQL notes and limitations
- Quote reserved words, such as
"timestamp", in double quotes. - Redshift does not support every PostgreSQL function. Catalog helpers such as
pg_table_sizeandobj_descriptionare not available. - Ordinary
SELECTqueries against your tables work normally.