A Streamlit web application to easily connect Aiven PostgreSQL and ClickHouse services to DataHub for metadata discovery and governance.
- 🔐 Secure token-based authentication for both Aiven and DataHub
- 📋 Automatic discovery of PostgreSQL and ClickHouse services from Aiven
- 🗄️ Database selection for PostgreSQL services (supports custom databases)
- 📊 Schema selection and filtering for PostgreSQL
- 🚀 One-click connector creation in DataHub
- ⚙️ Configurable schema and table patterns
- 👁️ Recipe preview before ingestion
- 📜 Real-time status and results display
- Python 3.8 or higher
- Aiven account with API token
- DataHub instance with Personal Access Token (PAT)
- PostgreSQL services on Aiven (optional: ClickHouse services)
- Clone this repository:
git clone <your-repo-url>
cd aiven_datahub_pg- Create a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Start the Streamlit app:
streamlit run app.py-
The app will open in your browser (typically at
http://localhost:8501) -
Configure your tokens in the sidebar:
- Aiven API Token: Your Aiven API token (obtain from Aiven Console → Account → API Tokens)
- DataHub GraphQL URL: Your DataHub GraphQL API endpoint (e.g.,
http://your-datahub-host:8080/api/graphql) - DataHub Access Token: Your DataHub Personal Access Token (generate in DataHub UI → Settings → Access Tokens)
-
Select a project and service:
- Choose an Aiven project from the dropdown
- Select PostgreSQL or ClickHouse services to connect
-
For PostgreSQL services:
- Fetch Databases: Click to discover available databases (or manually enter database name)
- Select Database: Choose which database to ingest
- Fetch Schemas: Discover available schemas in the selected database
- Select Schemas: Choose specific schemas to include (or use regex patterns)
- Configure Filters:
- Exclude system schemas (recommended)
- Optionally exclude 'public' schema
- Set table pattern filters
- Preview Recipe: Review the generated DataHub recipe before ingestion
-
Click "🚀 Create DataHub Connectors" to create and execute ingestion jobs
- Service Discovery: Uses Aiven API to fetch all PostgreSQL and ClickHouse services across your projects
- Connection Info Extraction: Retrieves connection details (host, port, credentials) from Aiven service details
- Database/Schema Discovery: For PostgreSQL, connects to the database to discover available databases and schemas
- Recipe Generation: Builds DataHub ingestion recipes with your selected configurations
- Connector Creation: Creates ingestion sources in DataHub using the GraphQL API
- Job Execution: Automatically triggers ingestion jobs for each created connector
- Database Selection: Choose from discovered databases or manually enter a database name
- Schema Selection:
- Select specific schemas by name (exact match)
- Or use regex patterns (e.g.,
.*for all,public|analyticsfor specific schemas)
- System Schema Exclusion: Automatically exclude PostgreSQL system schemas (
pg_catalog,information_schema, etc.) - Table Patterns: Use regex to filter tables (e.g.,
.*for all,^prod_.*for production tables)
- Uses default settings (all tables included)
- Automatically configures SSL connections via
uri_opts
- Verify your Aiven API token is correct
- Check that you have PostgreSQL/ClickHouse services in your Aiven projects
- Ensure the token has proper permissions
- pg_hba.conf errors: Aiven PostgreSQL may require IP whitelisting. You can manually enter the database name instead.
- Database 'postgres' does not exist: Aiven uses
defaultdbas the default database name. Try fetching databases or manually enterdefaultdb.
- Verify DataHub URL is correct and accessible
- Check that DataHub authentication is enabled
- Ensure the DataHub token is valid and not expired
- Verify database name is correct
- Check network connectivity to PostgreSQL
- Ensure SSL is properly configured (Aiven requires SSL)
- Tokens are stored only in session state (cleared on refresh)
- Never commit tokens to version control
- Use environment variables for production deployments
- Consider using Streamlit secrets management for sensitive data
streamlit run app.py --server.port 8502You can modify the app to read from environment variables:
export DATAHUB_URL="http://your-datahub:8080/api/graphql"
export DATAHUB_TOKEN="your-token"
export AIVEN_TOKEN="your-aiven-token"The app uses:
- Aiven API:
https://api.aiven.io/v1/project/{project}/service - DataHub GraphQL API:
{datahub_url}/api/graphql
MIT License - feel free to modify and use as needed.
Contributions are welcome! Please feel free to submit a Pull Request.