Documentation
tutorials/superset-setup.md
Apache Superset Analytics for Acsis Dynaplex Platform
Overview
Apache Superset is integrated into the Dynaplex platform to provide powerful data analytics and visualization capabilities. Superset runs as a containerized service alongside your other components and has direct access to your application database.
Quick Start
1. Enable Analytics in Your AppHost
Add Superset to your foundation configuration:
var foundation = builder.AddFoundation()
.WithDatabase()
.WithAnalytics() // π Adds Superset + Redis
// ... register your components
.Build();
foundation.Run();
2. Start Aspire
# From repository root
dotnet run --project projects/bbu-rfid/src/Acsis.Dynaplex.Projects.BbuRfid/Acsis.Dynaplex.Projects.BbuRfid.csproj
3. Access Superset
Note: The local Superset port is dynamically assigned by Aspire to enable multiple simultaneous instances.
To find the current Superset URL:
- Open the Aspire Dashboard (URL shown when AppHost starts)
- Find the "superset" resource
- Click on its endpoint to open Superset
- Local Development: Check Aspire Dashboard for current port
- Azure Deployment: Check Azure Container App URL in Aspire dashboard
4. Login
Default Credentials:
- Username:
admin - Password:
admin
β οΈ IMPORTANT: Change the default password immediately in production!
Architecture
Local Development
βββββββββββββββββββββββββββββββββββββββββββββββ
β Aspire AppHost β
βββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β βPostgreSQLβ β Redis β β Superset β β
β β β β β β β β
β β acsis db ββββ€ cache ββββ€ :8088 β β
β β ss schemaβ β β β β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β² β β
β β βΌ β
β ββββββ΄ββββββββββββββββββββββββββββββββββ β
β β Component Services (CoreData, etc.) β β
β ββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββ
Azure Deployment
βββββββββββββββββββββββββββββββββββββββββββββββ
β Azure Container Apps β
βββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββ β
β β PostgreSQL β β Redis β β
β β Flexible β β Cache β β
β β Server ββββ€ (Basic) β β
β β β β β β
β ββββββββββββββββ ββββββββββββ β
β β² β² β
β β β β
β ββββββββ΄ββββββββββββββββ΄βββββββββββββββββ β
β β Superset Container App β β
β β (ca-superset-{group}) β β
β β Public ingress enabled β β
β βββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββ
Database Schema
Superset stores its metadata (dashboards, users, permissions, etc.) in the ss schema of your main acsis database:
- Database:
acsis(shared with all Dynaplex components) - Schema:
ss(isolated Superset metadata) - Application Data:
publicschema (accessible for analytics)
This approach:
- β Simplifies deployment (no separate database needed)
- β Isolates Superset tables from application data
- β Allows Superset to query all component data directly
Connecting to Application Data
Step 1: Add Database Connection
- Navigate to Settings β Database Connections
- Click + Database
- Select PostgreSQL
- Configure connection:
Local Development:
Host: postgres
Port: 5432
Database: acsis
Username: postgres
Password: postgres
Display Name: Acsis Application Data
Azure Deployment:
Host: {your-postgres-server}.postgres.database.azure.com
Port: 5432
Database: acsis
Username: postgres
Password: {your-password}
SSL: Required
Display Name: Acsis Application Data
Step 2: Test Connection
Click Test Connection to verify Superset can access the database.
Step 3: Explore Data
- Navigate to SQL Lab β SQL Editor
- Select your "Acsis Application Data" database
- Browse schemas and tables
- Run test queries
Creating Your First Dashboard
1. Create a Dataset
- Go to Data β Datasets
- Click + Dataset
- Select:
- Database: Acsis Application Data
- Schema: public (or your component's schema)
- Table: Choose a table (e.g.,
users,assets, etc.)
- Click Add
2. Create a Chart
- Go to Charts β + Chart
- Select your dataset
- Choose a chart type (e.g., Table, Bar Chart, Line Chart)
- Configure:
- Metrics: What to measure (COUNT, SUM, AVG, etc.)
- Dimensions: How to group/filter data
- Filters: Narrow down data
- Click Run Query to preview
- Click Save and name your chart
3. Build a Dashboard
- Go to Dashboards β + Dashboard
- Name your dashboard
- Drag and drop charts onto the canvas
- Resize and arrange as needed
- Add filters for interactivity
- Click Save
Configuration Files
Superset configuration is stored in docs/internal/implementation-plans/superset/:
superset/
βββ config.py # Main Superset configuration
βββ init-schema.sql # PostgreSQL schema creation
βββ init-podman.sh # Manual initialization script
βββ docker-entrypoint.sh # Container auto-init entrypoint
βββ docker-compose.yml # Standalone docker compose (reference)
Key Configuration Settings
config.py highlights:
# Database connection (auto-configured via environment)
SQLALCHEMY_DATABASE_URI = postgresql://postgres@postgres:5432/acsis
# Schema isolation
SQLALCHEMY_ENGINE_OPTIONS = {
'connect_args': {
'options': '-csearch_path=ss,public'
}
}
# Redis caching
CACHE_CONFIG = {
'CACHE_TYPE': 'RedisCache',
'CACHE_REDIS_URL': 'redis://superset-redis:6379/0'
}
# Performance tuning
ROW_LIMIT = 50000
SUPERSET_WEBSERVER_TIMEOUT = 300
Manual Initialization
If automatic initialization fails, you can manually initialize Superset:
# Get the Superset container ID
docker ps | grep superset
# Run initialization script inside container
docker exec <container-id> /app/pythonpath/init-podman.sh
# Or step by step:
docker exec <container-id> superset db upgrade
docker exec <container-id> superset fab create-admin --username admin --password admin --email admin@acsis.local
docker exec <container-id> superset init
Troubleshooting
Superset won't start
Check logs:
# Via Aspire Dashboard
# Navigate to Superset resource β View Logs
# Or via Docker
docker logs <superset-container-id>
Common issues:
- PostgreSQL not ready: Superset waits up to 60s, check DB is running
- Redis not available: Check redis container is running
- Schema doesn't exist: Manually run
init-schema.sqlon your database
Can't connect to database
Verify connection:
# Test PostgreSQL connection from Superset container
docker exec <superset-container-id> psql -h postgres -U postgres -d acsis -c '\dt ss.*'
Check environment variables:
docker exec <superset-container-id> env | grep DATABASE
Charts are slow
- Enable caching: Already configured via Redis
- Check indexes: Ensure your database tables have proper indexes
- Limit row count: Adjust ROW_LIMIT in config.py
- Use aggregations: Pre-aggregate data in views
Can't login
Reset admin password:
docker exec -it <superset-container-id> superset fab reset-password --username admin
Schema changes not visible
Sync metadata:
- Go to Data β Databases
- Click your database
- Click Sync columns from source (in Advanced settings)
Advanced Configuration
Custom Admin User
Set environment variables before starting:
.WithEnvironment("SUPERSET_ADMIN_USERNAME", "your-username")
.WithEnvironment("SUPERSET_ADMIN_PASSWORD", "your-secure-password")
.WithEnvironment("SUPERSET_ADMIN_EMAIL", "you@company.com")
Enable CORS (for embedding)
Edit config.py:
ENABLE_CORS = True
CORS_OPTIONS = {
'origins': ['https://your-app.com'],
'supports_credentials': True
}
Increase Worker Count (performance)
For Azure Container Apps:
.WithEnvironment("SUPERSET_WORKERS", "8") // More workers for high load
.WithEnvironment("SUPERSET_THREADS", "40") // More threads per worker
SSL/TLS for PostgreSQL (Azure)
Azure PostgreSQL requires SSL. The connection will automatically use SSL when connecting to Azure:
# config.py automatically handles this
SQLALCHEMY_ENGINE_OPTIONS = {
'connect_args': {
'sslmode': 'require' # Added automatically for Azure
}
}
Security Best Practices
- Change default password: First thing after deployment
- Enable authentication: Configure OAuth, LDAP, or SAML in production
- Restrict access: Use Superset's role-based access control (RBAC)
- Use secrets: Store passwords in Azure Key Vault or environment variables
- Enable HTTPS: Use Azure Container Apps with custom domains
- Regular backups: Backup the
ssschema for disaster recovery
Performance Tuning
Database Query Optimization
- Add indexes: On frequently queried columns
- Create views: Pre-aggregate common queries
- Partition tables: For large time-series data
- Use materialized views: For complex aggregations
Superset Optimization
- Redis caching: Already configured, adjust timeouts in config.py
- Async queries: Enable for long-running queries
- SQL Lab: Limit result row count
- Dashboard filters: Use parameter caching
Monitoring
Via Aspire Dashboard
- Resource status: Check Superset health in resources list
- Logs: View real-time logs for errors
- Metrics: CPU, memory usage
Superset Internal Metrics
- Navigate to Settings β List Users to see activity
- Check SQL Lab β Query History for slow queries
- Use Chart β Run History to find performance issues
Integration with Other Tools
Export Data
Superset can export:
- Charts: PNG, CSV, JSON
- Dashboards: PDF (requires additional setup)
- Datasets: CSV, Excel
Programmatic Access
Use Superset's REST API:
# Get auth token
curl -X POST http://localhost:8088/api/v1/security/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin","provider":"db"}'
# List dashboards
curl -X GET http://localhost:8088/api/v1/dashboard/ \
-H "Authorization: Bearer <token>"
Component-Specific Analytics Guides
Once you have Superset set up, check out these component-specific guides for pre-built views and dashboards:
- BBU Superset Analytics - BBU RFID pipeline analytics with Oracle ingestion tracking, OBLPN shipment views, and component breakdown dashboards
Resources
- Superset Documentation: https://superset.apache.org/docs/intro
- SQL Lab Guide: https://superset.apache.org/docs/using-superset/exploring-data
- API Reference: https://superset.apache.org/docs/api
- Community: https://github.com/apache/superset
Support
For issues specific to the Dynaplex integration:
- Check this documentation
- Review container logs in Aspire Dashboard
- Verify database connectivity
- Check configuration files in
docs/internal/implementation-plans/superset/
For general Superset questions:
- Apache Superset GitHub: https://github.com/apache/superset/issues
- Slack Community: https://join.slack.com/t/apache-superset/shared_invite/