Add color mapping to Grafana dashboard.
This commit is contained in:
@ -2,6 +2,7 @@ from grafanalib.core import RowPanel, BarGauge, GridPos, TimeSeries, ORIENTATION
|
|||||||
GAUGE_DISPLAY_MODE_BASIC
|
GAUGE_DISPLAY_MODE_BASIC
|
||||||
from grafanalib.influxdb import InfluxDBTarget
|
from grafanalib.influxdb import InfluxDBTarget
|
||||||
|
|
||||||
|
from utils.color_mapping import color_mapping_environments
|
||||||
from utils.utils import read_query
|
from utils.utils import read_query
|
||||||
|
|
||||||
prewarming_pool_size = BarGauge(
|
prewarming_pool_size = BarGauge(
|
||||||
@ -13,6 +14,7 @@ prewarming_pool_size = BarGauge(
|
|||||||
orientation=ORIENTATION_VERTICAL,
|
orientation=ORIENTATION_VERTICAL,
|
||||||
displayMode=GAUGE_DISPLAY_MODE_BASIC,
|
displayMode=GAUGE_DISPLAY_MODE_BASIC,
|
||||||
max=None,
|
max=None,
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
idle_runner = TimeSeries(
|
idle_runner = TimeSeries(
|
||||||
@ -22,6 +24,7 @@ idle_runner = TimeSeries(
|
|||||||
gridPos=GridPos(h=10, w=13, x=11, y=1),
|
gridPos=GridPos(h=10, w=13, x=11, y=1),
|
||||||
lineInterpolation="stepAfter",
|
lineInterpolation="stepAfter",
|
||||||
maxDataPoints=None,
|
maxDataPoints=None,
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
runner_startup_duration = TimeSeries(
|
runner_startup_duration = TimeSeries(
|
||||||
@ -32,6 +35,7 @@ runner_startup_duration = TimeSeries(
|
|||||||
unit="ns",
|
unit="ns",
|
||||||
maxDataPoints=None,
|
maxDataPoints=None,
|
||||||
lineInterpolation="smooth",
|
lineInterpolation="smooth",
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
used_runner = TimeSeries(
|
used_runner = TimeSeries(
|
||||||
|
@ -2,7 +2,7 @@ from grafanalib.core import RowPanel, GridPos, Stat, TimeSeries, Heatmap, BarGau
|
|||||||
ORIENTATION_VERTICAL, GAUGE_DISPLAY_MODE_BASIC
|
ORIENTATION_VERTICAL, GAUGE_DISPLAY_MODE_BASIC
|
||||||
from grafanalib.influxdb import InfluxDBTarget
|
from grafanalib.influxdb import InfluxDBTarget
|
||||||
|
|
||||||
from utils.color_mapping import grey_all_mapping
|
from utils.color_mapping import grey_all_mapping, color_mapping_environments
|
||||||
from utils.utils import read_query
|
from utils.utils import read_query
|
||||||
|
|
||||||
requests_per_minute = TimeSeries(
|
requests_per_minute = TimeSeries(
|
||||||
@ -67,6 +67,7 @@ number_of_executions = BarGauge(
|
|||||||
orientation=ORIENTATION_VERTICAL,
|
orientation=ORIENTATION_VERTICAL,
|
||||||
displayMode=GAUGE_DISPLAY_MODE_BASIC,
|
displayMode=GAUGE_DISPLAY_MODE_BASIC,
|
||||||
max=None,
|
max=None,
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
execution_duration = BarGauge(
|
execution_duration = BarGauge(
|
||||||
@ -79,6 +80,7 @@ execution_duration = BarGauge(
|
|||||||
format="ns",
|
format="ns",
|
||||||
max=None,
|
max=None,
|
||||||
decimals=2,
|
decimals=2,
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
executions_per_runner = BarGauge(
|
executions_per_runner = BarGauge(
|
||||||
@ -90,6 +92,7 @@ executions_per_runner = BarGauge(
|
|||||||
displayMode=GAUGE_DISPLAY_MODE_GRADIENT,
|
displayMode=GAUGE_DISPLAY_MODE_GRADIENT,
|
||||||
max=None,
|
max=None,
|
||||||
decimals=2,
|
decimals=2,
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
executions_per_minute = BarGauge(
|
executions_per_minute = BarGauge(
|
||||||
@ -101,6 +104,7 @@ executions_per_minute = BarGauge(
|
|||||||
displayMode=GAUGE_DISPLAY_MODE_GRADIENT,
|
displayMode=GAUGE_DISPLAY_MODE_GRADIENT,
|
||||||
max=None,
|
max=None,
|
||||||
decimals=2,
|
decimals=2,
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
general_row = RowPanel(
|
general_row = RowPanel(
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from grafanalib.core import RowPanel, GridPos, Histogram, TimeSeries
|
from grafanalib.core import RowPanel, GridPos, Histogram, TimeSeries
|
||||||
from grafanalib.influxdb import InfluxDBTarget
|
from grafanalib.influxdb import InfluxDBTarget
|
||||||
|
|
||||||
from utils.utils import read_query
|
from utils.color_mapping import color_mapping_environments
|
||||||
|
from utils.utils import read_query, deep_update_dict
|
||||||
|
|
||||||
execution_duration_extra_json = {
|
execution_duration_extra_json = {
|
||||||
"fieldConfig": {
|
"fieldConfig": {
|
||||||
@ -10,6 +11,7 @@ execution_duration_extra_json = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
deep_update_dict(execution_duration_extra_json, color_mapping_environments)
|
||||||
execution_duration = Histogram(
|
execution_duration = Histogram(
|
||||||
title="Execution duration",
|
title="Execution duration",
|
||||||
dataSource="Poseidon",
|
dataSource="Poseidon",
|
||||||
@ -33,6 +35,7 @@ executions_per_runner = Histogram(
|
|||||||
fillOpacity=50,
|
fillOpacity=50,
|
||||||
lineWidth=1,
|
lineWidth=1,
|
||||||
maxDataPoints=None,
|
maxDataPoints=None,
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
executions_per_minute = TimeSeries(
|
executions_per_minute = TimeSeries(
|
||||||
@ -42,6 +45,7 @@ executions_per_minute = TimeSeries(
|
|||||||
gridPos=GridPos(h=10, w=13, x=11, y=57),
|
gridPos=GridPos(h=10, w=13, x=11, y=57),
|
||||||
maxDataPoints=None,
|
maxDataPoints=None,
|
||||||
lineInterpolation="smooth",
|
lineInterpolation="smooth",
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
request_body_size = TimeSeries(
|
request_body_size = TimeSeries(
|
||||||
@ -53,6 +57,7 @@ request_body_size = TimeSeries(
|
|||||||
unit="bytes",
|
unit="bytes",
|
||||||
maxDataPoints=None,
|
maxDataPoints=None,
|
||||||
lineInterpolation="smooth",
|
lineInterpolation="smooth",
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
runner_per_minute = TimeSeries(
|
runner_per_minute = TimeSeries(
|
||||||
@ -62,6 +67,7 @@ runner_per_minute = TimeSeries(
|
|||||||
gridPos=GridPos(h=10, w=13, x=11, y=67),
|
gridPos=GridPos(h=10, w=13, x=11, y=67),
|
||||||
maxDataPoints=None,
|
maxDataPoints=None,
|
||||||
lineInterpolation="smooth",
|
lineInterpolation="smooth",
|
||||||
|
extraJson=color_mapping_environments,
|
||||||
)
|
)
|
||||||
|
|
||||||
runner_insights_row = RowPanel(
|
runner_insights_row = RowPanel(
|
||||||
|
@ -9,4 +9,4 @@ result = from(bucket: "poseidon/autogen")
|
|||||||
|> filter(fn: (r) => r["event_type"] == "creation")
|
|> filter(fn: (r) => r["event_type"] == "creation")
|
||||||
|> group(columns: ["environment_id", "stage"], mode:"by")
|
|> group(columns: ["environment_id", "stage"], mode:"by")
|
||||||
|> aggregateWindow(every: 1m, fn: count, createEmpty: true)
|
|> aggregateWindow(every: 1m, fn: count, createEmpty: true)
|
||||||
|> aggregateWindow(every: duration(v: int(v: v.windowPeriod) * 5), fn: mean, createEmpty: true)
|
|> aggregateWindow(every: duration(v: int(v: v.windowPeriod) * 8), fn: mean, createEmpty: true)
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
from utils.utils import deep_update_dict
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
def color_mapping(name, color):
|
def color_mapping(name, color):
|
||||||
return {
|
return {
|
||||||
"fieldConfig": {
|
"fieldConfig": {
|
||||||
@ -19,3 +23,23 @@ def color_mapping(name, color):
|
|||||||
|
|
||||||
|
|
||||||
grey_all_mapping = color_mapping("all", "#4c4b5a")
|
grey_all_mapping = color_mapping("all", "#4c4b5a")
|
||||||
|
|
||||||
|
|
||||||
|
def add_color_mapping(mapping_dict, new_item):
|
||||||
|
deep_update_dict(mapping_dict, color_mapping(new_item[0], new_item[1]))
|
||||||
|
return mapping_dict
|
||||||
|
|
||||||
|
|
||||||
|
color_mapping_environments = reduce(add_color_mapping, [
|
||||||
|
("p10/java:8-antlr", "yellow"),
|
||||||
|
("p28/r:4", "blue"),
|
||||||
|
("p29/python:3.8", "orange"),
|
||||||
|
("p31/java:17", "red"),
|
||||||
|
("p33/openhpi/docker_exec_phusion", "purple"),
|
||||||
|
("p11/java:8-antlr", "pink"),
|
||||||
|
("p14/python:3.4", "brown"),
|
||||||
|
("p18/node:0.12", "black"),
|
||||||
|
("p22/python:3.4-rpi-web", "white"),
|
||||||
|
("p25/ruby:2.5", "gray"),
|
||||||
|
("p30/python:3.7-ml", "gold"),
|
||||||
|
], {})
|
||||||
|
@ -4,3 +4,22 @@ def read_query(*names):
|
|||||||
with open("queries/" + name + ".flux", "r") as file:
|
with open("queries/" + name + ".flux", "r") as file:
|
||||||
result += file.read()
|
result += file.read()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def deep_update_dict(base_dict, extra_dict):
|
||||||
|
if extra_dict is None:
|
||||||
|
return base_dict
|
||||||
|
|
||||||
|
for k, v in extra_dict.items():
|
||||||
|
update_dict_entry(base_dict, k, v)
|
||||||
|
|
||||||
|
|
||||||
|
def update_dict_entry(base_dict, k, v):
|
||||||
|
if k in base_dict and hasattr(base_dict[k], "to_json_data"):
|
||||||
|
base_dict[k] = base_dict[k].to_json_data()
|
||||||
|
if k in base_dict and isinstance(base_dict[k], dict):
|
||||||
|
deep_update_dict(base_dict[k], v)
|
||||||
|
elif k in base_dict and isinstance(base_dict[k], list):
|
||||||
|
base_dict[k].extend(v)
|
||||||
|
else:
|
||||||
|
base_dict[k] = v
|
||||||
|
Reference in New Issue
Block a user