From 2e3720deded4b5aa6128d196448cd501d2959df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Wed, 9 Nov 2022 23:54:01 +0000 Subject: [PATCH] Add panels visualizing the file download. --- .../panels/runner_insights_row.py | 39 ++++++++++++++++--- .../queries/file-download-ratio.flux | 13 +++++++ .../queries/file-download.flux | 10 +++++ ...equest-body-size.flux => file-upload.flux} | 0 deploy/grafana-dashboard/utils/utils.py | 1 + 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 deploy/grafana-dashboard/queries/file-download-ratio.flux create mode 100644 deploy/grafana-dashboard/queries/file-download.flux rename deploy/grafana-dashboard/queries/{request-body-size.flux => file-upload.flux} (100%) diff --git a/deploy/grafana-dashboard/panels/runner_insights_row.py b/deploy/grafana-dashboard/panels/runner_insights_row.py index 1a7785f..72906d2 100644 --- a/deploy/grafana-dashboard/panels/runner_insights_row.py +++ b/deploy/grafana-dashboard/panels/runner_insights_row.py @@ -1,4 +1,5 @@ -from grafanalib.core import RowPanel, GridPos, Histogram, TimeSeries +from grafanalib.core import RowPanel, GridPos, Histogram, TimeSeries, BarGauge, ORIENTATION_VERTICAL, \ + GAUGE_DISPLAY_MODE_BASIC, PERCENT_UNIT_FORMAT, GAUGE_CALC_MEAN from grafanalib.influxdb import InfluxDBTarget from utils.color_mapping import color_mapping_environments @@ -48,10 +49,10 @@ executions_per_minute = TimeSeries( extraJson=color_mapping_environments, ) -request_body_size = TimeSeries( - title="Request Body Size", +file_upload = TimeSeries( + title="File Upload", dataSource="Poseidon", - targets=[InfluxDBTarget(query=read_query("request-body-size", "environment-mapping"))], + targets=[InfluxDBTarget(query=read_query("file-upload", "environment-mapping"))], gridPos=GridPos(h=10, w=11, x=0, y=67), scaleDistributionType="log", unit="bytes", @@ -70,6 +71,32 @@ runner_per_minute = TimeSeries( extraJson=color_mapping_environments, ) +file_download = TimeSeries( + title="File Download", + dataSource="Poseidon", + targets=[InfluxDBTarget(query=read_query("file-download", "environment-mapping"))], + gridPos=GridPos(h=10, w=11, x=0, y=77), + scaleDistributionType="log", + unit="bytes", + maxDataPoints=None, + lineInterpolation="smooth", + extraJson=color_mapping_environments, +) + +file_download_ratio = BarGauge( + title="File Download Ratio", + dataSource="Poseidon", + targets=[InfluxDBTarget(query=read_query("file-download-ratio", "environment-mapping"))], + gridPos=GridPos(h=10, w=13, x=11, y=77), + max=1, + allValues=False, + calc=GAUGE_CALC_MEAN, + orientation=ORIENTATION_VERTICAL, + displayMode=GAUGE_DISPLAY_MODE_BASIC, + format=PERCENT_UNIT_FORMAT, + extraJson=color_mapping_environments, +) + runner_insights_row = RowPanel( title="Runner Insights", collapsed=False, @@ -81,6 +108,8 @@ runner_insights_panels = [ execution_duration, executions_per_runner, executions_per_minute, - request_body_size, + file_upload, runner_per_minute, + file_download, + file_download_ratio, ] diff --git a/deploy/grafana-dashboard/queries/file-download-ratio.flux b/deploy/grafana-dashboard/queries/file-download-ratio.flux new file mode 100644 index 0000000..274ad8c --- /dev/null +++ b/deploy/grafana-dashboard/queries/file-download-ratio.flux @@ -0,0 +1,13 @@ +import "strings" + +myWindowPeriod = if int(v: v.windowPeriod) > int(v: 1m) then duration(v: int(v: v.windowPeriod) * 10) else duration(v: int(v: v.windowPeriod) * 5) +data = from(bucket: "poseidon/autogen") + |> range(start: v.timeRangeStart, stop: v.timeRangeStop) + |> filter(fn: (r) => r["_measurement"] == "poseidon_file_download") + |> filter(fn: (r) => contains(value: r["environment_id"], set: ${environment_ids:json})) + |> filter(fn: (r) => (not exists r.stage) or contains(value: r["stage"], set: ${stages:json})) + +actual = data |> filter(fn: (r) => r["_field"] == "actual_length") +expected = data |> filter(fn: (r) => r["_field"] == "expected_length") +result = join(tables: {key1: actual, key2: expected}, on: ["_time", "environment_id", "runner_id", "stage"], method: "inner") + |> map(fn: (r) => ({ _value: if r._value_key2 == 0 then 1.0 else float(v: r._value_key1) / float(v: r._value_key2), environment_id: r.environment_id, runner_id: r.runner_id, stage: r.stage })) diff --git a/deploy/grafana-dashboard/queries/file-download.flux b/deploy/grafana-dashboard/queries/file-download.flux new file mode 100644 index 0000000..4d743f4 --- /dev/null +++ b/deploy/grafana-dashboard/queries/file-download.flux @@ -0,0 +1,10 @@ +import "strings" + +myWindowPeriod = if int(v: v.windowPeriod) > int(v: 1m) then duration(v: int(v: v.windowPeriod) * 100) else duration(v: int(v: v.windowPeriod) * 5) +result = from(bucket: "poseidon/autogen") + |> range(start: v.timeRangeStart, stop: v.timeRangeStop) + |> filter(fn: (r) => r["_measurement"] == "poseidon_file_download") + |> filter(fn: (r) => r["_field"] == "actual_length") + |> filter(fn: (r) => contains(value: r["environment_id"], set: ${environment_ids:json})) + |> filter(fn: (r) => (not exists r.stage) or contains(value: r["stage"], set: ${stages:json})) + |> keep(columns: ["_time", "_value", "environment_id", "stage"]) diff --git a/deploy/grafana-dashboard/queries/request-body-size.flux b/deploy/grafana-dashboard/queries/file-upload.flux similarity index 100% rename from deploy/grafana-dashboard/queries/request-body-size.flux rename to deploy/grafana-dashboard/queries/file-upload.flux diff --git a/deploy/grafana-dashboard/utils/utils.py b/deploy/grafana-dashboard/utils/utils.py index fd55deb..0062e34 100644 --- a/deploy/grafana-dashboard/utils/utils.py +++ b/deploy/grafana-dashboard/utils/utils.py @@ -3,6 +3,7 @@ def read_query(*names): for name in names: with open("queries/" + name + ".flux", "r") as file: result += file.read() + result += "\n" return result