Add color mapping to Grafana dashboard.
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
from utils.utils import deep_update_dict
|
||||
from functools import reduce
|
||||
|
||||
|
||||
def color_mapping(name, color):
|
||||
return {
|
||||
"fieldConfig": {
|
||||
@ -19,3 +23,23 @@ def color_mapping(name, color):
|
||||
|
||||
|
||||
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:
|
||||
result += file.read()
|
||||
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