sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #04448
Re: [Merge] ~ack/maas-kpi:maasspike-dashboard into ~maas-committers/maas-kpi/+git/maas-kpi:master
Review: Approve
+1 with a nitpick inline.
Diff comments:
> 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"),
Maybe reduce the time span here? 2 weeks should be more than enough.
> + 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()
--
https://code.launchpad.net/~ack/maas-kpi/+git/maas-kpi/+merge/435665
Your team MAAS Committers is subscribed to branch ~maas-committers/maas-kpi/+git/maas-kpi:master.
References