superset警报与报告
作者:互联网
参考官网进行配置
Alerts and Reports | superset dochttps://superset.apache.org/docs/installation/alerts-reports
邮箱配置
*邮箱以163举例
- 首先开启163邮箱SMTP
- 拿到授权码
- 编写SMTP配置
SMTP_PASSWORD 授权码
SMTP_USER 你的163邮箱
SMTP_MAIL_FROM 你的163邮箱
端口号
非SSL
SMTP_STARTTLS = True
SMTP_SSL = False
配置完成。
贴上我的配置,仅供参考:
/home/superset下
superset_config.py
from superset.typing import CacheConfig
from celery.schedules import crontab
FEATURE_FLAGS = {
"THUMBNAILS": True,
"THUMBNAILS_SQLA_LISTENERS": True,
"DASHBOARD_NATIVE_FILTERS": True,
"DASHBOARD_CACHE": True,
"ALERT_REPORTS": True,
}
CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 3,
'CACHE_KEY_PREFIX': 'superset_',
'CACHE_REDIS_HOST': 'localhost',
'CACHE_REDIS_PORT': 6379,
'CACHE_REDIS_DB': 0,
'CACHE_REDIS_URL': 'redis://localhost:6379/0'
}
DATA_CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 3, # 1 day default (in secs)
'CACHE_KEY_PREFIX': 'superset_results',
'CACHE_REDIS_URL': 'redis://localhost:6379/0',
}
# Async selenium thumbnail task will use the following user
THUMBNAIL_SELENIUM_USER = "admin"
THUMBNAIL_CACHE_CONFIG: CacheConfig = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 3*60*60,
'CACHE_KEY_PREFIX': 'thumbnail_',
'CACHE_NO_NULL_WARNING': True,
'CACHE_REDIS_URL': 'redis://localhost:6379/0'
}
class CeleryConfig(object):
BROKER_URL = "redis://localhost:6379/0"
CELERY_IMPORTS = ("superset.sql_lab", "superset.tasks", "superset.tasks.thumbnails",)
CELERY_RESULT_BACKEND = "redis://localhost:6379/0"
CELERYD_PREFETCH_MULTIPLIER = 10
CELERY_ACKS_LATE = True
CELERY_ANNOTATIONS = {
'sql_lab.get_sql_results': {
'rate_limit': '100/s',
},
'email_reports.send': {
'rate_limit': '1/s',
'time_limit': 600,
'soft_time_limit': 600,
'ignore_result': True,
},
}
CELERYBEAT_SCHEDULE = {
"cache-warmup-hourly": {
"task": "cache-warmup",
"schedule": crontab(minute=0, hour="*"), # hourly
"kwargs": {
"strategy_name": "top_n_dashboards",
"top_n": 5,
"since": "7 days ago",
},
},
'reports.scheduler': {
'task': 'reports.scheduler',
'schedule': crontab(minute='*', hour='*'),
},
'reports.prune_log': {
'task': 'reports.prune_log',
'schedule': crontab(minute=0, hour=0),
},
}
CELERY_CONFIG = CeleryConfig
SCREENSHOT_LOCATE_WAIT = 100
SCREENSHOT_LOAD_WAIT = 600
# Email configuration
SMTP_HOST = "smtp.163.com" #change to your host
SMTP_STARTTLS = True
SMTP_SSL = False
SMTP_USER = "lz********@163.com"
SMTP_PORT = 25 # your port eg. 587
SMTP_PASSWORD = "***************"
SMTP_MAIL_FROM = "lz******@163.com"
# The webdriver to use for generating reports. Use one of the following
# firefox
# Requires: geckodriver and firefox installations
# Limitations: can be buggy at times
# chrome:
# Requires: headless chrome
# Limitations: unable to generate screenshots of elements
WEBDRIVER_TYPE = "chrome"
# Additional args to be passed as arguments to the config object
# Note: these options are Chrome-specific. For FF, these should
# only include the "--headless" arg
WEBDRIVER_OPTION_ARGS = [
"--force-device-scale-factor=2.0",
"--high-dpi-support=2.0",
"--headless",
"--disable-gpu",
"--disable-dev-shm-usage",
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-extensions",
]
# The base URL to query for accessing the user interface
WEBDRIVER_BASEURL = "http://localhost:8088/"
# On Redis
from cachelib.redis import RedisCache
RESULTS_BACKEND = RedisCache(
host='localhost', port=6379, key_prefix='superset_results')
启动superset
我的运行方式与官方不同,是单容器运行的。Superset安装与汉化https://blog.csdn.net/LeeZed/article/details/121223218https://blog.csdn.net/LeeZed/article/details/121223218
重启superset容器,进入容器后
启动redis
nohup redis-server > ./redis.log &
启动celery beat
nohup celery --app=superset.tasks.celery_app:app beat > ./celery_beat.log &
启动celery worker
nohup celery --app=superset.tasks.celery_app:app worker --pool=prefork --max-tasks-per-child=128 -O fair -c 4 > ./celery.log &
celery相关可自行搜索相关知识,相关连接参考superset缩略图https://blog.csdn.net/LeeZed/article/details/121223296https://blog.csdn.net/LeeZed/article/details/121223296
警告与报告
- 配置完成后,进入superset,点击警报与报告
- 根据需求添加警报与报告
- 查看运行日志
错误(535, b'Error: authentication failed') 是SMTP配置问题,如果出现,检查相关配置。
测试通过
标签:报告,--,redis,CACHE,SMTP,celery,警报,superset 来源: https://blog.csdn.net/LeeZed/article/details/121227332