Skip to content

Commit d852c96

Browse files
authored
update grafana example with awesome sensor logger app (#855)
1 parent 8e6b797 commit d852c96

File tree

5 files changed

+47
-45
lines changed

5 files changed

+47
-45
lines changed

examples/awesome-sensor-logger/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ Install [Docker Desktop](https://docs.docker.com/desktop/) and fork this repo or
1515
Wait for about half a minute to have all containers up running.
1616

1717
### Step 2: install mobile app and push data to Proton
18-
Download Sensor Logger at www.tszheichoi.com/sensorlogger.
18+
Download Sensor Logger at www.tszheichoi.com/sensorlogger.
1919

2020
| Android | iOS |
2121
|:-:|:-:|
2222
| [<img src="https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png" height="50">](https://play.google.com/store/apps/details?id=com.kelvin.sensorapp&pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1) | [<img src="https://developer.apple.com/app-store/marketing/guidelines/images/badge-example-preferred_2x.png" height="50">](https://apps.apple.com/app/id1531582925) |
2323

24-
Open the app, and go to the settings page, by clicking the button at the bottom.
24+
Open the app, and go to the settings page, by clicking the button at the bottom.
2525
1. Click the `Data Streaming` menu.
2626
2. Turn on `Enable HTTP Push`.
2727
3. Get your IP for your server (on Mac, you can hold Option key and click the WiFi icon to get the IP address), and set the `Push URL` as `http://<ip>:8000`
2828
4. Optionally, you can turn on `Skip Writing`.
2929

3030
### Step 3: view the live dashboard in Grafana
3131

32-
In your laptop/server, access `http://localhost:3000` and open the `Phone Sensor`
33-
34-
32+
In your laptop/server, access the Grafana UI via `http://localhost:3000` and open the `Phone Sensor` dashboard.
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
services:
2-
proton:
2+
timeplus:
33
image: d.timeplus.com/timeplus-io/proton:latest
44
pull_policy: always
55
ports:
66
- 3218:3218 #http port for JDBC driver, default streaming mode
77
- 8123:8123 #http port for JDBC driver, default batch mode
88
- 8463:8463 #tcp port for go driver or grafana plugin
9-
volumes:
10-
- ./init_sql:/docker-entrypoint-initdb.d
119
healthcheck:
12-
test: wget --no-verbose --tries=1 --spider http://localhost:8123/?query=show+create+phone || exit 1
10+
test: ["CMD", "curl", "http://localhost:8123"]
1311
interval: 2s
1412
timeout: 10s
1513
retries: 3
1614
start_period: 10s
1715

16+
init_timeplus:
17+
image: curlimages/curl
18+
command: >
19+
sh -c "echo 'CREATE STREAM IF NOT EXISTS phone(raw string)' | curl timeplus:8123 --data-binary @-"
20+
depends_on:
21+
timeplus:
22+
condition: service_healthy
23+
1824
proxy:
1925
image: docker.timeplus.com/timeplus/sensor-logger-proxy
2026
ports:
2127
- 8000:3000 #expose internal port 3000 as 8000, avoiding conflicts with Grafana. This will forward HTTP POST to proton:3218
2228
environment:
23-
HOST: proton
29+
HOST: timeplus
2430
STREAM: phone
2531
depends_on:
26-
- proton
32+
- timeplus
2733

2834
grafana:
2935
image: grafana/grafana:latest
@@ -33,10 +39,10 @@ services:
3339
environment:
3440
GF_AUTH_ANONYMOUS_ENABLED: 1
3541
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
36-
GF_INSTALL_PLUGINS: timeplus-proton-datasource
42+
GF_INSTALL_PLUGINS: https://d.timeplus.com/grafana/timeplus-proton-datasource-2.0.0.zip;timeplus-proton-datasource
3743
GF_LOG_LEVEL: error
3844
volumes:
3945
- ./grafana_provisioning:/etc/grafana/provisioning
4046
depends_on:
41-
proton:
47+
timeplus:
4248
condition: service_healthy

examples/awesome-sensor-logger/grafana_provisioning/dashboards/grafana_dashboard.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@
105105
"type": "timeplus-proton-datasource",
106106
"uid": "c24e0faf-1490-4321-a373-7b2b07ca2e38"
107107
},
108-
"isStreaming": true,
109-
"queryText": "select array_join(xyz) as v, multi_if(v[1]=1,'x',v[1]=2,'y','z') as axis, v[2] as value, time from(\nselect to_datetime64((p:time::int64)/1000000000,3) as time,[[1,to_float32_or_zero(p:values.x)],[2,to_float32_or_zero(p:values.y)],[3,to_float32_or_zero(p:values.z)]] as xyz from (select array_join(json_extract_array(raw,'payload')) as p from phone where p:name='gyroscope')\n)",
108+
"sql": "select array_join(xyz) as v, multi_if(v[1]=1,'x',v[1]=2,'y','z') as axis, v[2] as value, time from(\nselect to_datetime64((p:time::int64)/1000000000,3) as time,[[1,to_float32_or_zero(p:values.x)],[2,to_float32_or_zero(p:values.y)],[3,to_float32_or_zero(p:values.z)]] as xyz from (select array_join(json_extract_array(raw,'payload')) as p from phone where p:name='gyroscope')\n)",
110109
"refId": "A"
111110
}
112111
],
@@ -168,9 +167,7 @@
168167
"id": 2,
169168
"options": {
170169
"dims": {
171-
"exclude": [
172-
"z"
173-
]
170+
"exclude": ["z"]
174171
},
175172
"legend": {
176173
"calcs": [],
@@ -192,8 +189,7 @@
192189
"type": "timeplus-proton-datasource",
193190
"uid": "c24e0faf-1490-4321-a373-7b2b07ca2e38"
194191
},
195-
"isStreaming": true,
196-
"queryText": "select to_datetime64((p:time::int64)/1000000000,3) as time,to_float32_or_zero(p:values.x) as x,to_float32_or_zero(p:values.y) as y,to_float32_or_zero(p:values.z) as z from (select array_join(json_extract_array(raw,'payload')) as p from phone where p:name='gyroscope')\n",
192+
"sql": "select to_datetime64((p:time::int64)/1000000000,3) as time,to_float32_or_zero(p:values.x) as x,to_float32_or_zero(p:values.y) as y,to_float32_or_zero(p:values.z) as z from (select array_join(json_extract_array(raw,'payload')) as p from phone where p:name='gyroscope')\n",
197193
"refId": "A"
198194
}
199195
],
@@ -217,4 +213,4 @@
217213
"uid": "a3406569-2c08-454c-8791-64064366e107",
218214
"version": 3,
219215
"weekStart": ""
220-
}
216+
}
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
apiVersion: 1
22

33
datasources:
4-
- name: Proton
5-
type: timeplus-proton-datasource
6-
uid: c24e0faf-1490-4321-a373-7b2b07ca2e38
7-
typeName: Proton
8-
access: proxy
9-
url:
10-
password:
11-
user:
12-
database:
13-
isDefault: true
14-
basicAuth: false
15-
basicAuthUser:
16-
basicAuthPassword:
17-
withCredentials:
18-
jsonData:
19-
host: proton
20-
readOnly: false
21-
secureJsonData:
22-
tlsCACert: ""
23-
tlsClientCert: ""
24-
tlsClientKey: ""
25-
version: 1
26-
editable: true
4+
- name: Proton
5+
type: timeplus-proton-datasource
6+
uid: c24e0faf-1490-4321-a373-7b2b07ca2e38
7+
typeName: Proton
8+
access: proxy
9+
url:
10+
password:
11+
user:
12+
database:
13+
isDefault: true
14+
basicAuth: false
15+
basicAuthUser:
16+
basicAuthPassword:
17+
withCredentials:
18+
jsonData:
19+
host: timeplus
20+
tcpPort: 8463
21+
httpPort: 3218
22+
username: default
23+
readOnly: false
24+
secureJsonData:
25+
tlsCACert: ""
26+
tlsClientCert: ""
27+
tlsClientKey: ""
28+
version: 1
29+
editable: true

examples/awesome-sensor-logger/init_sql/init.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)