sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #04447
[Merge] ~ack/maas-kpi:maasspike-dashboard into ~maas-committers/maas-kpi/+git/maas-kpi:master
Alberto Donato has proposed merging ~ack/maas-kpi:maasspike-dashboard into ~maas-committers/maas-kpi/+git/maas-kpi:master.
Commit message:
Add graphana dashboard for machine listing performance spike
Requested reviews:
MAAS Committers (maas-committers)
For more details, see:
https://code.launchpad.net/~ack/maas-kpi/+git/maas-kpi/+merge/435665
--
Your team MAAS Committers is requested to review the proposed merge of ~ack/maas-kpi:maasspike-dashboard into ~maas-committers/maas-kpi/+git/maas-kpi:master.
diff --git a/Makefile b/Makefile
index 3950cf7..778c6fd 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,14 @@ SWIFT_KEY ?= swift.key
VIRTUALENV := .ve
GENERATED := generated
+define DASHBOARDS
+ features.json \
+ kpis.json \
+ machine-listing-spike.json \
+ performance.json \
+ team.json
+endef
+
.DEFAULT_GOAL := setup
setup: clean py-dep
@@ -28,7 +36,7 @@ check: py-check
$(GENERATED):
mkdir $(GENERATED)
-dashboards: $(GENERATED)/team.json $(GENERATED)/features.json $(GENERATED)/kpis.json $(GENERATED)/performance.json
+dashboards: $(addprefix $(GENERATED)/, $(DASHBOARDS))
.PHONY: dashboards
$(GENERATED)/%.json : grafana/%.dashboard.py | $(GENERATED)
diff --git a/grafana/machine-listing-spike.dashboard.py b/grafana/machine-listing-spike.dashboard.py
new file mode 100644
index 0000000..9707080
--- /dev/null
+++ b/grafana/machine-listing-spike.dashboard.py
@@ -0,0 +1,193 @@
+# Copyright 2022 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+from textwrap import dedent
+
+from grafanalib.core import (
+ INDIVIDUAL,
+ NULL_AS_ZERO,
+ SECONDS_FORMAT,
+ SORT_DESC,
+ Annotations,
+ Dashboard,
+ Row,
+ Template,
+ Templating,
+ Time,
+ Tooltip,
+ YAxes,
+ YAxis,
+)
+
+from maaskpi.grafana import Graph, InfluxDBTarget, Tag, TagField, get_datasource
+
+RESULTS_PREFIX = "maasspike"
+MACHINE_COUNTS = ["50", "all"]
+HANDLERS = ["baseline", "django_light"]
+METRICS = (
+ ("duration", "Execution time"),
+ ("query_time", "Query time"),
+)
+
+
+def create_metric_graph(machine_count, metric):
+ query = dedent(
+ f'''\
+ SELECT "{metric}"
+ FROM maas_ci_perf..testcase
+ WHERE "system" = \'$system\'
+ AND "dataset" =~ /^$dataset/
+ AND "test" =~ /{RESULTS_PREFIX}_.*_{machine_count}$/
+ AND $timeFilter
+ GROUP BY "dataset", "test"
+ '''
+ )
+ targets = [
+ InfluxDBTarget(
+ measurement="testcase",
+ query=query,
+ rawQuery=True,
+ groupBy=[TagField("test"), TagField("dataset")],
+ tags=[Tag(key="system", operator="=", value="$system")],
+ alias="$tag_test - $tag_dataset",
+ )
+ ]
+
+ return Graph(
+ title=f"{machine_count} machines",
+ dataSource=get_datasource(),
+ targets=targets,
+ yAxes=YAxes(YAxis(format=SECONDS_FORMAT)),
+ fill=1,
+ tooltip=Tooltip(
+ sort=SORT_DESC,
+ valueType=INDIVIDUAL,
+ ),
+ nullPointMode=NULL_AS_ZERO,
+ span=12,
+ )
+
+
+def create_handler_graph(handler, machines_count):
+ targets = []
+ for metric, metric_name in METRICS:
+ query = dedent(
+ f'''\
+ SELECT "{metric}" AS "{metric_name}"
+ FROM maas_ci_perf..testcase
+ WHERE "system" = \'$system\'
+ AND "dataset" =~ /^$dataset/
+ AND "test" =~ /{RESULTS_PREFIX}_{handler}_/
+ AND $timeFilter
+ GROUP BY "dataset"
+ '''
+ )
+ targets.append(
+ InfluxDBTarget(
+ measurement="testcase",
+ query=query,
+ rawQuery=True,
+ groupBy=[TagField("dataset")],
+ tags=[Tag(key="system", operator="=", value="$system")],
+ alias=f"{metric_name} - $tag_dataset",
+ )
+ )
+
+ return Graph(
+ title=f"{handler} - {machines_count} machines",
+ dataSource=get_datasource(),
+ targets=targets,
+ yAxes=YAxes(YAxis(format=SECONDS_FORMAT)),
+ fill=1,
+ tooltip=Tooltip(
+ sort=SORT_DESC,
+ valueType=INDIVIDUAL,
+ ),
+ nullPointMode=NULL_AS_ZERO,
+ span=12,
+ )
+
+
+def create_handler_row(handler, machine_count):
+ return Row(
+ panels=[
+ create_handler_graph(
+ handler,
+ machine_count,
+ ),
+ ]
+ )
+
+
+def create_rows():
+ return [
+ Row(
+ title=metric_name,
+ panels=[
+ create_metric_graph(machine_count, metric)
+ for machine_count in MACHINE_COUNTS
+ ]
+ )
+ for metric, metric_name in METRICS
+ ] + [
+ Row(
+ title="All metrics",
+ panels=[
+ create_handler_graph(handler, machine_count)
+ for handler in HANDLERS
+ for machine_count in MACHINE_COUNTS
+ ]
+ )
+ ]
+
+
+def create_annotations():
+ query = dedent(
+ f'''\
+ SELECT "duration", "revision", "dataset"
+ FROM maas_ci_perf..testcase
+ WHERE "dataset" =~ /^$dataset/
+ AND $timeFilter
+ ORDER BY time ASC
+ '''
+ )
+ return Annotations(
+ list=[
+ {
+ "datasource": get_datasource(),
+ "enable": True,
+ "hide": False,
+ "name": "git",
+ "query": query,
+ "tagsColumn": "dataset",
+ "textColumn": "revision",
+ "type": "tags",
+ }
+ ]
+ )
+
+
+dashboard = Dashboard(
+ title="MAAS Performance - machine listing spike",
+ rows=create_rows(),
+ time=Time("now-30d", "now"),
+ annotations=create_annotations(),
+ refresh=None,
+ templating=Templating(
+ [
+ Template(
+ name="system",
+ query='SHOW TAG VALUES ON maas_ci_perf WITH KEY = "system"',
+ dataSource=get_datasource(),
+ ),
+ Template(
+ name="dataset",
+ query='SHOW TAG VALUES ON maas_ci_perf WITH KEY = "dataset"',
+ regex="/machine-list-spike/",
+ dataSource=get_datasource(),
+ includeAll=True,
+ multi=True,
+ ),
+ ]
+ ),
+).auto_panel_ids()
Follow ups