Skip to content

Commit 614ef4b

Browse files
Merge pull request #267 from m-lab/sandbox-soltesz
Add median metrics for Grafana WorldMap plugin
2 parents 2c7f6ef + a4cf9bc commit 614ef4b

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#standardSQL
2+
3+
SELECT
4+
machine,
5+
APPROX_QUANTILES(IF(direction = "s2c", download, NULL), 4)[OFFSET(2)] AS value_download_median_rate,
6+
APPROX_QUANTILES(IF(direction = "c2s", upload, NULL), 4)[OFFSET(2)] AS value_upload_median_rate,
7+
FORMAT("s%03dx%03d", latitude + 180, longitude + 180) as position,
8+
COUNT(*) AS value_tests
9+
FROM (
10+
SELECT
11+
-- Machine
12+
connection_spec.server_hostname AS machine,
13+
14+
-- Direction
15+
CASE connection_spec.data_direction
16+
WHEN 0 THEN "c2s"
17+
WHEN 1 THEN "s2c"
18+
ELSE "error"
19+
END AS direction,
20+
21+
-- Download as bits-per-second
22+
8 * 1000000 * (web100_log_entry.snap.HCThruOctetsAcked /
23+
(web100_log_entry.snap.SndLimTimeRwin +
24+
web100_log_entry.snap.SndLimTimeCwnd +
25+
web100_log_entry.snap.SndLimTimeSnd)) AS download,
26+
27+
-- Upload as bits-per-second
28+
8 * 1000000 * (web100_log_entry.snap.HCThruOctetsReceived /
29+
web100_log_entry.snap.Duration) AS upload,
30+
31+
-- Client latitude, rounded to 5 degrees.
32+
CAST(connection_spec.client_geolocation.latitude / 3.0 as INT64) * 3 as latitude,
33+
-- Client longitude, rounded to 5 degrees.
34+
CAST(connection_spec.client_geolocation.longitude / 3.0 as INT64) * 3 as longitude
35+
36+
FROM
37+
`measurement-lab.base_tables.ndt`
38+
39+
WHERE
40+
-- For faster queries we use _PARTITIONTIME boundaries. And, to
41+
-- guarantee the _PARTITIONTIME data is "complete" (all data collected
42+
-- and parsed) we should wait 36 hours after start of a given day.
43+
-- The following is equivalent to the pseudo code:
44+
-- date(now() - 12h) - 1d
45+
_PARTITIONTIME = TIMESTAMP_SUB(TIMESTAMP_TRUNC(TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 12 HOUR), DAY), INTERVAL 24 HOUR)
46+
-- Basic test quality filters for safe division.
47+
AND web100_log_entry.snap.Duration > 0
48+
AND (web100_log_entry.snap.SndLimTimeRwin + web100_log_entry.snap.SndLimTimeCwnd + web100_log_entry.snap.SndLimTimeSnd) > 0
49+
AND web100_log_entry.snap.CountRTT > 0
50+
AND web100_log_entry.snap.HCThruOctetsReceived > 0
51+
AND web100_log_entry.snap.HCThruOctetsAcked > 0
52+
)
53+
GROUP BY
54+
machine, latitude, longitude, position
55+
HAVING
56+
value_tests > 10
57+
AND value_download_median_rate is not NULL
58+
AND value_upload_median_rate is not NULL
59+
AND position is not NULL
60+
ORDER BY
61+
machine
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Setup the Grafana WorldMap Plugin
2+
3+
4+
Rough notes:
5+
6+
* manually install the worldmap plugin in Grafana server `/var/lib/grafana/plugins`.
7+
* create a GCS bucket for the json location data.
8+
* set defactl on bucket:
9+
```
10+
$ gsutil defacl set public-read gs://prometheus-support-mlab-sandbox/
11+
```
12+
* set cors policy on bucket, so requests evaluate `Access-Control-Allow-Origin`
13+
headers correctly.
14+
```
15+
$ gsutil cors set cors.json gs://prometheus-support-mlab-sandbox
16+
```
17+
18+
`cors.json` contains, a project-specific origin:
19+
```
20+
[
21+
{
22+
"origin": ["http://localhost:3000", "https://grafana.mlab-sandbox.measurementlab.net"],
23+
"responseHeader": ["Content-Type"],
24+
"method": ["GET", "HEAD", "DELETE"],
25+
"maxAgeSeconds": 3600
26+
}
27+
]
28+
```
29+
30+
* The worldmap plugin uses the "Legend" field to identify the label to use and
31+
look for in the location list.

k8s/prometheus-federation/deployments/bigquery-exporter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ spec:
2020
args: [ "--project={{GCLOUD_PROJECT}}",
2121
"--type=gauge", "--query=/queries/bq_ndt_tests.sql",
2222
"--type=gauge", "--query=/queries/bq_ipv6_bias.sql",
23+
"--type=gauge", "--query=/queries/bq_ndt_worldmap.sql",
2324
"--type=gauge", "--query=/queries/bq_ndt_server.sql" ]
2425
ports:
2526
- containerPort: 9050

0 commit comments

Comments
 (0)