Redash ãã³ãºãªã³è³æã¯ä»¥äžã®ç°å¢ãåæã«åäœç¢ºèªãããŠããŸãïŒ
- Docker For Mac
- Docker For Windows
ãªãïŒRedash ã®ããŒãžã§ã³ããšã«ãã³ãºãªã³è³æãçšæããŠããŸãïŒææ°ããŒãžã§ã³ä»¥å€ã䜿ãå Žåã¯ïŒä»¥äžã®ã¿ã°ããåç §ã§ããŸãïŒ
- kakakakakku/redash-hands-on at v2.0.1
- kakakakakku/redash-hands-on at v4.0.1
- kakakakakku/redash-hands-on at v4.0.2
- kakakakakku/redash-hands-on at v5.0.1
- kakakakakku/redash-hands-on at v6.0.0
- kakakakakku/redash-hands-on at v7.0.0
- kakakakakku/redash-hands-on at v8.0.0
Docker Compose 㧠Redash (v10.1.0) ç°å¢ãæ§ç¯ããŸãïŒä»»æã®ãã£ã¬ã¯ããªã« kakakakakku/redash-hands-on
ãªããžããªãã¯ããŒã³ããŸãããïŒ
$ git clone https://github.com/kakakakakku/redash-hands-on.git
$ cd redash-hands-on
å
¬åŒã® getredash/redash ãªããžããªã«å
¬éãããŠããèšå®ãããŒã¹ã«ïŒãã¹ãããŒã¿ãäºåã«æå
¥ãã MySQL 5.7 ã³ã³ãããå«ãã docker-compose.yml
ãæºåããŸããïŒ
以äžã®ã³ãã³ããå®è¡ãïŒDocker Compose 㧠Redash ãèµ·åããŸãããïŒ
ååã¯ã€ã¡ãŒãžãããŠã³ããŒãããããïŒå°ãæéããããå ŽåããããŸãïŒ
$ docker-compose run --rm server create_db
$ docker-compose up -d
èµ·åãããšïŒä»¥äžã® URL 㧠Redash ã«ã¢ã¯ã»ã¹ã§ããããã«ãªããŸãïŒ
æåã« Admin User ãš Organization Name ãç»é²ããŸãããïŒä»¥äžã«ãµã³ãã«ãèŒããŠãããŸãïŒå ¥åããããSetupããã¯ãªãã¯ããŸãïŒ
- Admin User
- Name
admin
- Email Address
admin@example.com
- Password
ä»»æã®ãã¹ã¯ãŒã
- Name
- General
- Organization Name
hands-on
- Organization Name
Redash ã«ãã°ã€ã³ã§ããŸããïŒ
ãªãïŒRedash ç°å¢ã®æ§ç¯æ¹æ³ã¯ Docker Compose 以å€ã«ããããŸãïŒèå³ã®ããæ¹ã¯ïŒå ¬åŒããã¥ã¡ã³ããèªãã§ã¿ãŸãããïŒ
次㫠Redash ãã MySQL ã«æ¥ç¶ã§ããããã«ãããŒã¿ãœãŒã¹ããèšå®ããŸãïŒ
ãã°ã€ã³åŸã®ç»é¢ã«ããã1. Connect a Data Sourceãã®ãªã³ã¯ãã¯ãªãã¯ããŸãïŒ
æ€çŽ¢ãã©ãŒã ãSearch...ãã«ãMySQLããšå ¥åãïŒ1çªç®ã®ãMySQLããã¯ãªãã¯ããŸãïŒãMySQL (Amazon RDS)ãã§ã¯ãªããMySQLãã§ãïŒ
以äžã®éãã«èšå®ããããCreate â Test Connectionããšã¯ãªãã¯ãïŒæ¥ç¶ç¢ºèªãããŸãããïŒSuccess ãšç»é¢å³äžã«è¡šç€ºãããŸãïŒãªãïŒä»åã¯ãã¹ãããŒã¿ãšã㊠world
ããŒã¿ããŒã¹ã䜿ããŸãïŒ
é ç® | å€ |
---|---|
Name | MySQL |
Host | mysql |
Port | 3306 |
User | root |
Password | - |
Database Name | world |
ç»é¢å·Šäžã«ãã Settings ã¢ã€ã³ã³ãã¯ãªãã¯ãïŒãGeneralãã¿ããã¯ãªãã¯ããŸãïŒ
æ¥ä»ãã©ãŒãããã以äžã®éãã«å€æŽããŸãïŒå€æŽåŸã«ãSaveããã¿ã³ãã¯ãªãã¯ããŸãïŒ
- General
- Date Format
YYYY-MM-DD
- Date Format
ããããŒãããCreate â New Queryããšã¯ãªãã¯ãïŒä»¥äžã®ã¯ãšãªãå ¥åããŸãããïŒ
SELECT * FROM country;
å ¥åããããExecuteããã¿ã³ãã¯ãªãã¯ããŠã¯ãšãªãå®è¡ããŸãïŒãããšãåœã®äžèŠ§ããååŸã§ããŸãïŒ
ã¯ãšãªã®å®è¡ãã§ãããïŒç»é¢å·Šäžã®ãNew Queryããšããéšåãã¯ãªãã¯ãïŒã¯ãšãªã¿ã€ãã«ã ãåœã®äžèŠ§ã ã«å€æŽããŸãïŒå¿ããã«ç»é¢å³åŽã«ãããSaveããã¿ã³ãã¯ãªãã¯ããŸãããïŒ
ããã«ç»é¢å³äžã®ãPublishããã¿ã³ãã¯ãªãã¯ããŸãïŒRedash ã§ã¯ã¯ãšãªãå ¬éããããšã§ïŒä»ã®ãŠãŒã¶ãŒã«å ±æããããšãã§ããŸãïŒ
Redash ã§ã¯ã¯ãšãªã«å¯Ÿããããæ°ã«å ¥ãç»é²ããšãã¿ã°ç»é²ãããµããŒããããŠããŸãïŒ
ãŸãïŒã¯ãšãªåã®å·Šã«ããæã¢ã€ã³ã³ãã¯ãªãã¯ãïŒãæ°ã«å ¥ãç»é²ãããŠã¿ãŸãããïŒæ¬¡ã«ïŒã¯ãšãªåã®å³ã«ãããAdd tagããã¿ã³ãã¯ãªãã¯ãïŒ2åã®ã¿ã° ãåæããŒã ã ãš ããã¹ã¿ããŒã¿ã ãç»é²ããŠã¿ãŸãããïŒ
ã¯ãšãªãå¢ãããšæ¢ãã«ãããªã£ãŠããŸãããïŒç©æ¥µçã«ããæ°ã«å ¥ãç»é²ããšãã¿ã°ç»é²ãã掻çšããŸãããïŒ
å ã»ã©ãšåæ§ã«ããããŒãããCreate â New Queryããšã¯ãªãã¯ãïŒæ°èŠã¯ãšãªãäœæãïŒä»¥äžã®ã¯ãšãªãå ¥åããŸãããïŒå®è¡ãããšïŒç»é²ãããŠããåœã®ä»¶æ°ãã239ãã§ããããšãååŸã§ããŸãïŒãã®ä»¶æ°ãã°ã©ãã«ããŠã¿ãŸãããïŒ
SELECT COUNT(*) AS COUNT FROM country;
ãTableã ã¿ãã®æšªã«è¡šç€ºãããŠããã+ Add Visualizationããã¿ã³ãã¯ãªãã¯ãïŒä»¥äžã®éãã«èšå®ãããŸãïŒãSaveããã¿ã³ãã¯ãªãã¯ãããšïŒä»¶æ°ã®ã°ã©ãã衚瀺ãããŸãïŒææ°å€ãªã©ïŒç¹å®ã®å€ãã°ã©ãã«ããå Žå㯠Counter
ã䟿å©ã§ãïŒ
- Visualization Type
Counter
- Visualization Name
åœã®ä»¶æ°
- Counter Value Column Name
COUNT
ãªã Counter
ã«ã¯ãç®æšå€ããèšå®ããæ©èœããããŸãïŒä»åã®ããŒã¿ãœãŒã¹ã§ã¯ããŒã¿ä»¶æ°ã«å€åããããŸãããïŒãµã³ãã«ãšããŠïŒäœã£ãŠã¿ãŸãããïŒå
ã»ã©ã®ã¯ãšãªã以äžã®éãã«å€æŽãïŒå®è¡ããŸãïŒ
SELECT COUNT(*) AS COUNT, 500 AS kpi FROM country;
ããäžåºŠã+ Add Visualizationããã¿ã³ãã¯ãªãã¯ãïŒä»¥äžã®éãã«èšå®ãããŸãïŒå ã»ã©ãšã®éãã¯ãTarget Value Column Nameãã®èšå®ãè¿œå ããç¹ã§ãïŒãã®ããã«ã¯ãšãªã掻çšããããšã§ïŒç®æšå€ãšå®çžŸå€ãäžç·ã«å¯èŠåããããšãã§ããŸãïŒ
Counter
ã«ãç®æšå€ããèšå®ããå ŽåïŒå€ãå®çžŸãäžåãå Žåã¯èµ€ã衚瀺ããïŒäžåãå Žåã¯ç·ã§è¡šç€ºãããŸãïŒ
- Visualization Type
Counter
- Visualization Name
åœã®ä»¶æ°ïŒ+ ç®æšå€ïŒ
- Counter Value Column Name
COUNT
- Target Value Column Name
kpi
ã¯ãšãªã¿ã€ãã«ã ãåœã®ä»¶æ°ã ãšãïŒå¿ããã«ä¿åãšå ¬éãããŠãããŸãããïŒ
ã¯ãšãªã®äœæã¯ããæ £ãããšæããŸãïŒä»¥äžã®ã¯ãšãªãäœæãïŒå®è¡ããŸãããïŒ
åœããšã«éœåžã®ä»¶æ°ãååŸã§ããŸãïŒäžåœãšã€ã³ããç¹ã«å€ãããšãããããŸãïŒãããŸã§ãµã³ãã«ããŒã¿ã§ãïŒïŒ
SELECT CountryCode, COUNT(*) AS COUNT
FROM city
GROUP BY CountryCode
ORDER BY COUNT DESC;
å ã»ã©ãšåæ§ã«ã+ Add Visualizationããã¿ã³ãã¯ãªãã¯ãïŒä»¥äžã®éãã«èšå®ããããšïŒåã°ã©ããäœãããšãã§ããŸãïŒ
- Visualization Type
Chart
- Visualization Name
éœåžã®ä»¶æ°
- General
- Chart Type
Pie
- X Column
CountryCode
- Y Columns
COUNT
- Chart Type
次ã«æ£ã°ã©ããäœã£ãŠã¿ãŸãããïŒèšå®ã¯ä»¥äžã®éãã§ãïŒ
- Visualization Type
Chart
- Visualization Name
éœåžã®ä»¶æ°ïŒæ£ã°ã©ãïŒ
- General
- Chart Type
Bar
- X Column
CountryCode
- Y Columns
COUNT
- Chart Type
ãããïŒæ£ã°ã©ãã®å ŽåïŒãã®ãŸãŸã§ã¯é åºããã©ãã©ã§ãïŒãGeneralãã¿ãã®é£ã«ãããX Axisãã¿ããã¯ãªãã¯ãïŒè»žã®èšå®ãããå¿ èŠããããŸãïŒ
- Scale
Category
- Sort Values
OFF
ããã§æ£ã°ã©ããäœããŸããïŒ
ã¯ãšãªã¿ã€ãã«ã ãéœåžã®ä»¶æ°ã ãšãïŒå¿ããã«ä¿åãšå ¬éãããŠãããŸãããïŒ
次ã«ããã·ã¥ããŒããäœã£ãŠã¿ãŸãããïŒ
ããããŒãããCreate â New Dashboardããšã¯ãªãã¯ãïŒããã·ã¥ããŒãã¿ã€ãã«ã« ãåœããã·ã¥ããŒãã ãšå ¥åããŸãããïŒ
次ã«ããã·ã¥ããŒãã«ã°ã©ããé 眮ããŠãããŸãïŒ
ç»é¢å³äžã«ããã¡ãã¥ãŒãããAdd Widgetããã¯ãªãã¯ããŸãïŒãããšãAdd Widgetããšããã¢ãŒãã«ã衚瀺ãããããïŒä»¥äžã®èšå®ãç¹°ãè¿ãè¡ããŸãããïŒãSearch a query by nameãã§ã¯ãšãªåãæ€çŽ¢ãïŒVisualizaãéžæããŸãïŒã¬ã€ã¢ãŠãã¯èªç±ã«å€æŽããããšãã§ããŸãïŒ
- 1åç®
- ã¯ãšãªå
åœã®äžèŠ§
- Choose Visualization
Table
- ã¯ãšãªå
- 2åç®
- ã¯ãšãªå
åœã®ä»¶æ°
- Choose Visualization
åœã®ä»¶æ°ïŒ+ ç®æšå€ïŒ
- ã¯ãšãªå
- 3åç®
- ã¯ãšãªå
éœåžã®ä»¶æ°
- Choose Visualization
éœåžã®ä»¶æ°
- ã¯ãšãªå
- 4åç®
- ã¯ãšãªå
éœåžã®ä»¶æ°
- Choose Visualization
éœåžã®ä»¶æ°ïŒæ£ã°ã©ãïŒ
- ã¯ãšãªå
ããã¯ãšãªåã衚瀺ãããªãå Žåã¯ïŒãã®ã¯ãšãªãå ¬éãããŠããªãããšãèããããŸãïŒ
ããããŒã®ãQueriesã㧠Unpublished
ç¶æ
ã«ãªã£ãŠããã¯ãšãªããã£ããïŒãã®ã¯ãšãªãå
¬éãïŒå床ããã·ã¥ããŒãã«ã°ã©ããè¿œå ããŠã¿ãŸãããïŒ
æåŸã«ç»é¢å³äžã«ãããDone Editingããã¯ãªãã¯ãïŒç¶ããŠãPublishããã¯ãªãã¯ããŸãããïŒã¯ãšãªåæ§ã«ããã·ã¥ããŒããä»ã®ãŠãŒã¶ãŒã«å ±æããããšãã§ããŸãïŒ
Redash ã§ã¯ã¯ãšãªã ãã§ã¯ãªãïŒããã·ã¥ããŒãã«å¯ŸããŠãããæ°ã«å ¥ãç»é²ããšãã¿ã°ç»é²ãããµããŒããããŠããŸãïŒ
ãŸãïŒããã·ã¥ããŒãåã®å·Šã«ããæã¢ã€ã³ã³ãã¯ãªãã¯ãïŒãæ°ã«å ¥ãç»é²ãããŠã¿ãŸãããïŒæ¬¡ã«ïŒããã·ã¥ããŒãåã®å³ã«ãããAdd tagããã¿ã³ãã¯ãªãã¯ãïŒã¿ã° ãåæããŒã ã ãç»é²ããŠã¿ãŸãããïŒ
次ã¯ã¯ãšãªã«ãã©ã¡ãŒã¿ãä»ããŠã¿ãŸãããïŒ
Redash ã§ã¯ïŒã¯ãšãªã« {{}}
ãå«ãããšïŒãã®éšåããã©ã¡ãŒã¿ã«ãªããŸãïŒä»¥äžã®æ°èŠã¯ãšãªãäœããŸãããïŒ
ãªãïŒã¯ãšãªãå
¥åããåŸã«ã¯ãšãªã®äžã«ãã2çªç®ã®ã¢ã€ã³ã³ãFormat Queryããã¯ãªãã¯ãããšïŒèªåçã«ã¯ãšãªããã©ãŒãããããããšãã§ããŸãïŒFROM
ã3è¡ç®ã«ãã©ãŒããããããŸãïŒè©ŠããŠã¿ãŸãããïŒ
SELECT * FROM city
WHERE CountryCode = '{{CountryCode}}'
ORDER BY Population DESC;
ãããšïŒç»é¢å·Šäžã«ãCountryCodeãããã©ã¡ãŒã¿ãšããŠå ¥åããããã¹ããšãªã¢ã衚瀺ãããŸãïŒ
ããã«ãJPNããå ¥åãïŒãApply Changesããã¯ãªãã¯ãããšïŒæ¥æ¬ã®éœåžã人å£ã®å€ãé ã«ååŸããããšãã§ããŸãïŒã¯ãšãªã¿ã€ãã«ã ãéœåžã®æ€çŽ¢ïŒãã©ã¡ãŒã¿éžæïŒã ã«ããŠä¿åããŠãããŸãããïŒ
ãã©ã¡ãŒã¿ãšããŠå ¥åã§ãã UI ã¯ããã¹ããã£ãŒã«ã以å€ã«ããããŸãïŒååã®éãïŒäŸãã°ãDateããéžæãããšïŒæ¥ä»ããã«ãŒïŒã«ã¬ã³ããŒïŒããæ¥ä»ãéžæããããšãã§ããŸãïŒ
- Text
- Number
- Dropdown List
- Query Based Dropdown List
- Date
- Date and Time
- Date and Time (with seconds)
- Date Range
- Date and Time Range
- Date and Time Range (with seconds)
ä»åã¯äŸ¿å©ãªãDropdown Listããè©ŠããŸãããïŒ
ãã©ã¡ãŒã¿ã®æšªã«ãããã°ã«ãã¯ãªãã¯ãïŒãTypeãã Dropdown List
ã«ããŸãïŒããã«ãValuesã ã«ä»¥äžã®ãªã¹ããèšå®ããŸãïŒ
JPN
USA
AUS
ãããšïŒéžæè¢ããéžã¹ãããã«ãªãããïŒå ¥åãã¹ã軜æžã§ããããã«ãªããŸãïŒãAUSããéžæãïŒãApply Changesããã¯ãªãã¯ããŠã¿ãŸãããïŒ
ãã©ã¡ãŒã¿ãè€æ°éžæããæ©èœããããŸãïŒä»¥äžã®æ°èŠã¯ãšãªãäœããŸãããïŒ
SELECT *
FROM city
WHERE CountryCode IN ({{CountryCode}})
ORDER BY Population DESC;
ãã©ã¡ãŒã¿ã®æšªã«ãããã°ã«ãã¯ãªãã¯ãïŒãTypeãã Dropdown List
ã«ããŸãïŒããã«ãValuesã ã«ä»¥äžã®ãªã¹ããèšå®ãïŒä»åã¯ãAllow multiple valuesãããã§ãã¯ãïŒãQuotationãã§ãSingle Quotation MarkããéžæããŸãïŒ
JPN
USA
AUS
ãããšïŒéžæè¢ãããã©ã¡ãŒã¿ãè€æ°éžã¹ãããã«ãªããŸãïŒä»åã¯ãJPNããšãAUSããéžæãïŒãApply Changesããã¯ãªãã¯ããŠã¿ãŸãããïŒ
ã¯ãšãªã¿ã€ãã«ã ãéœåžã®æ€çŽ¢ïŒãã©ã¡ãŒã¿è€æ°éžæïŒã ã«ããŠä¿åããŠãããŸãããïŒ
Redash ã§ã¯ïŒã¯ãšãªã®ã«ã©ã åã ã«ã©ã å::filter
ããã㯠ã«ã©ã å::multi-filter
ãšããåœåèŠåã«ãããšïŒã¯ãšãªçµæããã£ã«ã¿ã§ããããã«ãªããŸãïŒãã£ããè©ŠããŠã¿ãŸãããïŒ
以äžã®æ°èŠã¯ãšãªãäœæãïŒå®è¡ãããšïŒã¯ãšãªçµæããCountryCodeãã§èªç±ã«ãã£ã«ã¿ã§ããããã«ãªããŸãïŒãããããã£ã«ã¿æ©èœãã§ãïŒ
SELECT *, CountryCode AS 'CountryCode::filter'
FROM city
ORDER BY Population DESC;
次ã«ããã«ããã£ã«ã¿æ©èœããè©ŠããŸãããïŒã¯ãšãªã以äžã®ããã«å€æŽãããšïŒä»åºŠã¯è€æ°ã®ãCountryCodeãã§ãã£ã«ã¿ã§ããããã«ãªããŸãïŒãªãïŒä»åããFormat Queryããå®è¡ããŠãããŸãããïŒ
SELECT *, CountryCode AS 'CountryCode::multi-filter' FROM city ORDER BY Population DESC;
ãã£ã«ã¿æ©èœã¯éåžžã«äŸ¿å©ã§ãïŒè©³ããã¯å ¬åŒããã¥ã¡ã³ããèªãã§ã¿ãŸãããïŒ
ã¯ãšãªã¿ã€ãã«ã ãéœåžã®ãã£ã«ã¿ã ã«ããŠä¿åããŠãããŸãããïŒ
Redash ã§ã¯ïŒãã䜿ãã¯ãšãªïŒãããã¯ã¯ãšãªã®äžéšïŒãã¯ãšãªã¹ãããããšããŠç»é²ããæ©èœããããŸãïŒ
ç»é¢å·Šäžã«ãã Settings ã¢ã€ã³ã³ãã¯ãªãã¯ãïŒãQuery Snippetsãã¿ããã¯ãªãã¯ããŸãïŒ
次ã«ãNew Query Snippetããã¿ã³ãã¯ãªãã¯ãããšç»é²ç»é¢ã衚瀺ãããŸãïŒä»¥äžã®èšå®ãããããCreateããã¿ã³ãæŒããŸãããïŒ
- Trigger
_country_code
- Description
åœã³ãŒãæ€çŽ¢
- Snippet
WHERE CountryCode = '{{CountryCode}}'
æ°èŠã¯ãšãªãäœæãïŒä»¥äžã®ã¯ãšãªãå
¥åããŸãããïŒã¯ãšãªã¹ããããã«ç»é²ãããTriggerãã«éšåäžèŽãããšåè£ãšããŠè¡šç€ºããããã _
ãšå
¥åãããšã¯ãšãªã¹ãããããåŒã³åºãããšãã§ããŸãïŒ
SELECT * FROM city _
ã¯ãšãªã¹ããããã«ãã¬ãŒã¹ãã«ããèšå®ããããšãã§ããŸãïŒ
以äžã®ããã« ${1:table}
ãšèšå®ãããšïŒããŒãã«åã®ãã¬ãŒã¹ãã«ãã«ãªããŸãïŒæ¯éè©ŠããŠã¿ãŸãããïŒä»åã¯ã¯ãšãªã¹ããããã®åäœç¢ºèªãç®çã§ãã®ã§ïŒã¯ãšãªã¯ä¿åããªããŠå€§äžå€«ã§ãïŒ
- Trigger
_record_count
- Description
ã¬ã³ãŒã件æ°
- Snippet
SELECT COUNT(*) FROM ${1:table};
Redash ã§ã¯ïŒã¯ãšãªçµæã« HTML ãåã蟌ãããšãã§ããŸãïŒãã£ãã以äžã®æ°èŠã¯ãšãªãäœæããŠã¿ãŸãããïŒ
SELECT Code,
Name,
Population,
CASE
WHEN Population > 1000000000 THEN '<div class="bg-success p-30 text-center">AAA</div>'
WHEN Population > 213000000 THEN '<div class="bg-warning p-20 text-center">BBB</div>'
ELSE '<div class="bg-danger p-10 text-center">CCC</div>'
END AS Color
FROM country
ORDER BY Population DESC;
ãPopulationãã®å€ã«ãã£ãŠãç·é»èµ€ããšè²ãå€ããŠããŸãïŒããã«çžŠãµã€ãºãå€ããŠããŸãïŒãã®ããã«æŽ»çšãããšïŒããã¯ãšãªçµæã䟿å©ã«äœ¿ãããšãã§ããŸãïŒ
ã¯ãšãªã¿ã€ãã«ã ãåœã®äžèŠ§ïŒè²ä»ãïŒã ã«ããŠä¿åããŠãããŸãããïŒä»ã«ãå©çšå¯èœãªããŒã¯ã¢ãããããïŒå ¬åŒããã¥ã¡ã³ãã«èŒã£ãŠããŸãïŒ
ããã·ã¥ããŒãã«è€æ°ã®ã°ã©ããé 眮ããå ŽåïŒé¢é£ãã URL ãªã©ãèŒããŠãããšäŸ¿å©ãªå ŽåããããŸãïŒ
ããã·ã¥ããŒãã«ããªãŒããã¹ããå ¥åããæ¹æ³ããããŸããïŒRedash ã§ã¯ïŒã¯ãšãªçµæã« HTML ãåã蟌ãããšãã§ããããïŒç°¡åã«ãªã³ã¯ãäœæããããšãã§ããŸãïŒ
以äžã®æ°èŠã¯ãšãªãäœæãïŒã¯ãšãªã¿ã€ãã«ã ããªã³ã¯éã ã«ããŠä¿åããŠãããŸãããïŒ
SELECT '<a href="https://www.google.co.jp/" target="_blank">Google</a>' AS name
UNION
SELECT '<a href="https://www.yahoo.co.jp/" target="_blank">Yahoo!</a>'
UNION
SELECT '<a href="https://www.bing.com/" target="_blank">Bing</a>'
UNION
SELECT '<a href="https://kakakakakku.hatenablog.com/" target="_blank">kakakakakku blog</a>';
Redash ã«ã¯ïŒã¯ãšãªãéžæå®è¡ããæ©èœããããŸãïŒ
åæã¯ãšãªãæžããšãã«ãµãã¯ãšãªã JOIN ã掻çšããå Žé¢ãå€ããšæããŸãïŒãµãã¯ãšãªãªã©ã®éšåã¯ãšãªãéžæããŠå®è¡ã§ãããšäŸ¿å©ã§ãïŒ
以äžã®æ°èŠã¯ãšãªãäœæãïŒãµãã¯ãšãªãéžæãïŒãExecute Selectedããã¿ã³ãã¯ãªãã¯ããŠå®è¡ããŠã¿ãŸãããïŒ
SELECT *
FROM country
WHERE Code =
(SELECT Code
FROM country
WHERE Name = 'Japan')
Redash ã§ã¯ïŒã¯ãšãªçµæãããŠã³ããŒãããããšãã§ããŸãïŒçŸç¶ãµããŒããããŠããããŒã¿åœ¢åŒã¯ CSV ãš TSV ãš Excel ã§ãïŒ
ããããŒã®ãQueriesããã¯ãªãã¯ãïŒæ¢ã«äœã£ãã¯ãšãª ãåœã®äžèŠ§ã ãéããŸãããïŒ
ç»é¢äžã«ããã瞊ç¹ããã¿ã³ïŒEdit Visualization ãã¿ã³ã®å·Šã«ããïŒãæŒããšïŒä»¥äžã®ã¡ãã¥ãŒã衚瀺ãããŸãïŒã¯ãšãªçµæãããŠã³ããŒãããŠã¿ãŸãããïŒ
- Download as CSV File
- Download as TSV File
- Download as Excel File
ä»åã¯ãã³ãºãªã³ãšã㊠Redash ã1人ã§äœ¿ã£ãŠããŸããïŒäžè¬çã«ã¯ããŒã ã§äœ¿ãããšãå€ããšæããŸãïŒ
ããŒã ã§äœ¿ã£ãŠãããš ãã¡ã³ããŒãäœã£ãã¯ãšãªãå°ãã«ã¹ã¿ãã€ãºãããã ãšæããå Žé¢ããããŸãïŒãã®ããã« Redash ã«ã¯ããã©ãŒã¯æ©èœãããããŸãïŒ
æ¢ã«äœã£ãã¯ãšãª ãåœã®äžèŠ§ã ãéãïŒç»é¢å³äžã«ãããã«ããŠã³ãããForkããã¿ã³ãã¯ãªãã¯ããŸãããïŒãããšïŒèªåçã«æ°èŠã¯ãšãªãäœæãããŸãïŒã¯ãšãªã¿ã€ãã«ã ãCopy of (#1) åœã®äžèŠ§ã ãã ãåœã®äžèŠ§ïŒã«ã¹ã¿ãã€ãºïŒã ã«å€æŽããŸãããïŒ
ã¯ãšãªãèªç±ã«å€æŽã§ããããïŒä»¥äžã®ã¯ãšãªãå ¥åãïŒå®è¡ããŸãããïŒè¡šç€ºããã«ã©ã ããåœã³ãŒãããšãååããšã人å£ãã«ã«ã¹ã¿ãã€ãºã§ããŸããïŒãªãïŒä»åããFormat Queryããå®è¡ããŠãããŸãããïŒ
SELECT Code, Name, Population FROM country;
Redash ã®æ©èœã¯å¯èŠåã ãã§ã¯ãããŸããïŒç¹å®ã®å€ãéŸå€ãè¶ ããå Žåã«ã¢ã©ãŒããéç¥ããæ©èœããããŸãïŒéç¥å ã¯ä»¥äžããéžã¶ããšãã§ããŸãïŒ
- Slack
- Webhook
- Mattermost
- ChatWork
- PagerDuty
- Google Hangouts Chat
Slack ã« Webhook çµç±ã§ã¢ã©ãŒããéç¥ããŠã¿ãŸãããïŒä»åã¯ïŒèªç±ã«äœ¿ãã Slack ã¢ã«ãŠã³ããããåæã§é²ããŸãïŒ
ãŸãïŒSlack 㧠Incoming WebHooks ãäœæããŸãïŒãã®ãŸãŸã§ã䜿ããŸããïŒãCustomize Nameãã« Redash Alerts
ïŒãCustomize Iconãã« Redash ã®ããŽç»åãªã©ãèšå®ããŠãããšäŸ¿å©ã§ãïŒãWebhook URLãã®å€ã¯æ¬¡ã«äœ¿ããŸãïŒ
ç»é¢å·Šäžã«ãã Settings ã¢ã€ã³ã³ãã¯ãªãã¯ãïŒãAlert Destinationsãã¿ãã«ãããNew Alert Destinationããã¿ã³ãã¯ãªãã¯ããŸãããïŒæ¬¡ã«ãSlackããã¯ãªãã¯ãïŒç»é²ç»é¢ã§ä»¥äžãèšå®ããŸãïŒ
- Name
Slack
- Slack Webhook URL
Webhook URL
ã¢ã©ãŒããèšå®ããåã«ïŒããå°ãæºåãããŠããå¿ èŠããããŸãïŒ
æ¢ã«äœæããããåœã®ä»¶æ°ãã¯ãšãªãéããEdit Sourceããã¯ãªãã¯ããŸããããã«ç»é¢å·Šäžã«ãããRefresh Scheduleããæå¹ã«ããå¿
èŠããããŸãïŒãNeverããã¯ãªãã¯ããŠããïŒä»å㯠1 minute
ã«ããŸãããïŒ
ä»åã®äŸã§ã¯ïŒåœã®ä»¶æ°ã«å€åã¯ãããŸãããïŒå®æçã«ã¯ãšãªã®å®è¡ãããæ©èœã§ãïŒã¢ã©ãŒãã®èšå®ãããã¯ãšãªã«ã¯ãRefresh Scheduleãã®èšå®ãå¿ èŠã§ãïŒ
æåŸã¯ã¢ã©ãŒãã®èšå®ã§ãïŒããããŒãããCreate â New Alertããã¯ãªãã¯ãïŒãNew Alertãã®ç»é¢ãéããŸãïŒ
ç»é²ç»é¢ã§ä»¥äžãèšå®ããŸãïŒ
- Query
åœã®ä»¶æ°
- Trigger when
COUNT > 200
- When triggered, send notification
Each time alert is evaluated
- ååïŒç»é¢1çªäžïŒ
åœã®ä»¶æ°ã200件ãè¶ ããå Žå
ãCreate Alertããã¯ãªãã¯ãããšïŒå³åŽã«ãDestinationsãã®ã¡ãã¥ãŒã衚瀺ãããããïŒãSlackãããAddãããŸãïŒ
ãããšïŒSlack ã«ã¢ã©ãŒããéç¥ãããŸãïŒç¢ºèªãã§ããããDestinationsãã®ãSlackããæ¶ããŠãããŸãããïŒ
次ã«ïŒRedash 管çè ãšã㊠Redash ãŠãŒã¶ãŒãè¿œå ïŒç¡å¹åããéçšæé ãè©ŠããŠã¿ãŸãããïŒ
ç»é¢å·Šäžã«ãã Settings ã¢ã€ã³ã³ãã¯ãªãã¯ãïŒãUsersãã¿ããã¯ãªãã¯ããŸãïŒæ¬¡ã«ãNew Userããã¿ã³ãã¯ãªãã¯ããŸãïŒ
以äžã®éãã«ïŒRedash ãŠãŒã¶ãŒã2åç»é²ããŸãïŒãEmail not sent!ããšããã¡ãã»ãŒãžã¯åé¡ãããŸããïŒç»é²ãçµãã£ãããPending Invitationsããã¯ãªãã¯ãïŒãŠãŒã¶ãŒã確èªããŸãããïŒæåŸ äžã®ç¶æ ã«ãªã£ãŠããŸãïŒ
- Create a New UserïŒ1åç®ïŒ
- Name
RedashUser1
- Email
redashuser1@example.com
- Name
- Create a New UserïŒ2åç®ïŒ
- Name
RedashUser2
- Email
redashuser2@example.com
- Name
ã¡ã³ããŒã®éè·ãªã©ïŒRedash ãŠãŒã¶ãŒãåé€ããå Žåã¯ã©ããããè¯ãã®ã§ãããïŒ
Redash ã«ã¯ãŠãŒã¶ãŒãåé€ããæ©èœã¯ãããŸãããïŒãŠãŒã¶ãŒãç¡å¹åããæé ããããŸãïŒä»åã¯æåŸ äžã®ãŠãŒã¶ãŒãç¡å¹åããŸãïŒ
ãPending Invitationsãã§ãRedashUser2ããã¯ãªãã¯ãïŒãDisable Userããã¿ã³ãæŒããŠã¿ãŸãããïŒãŠãŒã¶ãŒãç¡å¹åã§ããŸããïŒç¡å¹åã解é€ããå Žåã¯ãEnable Userããã¿ã³ãã¯ãªãã¯ããŸãïŒ
以äžã§ãã³ãºãªã³ã¯çµããã§ãïŒRedash ãåæ¢ããŠãããŸãããïŒãç²ãããŸã§ããïŒ
$ docker-compose down
Happy querying :)