0
# Configuration
1
2
Comprehensive configuration system for Apache Superset covering databases, security, caching, performance tuning, and feature flags.
3
4
## Capabilities
5
6
### Core Application Configuration
7
8
Base configuration settings for the Superset application.
9
10
```python { .api }
11
class SupersetConfig:
12
"""Base configuration class for Superset."""
13
14
# Server Configuration
15
SECRET_KEY: str = "YOUR_OWN_RANDOM_GENERATED_SECRET_KEY"
16
SUPERSET_WEBSERVER_PROTOCOL: str = "http"
17
SUPERSET_WEBSERVER_ADDRESS: str = "0.0.0.0"
18
SUPERSET_WEBSERVER_PORT: int = 8088
19
SUPERSET_WEBSERVER_TIMEOUT: int = 60
20
21
# Application Metadata
22
APP_NAME: str = "Superset"
23
APP_ICON: str = "/static/assets/images/superset-logo-horiz.png"
24
FAVICONS: List[Dict[str, Any]] = []
25
26
# Logging Configuration
27
LOG_FORMAT: str = "%(asctime)s:%(levelname)s:%(name)s:%(message)s"
28
LOG_LEVEL: str = "DEBUG"
29
ENABLE_TIME_ROTATE: bool = True
30
31
# Flask Configuration
32
FLASK_USE_RELOAD: bool = True
33
FLASK_ADMIN_SWATCH: str = "cosmo"
34
```
35
36
**Usage Examples:**
37
38
```python
39
# Custom configuration file (superset_config.py)
40
SECRET_KEY = 'my-secret-key'
41
SUPERSET_WEBSERVER_PORT = 8080
42
43
# Environment variables
44
import os
45
SECRET_KEY = os.environ.get('SUPERSET_SECRET_KEY', 'default-secret')
46
```
47
48
### Database Configuration
49
50
Database connection settings and SQLAlchemy configuration.
51
52
```python { .api }
53
# Primary Database Configuration
54
SQLALCHEMY_DATABASE_URI: str = "sqlite:///superset.db"
55
SQLALCHEMY_TRACK_MODIFICATIONS: bool = False
56
SQLALCHEMY_ENGINE_OPTIONS: Dict[str, Any] = {
57
"pool_pre_ping": True,
58
"pool_recycle": 300,
59
"pool_size": 10,
60
"max_overflow": 20
61
}
62
63
# Custom Password Stores
64
SQLALCHEMY_CUSTOM_PASSWORD_STORE: Optional[Callable[[str], str]] = None
65
66
# Database Connections Pool Settings
67
SQLALCHEMY_POOL_SIZE: int = 5
68
SQLALCHEMY_POOL_TIMEOUT: int = 30
69
SQLALCHEMY_POOL_RECYCLE: int = 1800
70
SQLALCHEMY_MAX_OVERFLOW: int = 10
71
SQLALCHEMY_ECHO: bool = False
72
73
# Query Execution Settings
74
SUPERSET_WEBSERVER_TIMEOUT: int = 60
75
SQLLAB_TIMEOUT: int = 300
76
SQLLAB_ASYNC_TIME_LIMIT_SEC: int = 600
77
SQL_MAX_ROW: int = 100000
78
```
79
80
**Usage Examples:**
81
82
```python
83
# PostgreSQL configuration
84
SQLALCHEMY_DATABASE_URI = 'postgresql://user:password@host:port/database'
85
86
# MySQL configuration
87
SQLALCHEMY_DATABASE_URI = 'mysql://user:password@host:port/database'
88
89
# Connection pooling
90
SQLALCHEMY_ENGINE_OPTIONS = {
91
'pool_size': 20,
92
'pool_timeout': 20,
93
'pool_recycle': 1800,
94
'max_overflow': 0,
95
'pool_pre_ping': True,
96
}
97
```
98
99
### Security Configuration
100
101
Authentication, authorization, and security settings.
102
103
```python { .api }
104
# Authentication Configuration
105
AUTH_TYPE: int = AUTH_DB # Database authentication
106
AUTH_ROLE_ADMIN: str = "Admin"
107
AUTH_ROLE_PUBLIC: str = "Public"
108
AUTH_USER_REGISTRATION: bool = False
109
AUTH_USER_REGISTRATION_ROLE: str = "Gamma"
110
111
# Custom Security Manager
112
CUSTOM_SECURITY_MANAGER: Optional[Type[SupersetSecurityManager]] = None
113
114
# CSRF Protection
115
WTF_CSRF_ENABLED: bool = True
116
WTF_CSRF_EXEMPT_LIST: List[str] = []
117
WTF_CSRF_TIME_LIMIT: int = 3600
118
119
# Session Configuration
120
PERMANENT_SESSION_LIFETIME: timedelta = timedelta(days=31)
121
SESSION_COOKIE_SECURE: bool = False
122
SESSION_COOKIE_HTTPONLY: bool = True
123
SESSION_COOKIE_SAMESITE: Optional[str] = "Lax"
124
125
# OAuth Configuration
126
AUTH_TYPE: int = AUTH_OAUTH
127
OAUTH_PROVIDERS: List[Dict[str, Any]] = []
128
129
# Public Role Permissions
130
PUBLIC_ROLE_LIKE: Optional[str] = "Gamma"
131
```
132
133
**Usage Examples:**
134
135
```python
136
# OAuth Google configuration
137
from flask_appbuilder.security.manager import AUTH_OAUTH
138
139
AUTH_TYPE = AUTH_OAUTH
140
OAUTH_PROVIDERS = [{
141
'name': 'google',
142
'token_key': 'access_token',
143
'icon': 'fa-google',
144
'remote_app': {
145
'client_id': 'GOOGLE_CLIENT_ID',
146
'client_secret': 'GOOGLE_CLIENT_SECRET',
147
'server_metadata_url': 'https://accounts.google.com/.well-known/openid_configuration',
148
'client_kwargs': {'scope': 'openid email profile'}
149
}
150
}]
151
```
152
153
### Cache Configuration
154
155
Multi-tier caching system configuration for performance optimization.
156
157
```python { .api }
158
# Cache Backend Configuration
159
CACHE_CONFIG: Dict[str, Any] = {
160
'CACHE_TYPE': 'redis',
161
'CACHE_DEFAULT_TIMEOUT': 300,
162
'CACHE_KEY_PREFIX': 'superset_',
163
'CACHE_REDIS_HOST': 'localhost',
164
'CACHE_REDIS_PORT': 6379,
165
'CACHE_REDIS_DB': 1,
166
'CACHE_REDIS_URL': 'redis://localhost:6379/1'
167
}
168
169
# Data Cache Configuration
170
DATA_CACHE_CONFIG: Dict[str, Any] = {
171
'CACHE_TYPE': 'redis',
172
'CACHE_DEFAULT_TIMEOUT': 86400, # 24 hours
173
'CACHE_KEY_PREFIX': 'superset_data_',
174
'CACHE_REDIS_URL': 'redis://localhost:6379/2'
175
}
176
177
# Filter State Cache
178
FILTER_STATE_CACHE_CONFIG: Dict[str, Any] = {
179
'CACHE_TYPE': 'redis',
180
'CACHE_DEFAULT_TIMEOUT': 86400,
181
'CACHE_REDIS_URL': 'redis://localhost:6379/3'
182
}
183
184
# Explore Form Data Cache
185
EXPLORE_FORM_DATA_CACHE_CONFIG: Dict[str, Any] = {
186
'CACHE_TYPE': 'redis',
187
'CACHE_DEFAULT_TIMEOUT': 604800, # 7 days
188
'CACHE_REDIS_URL': 'redis://localhost:6379/4'
189
}
190
191
# Cache Warmup Settings
192
CACHE_WARMUP_CHART_DATA: bool = True
193
CACHE_WARMUP_DASHBOARD_DATA: bool = True
194
```
195
196
**Usage Examples:**
197
198
```python
199
# Memcached configuration
200
CACHE_CONFIG = {
201
'CACHE_TYPE': 'memcached',
202
'CACHE_MEMCACHED_SERVERS': ['127.0.0.1:11211'],
203
'CACHE_DEFAULT_TIMEOUT': 300
204
}
205
206
# Filesystem cache
207
CACHE_CONFIG = {
208
'CACHE_TYPE': 'filesystem',
209
'CACHE_DIR': '/tmp/superset_cache',
210
'CACHE_DEFAULT_TIMEOUT': 300
211
}
212
```
213
214
### Feature Flags
215
216
Dynamic feature toggling system for experimental and optional functionality.
217
218
```python { .api }
219
# Default Feature Flags
220
DEFAULT_FEATURE_FLAGS: Dict[str, bool] = {
221
'ENABLE_TEMPLATE_PROCESSING': True,
222
'ALERT_REPORTS': False,
223
'DASHBOARD_NATIVE_FILTERS': True,
224
'DASHBOARD_CROSS_FILTERS': False,
225
'EMBEDDED_SUPERSET': False,
226
'ESCAPE_MARKDOWN_HTML': False,
227
'ESTIMATE_QUERY_COST': False,
228
'GENERIC_CHART_AXES': False,
229
'LISTVIEWS_DEFAULT_CARD_VIEW': False,
230
'SQLLAB_BACKEND_PERSISTENCE': True,
231
'THUMBNAILS': False,
232
'DYNAMIC_PLUGINS': False,
233
'DRILL_TO_DETAIL': False,
234
'DRILL_BY': False
235
}
236
237
# Custom Feature Flags
238
FEATURE_FLAGS: Dict[str, bool] = {}
239
240
# Dynamic Feature Flag Function
241
GET_FEATURE_FLAGS_FUNC: Optional[Callable[[Dict[str, bool]], Dict[str, bool]]] = None
242
```
243
244
**Usage Examples:**
245
246
```python
247
# Enable specific features
248
FEATURE_FLAGS = {
249
'ALERT_REPORTS': True,
250
'THUMBNAILS': True,
251
'EMBEDDED_SUPERSET': True
252
}
253
254
# Dynamic feature flags based on user
255
def get_feature_flags(ff):
256
"""Customize feature flags based on context."""
257
from flask import g
258
if hasattr(g, 'user') and g.user.is_admin:
259
ff['EXPERIMENTAL_FEATURE'] = True
260
return ff
261
262
GET_FEATURE_FLAGS_FUNC = get_feature_flags
263
```
264
265
### Performance and Limits Configuration
266
267
Settings for query execution limits, row limits, and performance tuning.
268
269
```python { .api }
270
# Query Execution Limits
271
ROW_LIMIT: int = 50000
272
VIZ_ROW_LIMIT: int = 10000
273
SAMPLES_ROW_LIMIT: int = 1000
274
SQL_MAX_ROW: int = 100000
275
276
# Time Limits
277
SUPERSET_WEBSERVER_TIMEOUT: int = 60
278
SQLLAB_TIMEOUT: int = 300
279
SQLLAB_ASYNC_TIME_LIMIT_SEC: int = 600
280
281
# Dashboard Settings
282
SUPERSET_DASHBOARD_POSITION_DATA_LIMIT: int = 65535
283
DASHBOARD_AUTO_REFRESH_MODE: str = "fetch"
284
DASHBOARD_AUTO_REFRESH_INTERVALS: List[Tuple[int, str]] = [
285
(0, "Don't refresh"),
286
(10, "10 seconds"),
287
(30, "30 seconds"),
288
(60, "1 minute"),
289
(300, "5 minutes")
290
]
291
292
# Chart Data Settings
293
SUPERSET_CELERY_FLOWER_TIMEOUT: int = 60
294
RESULTS_BACKEND_USE_MSGPACK: bool = True
295
GLOBAL_ASYNC_QUERIES_TRANSPORT: str = "polling"
296
```
297
298
### Email and Alerting Configuration
299
300
Email server settings and alert system configuration.
301
302
```python { .api }
303
# Email Configuration
304
SMTP_HOST: str = "localhost"
305
SMTP_STARTTLS: bool = True
306
SMTP_SSL: bool = False
307
SMTP_USER: str = "superset"
308
SMTP_PORT: int = 25
309
SMTP_PASSWORD: str = "superset"
310
SMTP_MAIL_FROM: str = "superset@superset.com"
311
312
# Alert Manager Configuration
313
ALERT_REPORTS_NOTIFICATION_DRY_RUN: bool = False
314
ALERT_REPORTS_WORKING_TIME_OUT_KILL: bool = True
315
ALERT_REPORTS_WORKING_TIME_OUT_LAG: int = 3600
316
ALERT_REPORTS_WORKING_SOFT_TIME_OUT_LAG: int = 1800
317
318
# Webdriver Configuration for Screenshots
319
WEBDRIVER_BASEURL: str = "http://superset:8088/"
320
WEBDRIVER_BASEURL_USER_FRIENDLY: str = "http://localhost:8088/"
321
WEBDRIVER_TYPE: str = "firefox"
322
WEBDRIVER_OPTION_ARGS: List[str] = [
323
"--headless",
324
"--no-sandbox",
325
"--disable-gpu"
326
]
327
```
328
329
## Configuration Loading
330
331
### Environment Variables
332
333
```python { .api }
334
import os
335
336
# Common environment variable patterns
337
SECRET_KEY = os.environ.get('SUPERSET_SECRET_KEY')
338
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
339
REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379/0')
340
341
# Feature flags from environment
342
FEATURE_FLAGS = {
343
'THUMBNAILS': os.environ.get('SUPERSET_THUMBNAILS', 'False').lower() == 'true'
344
}
345
```
346
347
### Configuration Files
348
349
```python { .api }
350
# Load configuration from Python module
351
SUPERSET_CONFIG_PATH: str = "/path/to/superset_config.py"
352
353
# Configuration inheritance
354
from superset.config import * # Load defaults
355
SECRET_KEY = 'custom-secret-key' # Override specific settings
356
```