Skip to content

Commit 824fb3e

Browse files
committedDec 25, 2020
Grafana gzip
1 parent fe5369b commit 824fb3e

File tree

4 files changed

+59
-48
lines changed

4 files changed

+59
-48
lines changed
 

‎bootstrap.sql

+31-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
---- db: -h localhost -p 5488 -U postgres devbox
22
\d+ patient
33
----
4+
select id from patient;
5+
----
46
\c devbox
57
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
68
----
79
DROP VIEW if exists hr_view CASCADE;
810
DROP VIEW if exists pulse_view CASCADE;
911
DROP VIEW if exists resp_view CASCADE;
1012
DROP VIEW if exists oxy_view CASCADE;
13+
----
1114

1215
DROP table if exists observation_data;
1316

@@ -68,6 +71,15 @@ SELECT create_hypertable('observation_data', 'ts');
6871
SELECT add_dimension('observation_data', 'Patient_id', number_partitions => 200, if_not_exists => true);
6972
SELECT add_dimension('observation_data', 'Observation_id', number_partitions => 200, if_not_exists => true);
7073

74+
----
75+
\d+ observation_data
76+
----
77+
78+
SELECT
79+
pid ,wait_event, age(clock_timestamp(), query_start) ,query
80+
FROM pg_stat_activity
81+
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' and "state" = 'active'
82+
ORDER BY query_start nulls last;
7183
----
7284
\x
7385
select count(*)
@@ -87,32 +99,14 @@ from observation_data;;
8799
\x
88100
select * from observation_data limit 1;
89101
----
102+
----
90103
DROP VIEW if exists hr_view CASCADE;
91104
DROP VIEW if exists pulse_view CASCADE;
92105
DROP VIEW if exists resp_view CASCADE;
93106
DROP VIEW if exists oxy_view CASCADE;
94107

95108
truncate observation_data;
96109
----
97-
select patient_id, (array_agg(smooth_bpm))[1]
98-
from (
99-
SELECT
100-
ts,
101-
Patient_id,
102-
AVG(valueQuantity_value) OVER(
103-
PARTITION BY Patient_id
104-
ORDER BY ts
105-
ROWS BETWEEN 60 PRECEDING AND CURRENT ROW
106-
)
107-
AS smooth_bpm
108-
FROM observation_data
109-
WHERE code = '8867-4' -- heart rate
110-
and ts > NOW() - INTERVAL '1 minute'
111-
--and smooth_bpm > 90
112-
ORDER BY ts DESC
113-
) as avgg
114-
where avgg.smooth_bpm > 100
115-
group by patient_id;
116110
----
117111
SELECT
118112
time_bucket('10s', ts) as bucket,
@@ -141,8 +135,10 @@ FROM
141135
observation_data
142136

143137
----
138+
----------------------------------------------------------------------
144139
DROP VIEW if exists hr_view CASCADE;
145140

141+
146142
CREATE VIEW hr_view WITH
147143
(timescaledb.continuous, timescaledb.refresh_interval = '30s')
148144
AS
@@ -197,6 +193,22 @@ WHERE code = '2708-6' -- resp
197193
group by patient_id, time_bucket('10s', ts)
198194
HAVING AVG(valueQuantity_value) < 96
199195

196+
----
197+
explain analyze
198+
SELECT ts AS "time"
199+
, valuesampleddata_data I
200+
FROM observation_data
201+
where code = '131329'
202+
--and ts BETWEEN (1601823599500)::timestamp AND (1601823610500)::timestamp
203+
and ts BETWEEN '2020-10-04T14:59:59.500Z' AND '2020-10-04T15:00:10.500Z'
204+
and patient_id = 'bfd8ecb3-06dd-8f08-7121-020a9a589602'
205+
order by ts
206+
--limit 1000
207+
208+
----
209+
create index obsdatacode on observation_data (code);
210+
----
211+
analyze observation_data;
200212
----
201213
\x
202214
SELECT * FROM timescaledb_information.continuous_aggregate_stats;

‎device_imitator/src/device/core.clj

+26-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,31 @@
1010

1111
(def config
1212
{:box-url "http://localhost:8888"
13-
:jobs {:j1 {:patient-id "333"
13+
:jobs {:j1 {:patient-id "bb1cf28f-b3b6-5a90-22f3-71dcecb6fad5"
1414
:dataset-path "resources/csv/bidmc_01_Numerics.csv"}
15-
:j2 {:patient-id "123"
16-
:dataset-path "resources/csv/bidmc_02_Numerics.csv"}}})
17-
18-
15+
:j2 {:patient-id "bf16eed6-d4f0-c2f4-9ab4-788f458de47b"
16+
:dataset-path "resources/csv/bidmc_02_Numerics.csv"}
17+
:j3 {:patient-id "bfd8ecb3-06dd-8f08-7121-020a9a589602"
18+
:dataset-path "resources/csv/bidmc_03_Numerics.csv"}
19+
:j4 {:patient-id "eb277a4d-4a42-7905-5576-d92a9a3fda9c"
20+
:dataset-path "resources/csv/bidmc_04_Numerics.csv"}
21+
:j5 {:patient-id "e490c516-7f1e-7910-44d4-0ba0fe542b31"
22+
:dataset-path "resources/csv/bidmc_05_Numerics.csv"}
23+
:j6 {:patient-id "e2d08a03-e382-c8cf-bc7a-474277238b3b"
24+
:dataset-path "resources/csv/bidmc_06_Numerics.csv"}
25+
:j7 {:patient-id "e1ed357c-6753-fe21-f98d-2e5996966ff2"
26+
:dataset-path "resources/csv/bidmc_07_Numerics.csv"}
27+
:j8 {:patient-id "e490c516-7f1e-7910-44d4-0ba0fe542b31"
28+
:dataset-path "resources/csv/bidmc_08_Numerics.csv"}
29+
:j9 {:patient-id "dd178782-f1bd-7487-e670-32e02d2c8396"
30+
:dataset-path "resources/csv/bidmc_09_Numerics.csv"}
31+
:j10 {:patient-id "d5743f3a-b161-67db-d952-983f5544f7a7"
32+
:dataset-path "resources/csv/bidmc_10_Numerics.csv"}
33+
:j11 {:patient-id "c81ef392-ed3f-e948-ac90-2e643346ed2d"
34+
:dataset-path "resources/csv/bidmc_11_Numerics.csv"}
35+
:j12 {:patient-id "bffc6742-0671-0f7f-3837-d3ecdbb31e8b"
36+
:dataset-path "resources/csv/bidmc_12_Numerics.csv"}
37+
}})
1938

2039
(defn configure [n]
2140
{:box-url "http://localhost:8888"
@@ -159,7 +178,8 @@
159178

160179
(parse-csv "resources/csv/bidmc_01_Numerics.csv")
161180

162-
(run-jobs (configure 50))
181+
#_(run-jobs (configure 50))
182+
(run-jobs config)
163183

164184
(prn 1)
165185

‎docker-compose.dev.yml

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ services:
4141
environment:
4242
GF_SECURITY_ALLOW_EMBEDDING: "true"
4343
GF_AUTH_ANONYMOUS_ENABLED: "true"
44+
GF_SERVER_ENABLE_GZIP: "true"
4445
volumes:
4546
- "./grafanadata:/var/lib/grafana"
4647
ports:

‎ui/src/app/pages/index/view.cljs

+1-23
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,4 @@
2222
" "
2323
(get-in p [:name 0 :family])
2424
]]
25-
]]
26-
27-
28-
)]]
29-
30-
31-
32-
[:div.col-md-12
33-
[:iframe
34-
{:src "http://localhost:3000/d-solo/rb_qDpxGz/new-dashboard-copy?orgId=1&from=1591109999882&to=1591110010126&var-Patient=33b9e41c-6a40-4b8c-948f-e69f5a35da8d&panelId=9"
35-
:height "500px"
36-
:width "100%"
37-
:frameborder "0"}]]
38-
39-
[:div.col-md-6
40-
[:div.bd
41-
42-
[:iframe
43-
{:src "http://localhost:3000/d-solo/rb_qDpxGz/new-dashboard-copy?orgId=1&from=1608823166525&to=1608823640459&var-Patient=43284e5d-c335-431e-a5df-d5b93badacc3&panelId=2"
44-
:height "300px"
45-
:width "100%"
46-
:frameborder "0"}]]]]
47-
))
25+
]])]]]))

0 commit comments

Comments
 (0)
Please sign in to comment.