Skip to content

Commit c88c2c6

Browse files
sjwiesmanfhueske
authored andcommitted
Add Grafana and default dashboard
1 parent 7c08020 commit c88c2c6

File tree

7 files changed

+172
-23
lines changed

7 files changed

+172
-23
lines changed

README.md

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,19 @@ SELECT * FROM PROD_CUSTOMER LIMIT 10;
6868
quit;
6969
```
7070

71+
## Grafana
72+
73+
* Visualization tool
74+
7175
## Minio (S3-compatible Storage)
7276

7377
* No files here yet
74-
* Show in Web UI: http://localhost:9000 (user: `sql-demo`, password: `demo-sql`)
78+
* Show in Web UI: [http://localhost:9000](http://localhost:9000) (user: `sql-demo`, password: `demo-sql`)
7579

7680
## Flink JobManager and TaskManager
7781

7882
* Queries are executed on a FLink cluster
79-
* Show Web UI: http://localhost:8081
83+
* Show Web UI: [http://localhost:8081](http://localhost:8081)
8084

8185
## SQL client + Hive Metastore
8286

@@ -150,7 +154,7 @@ INSERT INTO dev_orders SELECT * FROM default_catalog.default_database.prod_order
150154

151155
* Manually cancel the job
152156

153-
* Show file in Minio: http://localhost:9000
157+
* Show file in Minio: [http://localhost:9000](http://localhost:9000)
154158

155159
* Show data in SQL client
156160

@@ -532,19 +536,6 @@ GROUP BY
532536
HOUR(o_ordertime);
533537
```
534538

535-
* Create a backing table in MySQL
536-
537-
```
538-
docker-compose exec mysql mysql -Dsql-demo -usql-demo -pdemo-sql
539-
540-
CREATE TABLE REGION_STATS (
541-
region VARCHAR(20) NOT NULL,
542-
hour_of_day BIGINT NOT NULL,
543-
number_of_customers BIGINT NOT NULL,
544-
number_of_orders BIGINT NOT NULL,
545-
PRIMARY KEY (region, hour_of_day));
546-
```
547-
548539
* Create a table in Flink
549540

550541
```
@@ -587,10 +578,6 @@ GROUP BY
587578
HOUR(o_ordertime);
588579
```
589580

590-
* Monitor query result in MySQL
591-
592-
```
593-
docker-compose exec mysql mysql -Dsql-demo -usql-demo -pdemo-sql
581+
* Monitor query result in Grafana: [http://localhost:3000](http://localhost:3000)
582+
* Go to dashboard region stats and set refresh rate to 1s
594583

595-
SELECT * FROM REGION_STATS ORDER BY hour_of_day, region;
596-
```

docker-compose.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,13 @@ services:
103103
volumes:
104104
- ./mysql-init:/docker-entrypoint-initdb.d
105105
- ./data:/data
106-
106+
grafana:
107+
image: grafana/grafana
108+
ports:
109+
- "3000:3000"
110+
depends_on:
111+
- mysql
112+
volumes:
113+
- ./grafana-init/provisioning/:/etc/grafana/provisioning/
114+
- ./grafana-init/dashboard.json:/etc/grafana/dashboard.json
115+
- ./grafana-init/grafana.ini:/etc/grafana/grafana.ini

grafana-init/dashboard.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"annotations": {
3+
"list": [
4+
{
5+
"builtIn": 1,
6+
"datasource": "-- Grafana --",
7+
"enable": true,
8+
"hide": true,
9+
"iconColor": "rgba(0, 211, 255, 1)",
10+
"name": "Annotations & Alerts",
11+
"type": "dashboard"
12+
}
13+
]
14+
},
15+
"editable": true,
16+
"gnetId": null,
17+
"graphTooltip": 0,
18+
"id": 1,
19+
"links": [],
20+
"panels": [
21+
{
22+
"datasource": "MySQL",
23+
"gridPos": {
24+
"h": 9,
25+
"w": 12,
26+
"x": 0,
27+
"y": 0
28+
},
29+
"id": 2,
30+
"options": {
31+
"fieldOptions": {
32+
"calcs": [
33+
"mean"
34+
],
35+
"defaults": {
36+
"mappings": [],
37+
"thresholds": {
38+
"mode": "absolute",
39+
"steps": [
40+
{
41+
"color": "green",
42+
"value": null
43+
}
44+
]
45+
}
46+
},
47+
"overrides": [],
48+
"values": false
49+
},
50+
"orientation": "horizontal",
51+
"showThresholdLabels": false,
52+
"showThresholdMarkers": true
53+
},
54+
"pluginVersion": "6.7.3",
55+
"targets": [
56+
{
57+
"format": "time_series",
58+
"group": [],
59+
"metricColumn": "none",
60+
"rawQuery": true,
61+
"rawSql": "SELECT \n now() as time,\n region as metric,\n sum(number_of_customers) as value\nfrom\n REGION_STATS\ngroup by region\n",
62+
"refId": "A",
63+
"select": [
64+
[
65+
{
66+
"params": [
67+
"value"
68+
],
69+
"type": "column"
70+
}
71+
]
72+
],
73+
"timeColumn": "time",
74+
"where": [
75+
{
76+
"name": "$__timeFilter",
77+
"params": [],
78+
"type": "macro"
79+
}
80+
]
81+
}
82+
],
83+
"timeFrom": null,
84+
"timeShift": null,
85+
"title": "Region Stats",
86+
"type": "gauge"
87+
}
88+
],
89+
"refresh": "1s",
90+
"schemaVersion": 22,
91+
"style": "dark",
92+
"tags": [],
93+
"templating": {
94+
"list": []
95+
},
96+
"time": {
97+
"from": "2020-04-28T02:18:59.421Z",
98+
"to": "2020-04-28T02:19:00.832Z"
99+
},
100+
"timepicker": {
101+
"refresh_intervals": [
102+
"1s"
103+
]
104+
},
105+
"timezone": "",
106+
"title": "Region Stats",
107+
"uid": "9VmYzieZz",
108+
"variables": {
109+
"list": []
110+
},
111+
"version": 2
112+
}

grafana-init/grafana.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[auth]
2+
disable_login_form = true
3+
4+
[auth.anonymous]
5+
enabled = true
6+
org_role = Editor
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: 1
2+
3+
providers:
4+
- name: default
5+
orgId: 1
6+
folder: ''
7+
type: file
8+
disableDeletion: true
9+
editable: true
10+
options:
11+
path: /etc/grafana/dashboard.json
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- orgId: 1
5+
version: 3
6+
name: MySQL
7+
type: mysql
8+
access: proxy
9+
url: mysql:3306
10+
user: sql-demo
11+
database: sql-demo
12+
isDefault: true
13+
jsonData:
14+
timeInterval: 1s
15+
secureJsonData:
16+
password: demo-sql

mysql-init/create_tables.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ CREATE TABLE PROD_RATES (
2828
RS_RATE DOUBLE NOT NULL
2929
);
3030

31+
CREATE TABLE REGION_STATS (
32+
region VARCHAR(20) NOT NULL,
33+
hour_of_day BIGINT NOT NULL,
34+
number_of_customers BIGINT NOT NULL,
35+
number_of_orders BIGINT NOT NULL,
36+
PRIMARY KEY (region, hour_of_day)
37+
);
38+
3139
INSERT INTO PROD_RATES VALUES (TIMESTAMP '2020-04-01 00:00:00.000', 'EUR', 1.0000);
3240
INSERT INTO PROD_RATES VALUES (TIMESTAMP '2020-04-01 00:00:00.000', 'CHF', 1.0588);
3341
INSERT INTO PROD_RATES VALUES (TIMESTAMP '2020-04-01 00:00:00.000', 'HKD', 8.3201);

0 commit comments

Comments
 (0)