What You Can Do
With the PostgreSQL integration, you can:- Track any database metric - Run custom SQL queries to pull any numeric value from your database
- Use the Visual Query Builder - Build queries visually by selecting tables, columns, and aggregations without writing SQL
- Write raw SQL queries - Full SQL flexibility for complex metrics, joins, and custom calculations
- Filter by time ranges - Automatically filter data by last 24 hours, 7 days, 30 days, 90 days, or 365 days
- Test queries before saving - Verify your query returns the expected value before linking to goals
- Set refresh intervals - Choose hourly, daily, or weekly metric updates
- Track multiple metrics - Connect to any number of tables and views in your database
Connecting PostgreSQL
Navigate to Settings
Click your profile menu in the top-right corner and select Settings, then go to Integrations
Enter Connection Details
In the configuration dialog, enter:
- Integration Name - A name to identify this connection (e.g., “Production Database”)
- Host - Your database server hostname or IP address
- Port - Database port (defaults to 5432)
- Database Name - The name of your database
- Username - Database user with read access
- Password - Database password
- Require SSL - Enable for secure connections (recommended)
For security, we recommend creating a read-only database user with access only to the tables you need for metrics. This minimizes risk while allowing Kasava to query your data.
Creating a Read-Only Database User
For production databases, create a dedicated read-only user:Linking Metrics to Goals
Once connected, you can link PostgreSQL metrics to your product goals for automatic progress tracking.
Query Modes
PostgreSQL supports two query modes for maximum flexibility:Visual Query Builder
Build queries visually without writing SQL. Perfect for common aggregations.| Setting | Description |
|---|---|
| Table | Select from available tables and views in your database |
| Aggregation | Count (rows), Sum, Average, Maximum, Minimum, Count Distinct |
| Column | For non-count aggregations, select the numeric column to aggregate |
| Time Column | Optional - select a timestamp column to filter by time |
| Time Range | Last 24 hours, 7 days, 30 days, 90 days, 365 days, or All time |
- Count all users: Table =
users, Aggregation =Count (rows) - Sum of revenue: Table =
orders, Aggregation =Sum, Column =amount - Average order value: Table =
orders, Aggregation =Average, Column =amount - New users this month: Table =
users, Aggregation =Count (rows), Time Column =created_at, Time Range =Last 30 days
Raw SQL
Write custom SQL for complex metrics. Your query must return exactly one row with one numeric column.Aggregation Types
When using the Visual Builder, you can choose from these aggregation functions:| Aggregation | Description | Column Required |
|---|---|---|
| Count (rows) | Counts the number of rows | No |
| Sum | Sums all values in a numeric column | Yes (numeric) |
| Average | Calculates the mean of a numeric column | Yes (numeric) |
| Maximum | Finds the highest value | Yes (numeric) |
| Minimum | Finds the lowest value | Yes (numeric) |
| Count Distinct | Counts unique values in a column | Yes (any type) |
Time Filtering
Add time-based filtering to track metrics over specific periods:| Time Range | Description |
|---|---|
| Last 24 hours | Data from the past day |
| Last 7 days | Data from the past week |
| Last 30 days | Data from the past month |
| Last 90 days | Data from the past quarter |
| Last 365 days | Data from the past year |
| All time | No time filter applied |
- Select a Time Column (must be a timestamp, date, or datetime column)
- Choose your desired Time Range
Refresh Intervals
Choose how often Kasava fetches new data from your database:| Interval | Description |
|---|---|
| Hourly | Updates every hour - best for real-time dashboards |
| Daily | Updates once per day - best for most goals |
| Weekly | Updates once per week - best for long-term trends |
Testing Your Query
After configuring a metric query, always click Test Query before saving. This will:- Connect to your database using the stored credentials
- Execute your query against the database
- Display the current metric value
- Confirm the configuration returns valid results
A successful test shows a green success message with the current value. If the test fails, you’ll see an error message explaining what went wrong.
Managing Integrations
View Integration Status
Navigate to Settings > Integrations to see all connected PostgreSQL integrations and their status.Create Integration Metrics
You can create reusable metrics at the integration level that can be linked to multiple goals:Go to Integration Settings
Navigate to Settings > Integrations and click Manage on your PostgreSQL integration
Disconnect Integration
Disconnecting will stop all metric syncing for goals linked to this integration. Historical data will be preserved, but no new data will be fetched.
Use Cases
Product Metrics
Track user counts, feature adoption, and engagement:Business Metrics
Monitor revenue, subscriptions, and customer data:Technical Metrics
Track API performance, error rates, and system health:Troubleshooting
Connection failed: could not connect to server
Connection failed: could not connect to server
Verify your database host is accessible from the internet. If using a private network, you may need to whitelist Kasava’s IP addresses or set up a secure tunnel.
SSL connection required
SSL connection required
Enable the Require SSL checkbox in the connection settings. Most cloud database providers require SSL connections.
Permission denied for table
Permission denied for table
The database user doesn’t have SELECT permissions on the requested table. Grant access with:
Query returns no rows
Query returns no rows
Your query must return exactly one row. Wrap aggregations in your query or ensure your WHERE clause matches at least one record. Use
COALESCE to handle empty results:Query returns non-numeric value
Query returns non-numeric value
The query must return a numeric value. Cast text or other types to numeric:
Connection timeout
Connection timeout
Check if your database allows connections from external IPs. Cloud databases often require you to add Kasava’s IP addresses to an allowlist.
Tables not showing in Visual Builder
Tables not showing in Visual Builder
The database user may not have access to the information_schema or lacks SELECT permissions on certain tables. Verify permissions and try refreshing the table list.