一、安装

https://github.com/getredash/redash 拉取代码,运行docker-compose.production.yml

1,docker-compose文件调整

主要修改了两处:

1,增加了redis和postgres的db文件与宿主机的映射,不让docker容器停止后数据丢失。

官方默认的docker-compose.production.yml在docker-compose down 命令后,所有的配置信息都丢失了

2,增加了redis和postgres的端口映射,方便调试,线上环境也可以关掉。

3,修改REDASH_COOKIE_SECRET。

修改后的docker-compose.production.yml文件如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# This is an example configuration for Docker Compose. Make sure to atleast update
# the cookie secret & postgres database password.
#
# Some other recommendations:
# 1. To persist Postgres data, assign it a volume host location.
# 2. Split the worker service to adhoc workers and scheduled queries workers.
version: '2'
services:
server:
image: redash/redash:latest
command: server
depends_on:
- postgres
- redis
ports:
- "5000:5000"
environment:
PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
REDASH_COOKIE_SECRET: "Q422k6vaXUk8"
REDASH_WEB_WORKERS: 4
restart: always
worker:
image: redash/redash:latest
command: scheduler
environment:
PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
QUEUES: "queries,scheduled_queries,celery"
WORKERS_COUNT: 2
restart: always
redis:
image: redis:3.0-alpine
ports:
- "6379:6379"
volumes:
- ./data/redis_data:/data
restart: always
postgres:
image: postgres:9.5.6-alpine
ports:
- "5432:5432"
volumes:
- ./data/postgresql_data:/var/lib/postgresql/data
restart: always
nginx:
image: redash/nginx:latest
ports:
- "88:80"
depends_on:
- server
links:
- server:redash
restart: always

2,创建db

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@VM_38_115_centos redash]# docker-compose -f docker-compose.production.yml run --rm server create_db
Starting redash_redis_1
Starting redash_postgres_1
[2018-09-11 09:02:39,580][PID:1][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2018-09-11 09:02:39,601][PID:1][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
[2018-09-11 09:02:41,707][PID:1][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2018-09-11 09:02:41,708][PID:1][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2018-09-11 09:02:41,724][PID:1][INFO][alembic.runtime.migration] Running stamp_revision -> 969126bd800f

3,运行

1
# docker-compose -f docker-compose.production.yml up

运行起来的容器如下:

4,邮件配置

For the system to be able to send emails (for example when alerts trigger), you need to set the mail server to use and the host name of your Redash server. If you’re using one of our images, you can do this by editing the .env file:

1
2
3
4
5
6
7
8
9
10
11
12
# Note that not all values are required, as they have default values.
export REDASH_MAIL_SERVER="" # default: localhost
export REDASH_MAIL_PORT="" # default: 25
export REDASH_MAIL_USE_TLS="" # default: false
export REDASH_MAIL_USE_SSL="" # default: false
export REDASH_MAIL_USERNAME="" # default: None
export REDASH_MAIL_PASSWORD="" # default: None
export REDASH_MAIL_DEFAULT_SENDER="" # Email address to send from
export REDASH_HOST="" # base address of your Redash instance, for example: "https://demo.redash.io"

docker-compose文件中配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
server:
image: redash/redash:latest
environment:
...
#邮箱
REDASH_MAIL_SERVER: "smtp.exmail.qq.com"
REDASH_MAIL_PORT: 465
REDASH_MAIL_USE_TLS: "false"
REDASH_MAIL_USE_SSL: "true"
REDASH_MAIL_USERNAME: "no-reply@yoursite.com"
REDASH_MAIL_PASSWORD: "111111"
REDASH_MAIL_DEFAULT_SENDER: "no-reply@yoursite.com"
REDASH_HOST: "http://redash.mysite.com"

测试是否配置成功:

1
2
3
4
5
6
[root@VM_38_115_centos ~]# docker exec -it redash_server_1 python manage.py send_test_mail
[2018-09-11 10:02:28,627][PID:37][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2018-09-11 10:02:28,649][PID:37][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt

自己邮件会收到Test message。

PS:配置成功了,但在Alerts中触发了警告,设置的接受邮件没收到警告信息。还没找到原因…

二、使用

1,配置数据库

2,查询语句

  • 获取表的更新时间

增加图表展示:

3,Dashboards

三、用户管理


添加用户

四、特性

1,支持iframe嵌入到其它网页

对于任何Query,表格和图形都支持embed

点击Embed弹出:


这个功能可以实现自己系统中集成报表展示。

2,可视化图形支持的类型

箱型图

线形图、柱状图、面积图、饼图、散点图



队列图

计数器

漏斗图

地图

透视表

桑基图

桑基图用于表达流量分布于结构对比,最初的发明者使用它来呈现能量的流动与分布。

旭日图(Sunburst)

词云图

五,实践

根据scrapy log日志表,设计出一张bashboard监控面板:

参考

redash邮箱设置

redash环境变量

Visualization Types