Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
time = attr.ib(default=g.Time("now-30d", "now"))
# Make it possible to use $source as a source.
templating = attr.ib(default=g.Templating(list=[SOURCE_TEMPLATE]))
# Graph is a g.Graph with reasonable defaults applied.
@attr.s
class Graph(g.Graph):
dataSource = attr.ib(default="$source")
span = attr.ib(default=g.TOTAL_SPAN)
tooltip = attr.ib(default=DECREASING_ORDER_TOOLTIP)
nullPointMode = attr.ib(default=None)
@attr.s
class Row(g.Row):
height = attr.ib(default=PANEL_HEIGHT)
@attr.s
class Target(g.Target):
interval = attr.ib(default="5s")
intervalFactor = attr.ib(default=1)
def simple_graph(title, exprs, legend="", interval="5s", **kwargs):
if not isinstance(exprs, (list, tuple)):
exprs = [exprs]
if legend != "" and len(exprs) != 1:
raise ValueError("legend can be specified only for a 1-element exprs")
return Graph(
title=title,
def resource_row(pod_type: str = None) -> G.Row:
"""
Construct a Grafana row with resource statistics.
"""
if pod_type:
title = "Resources for pods of type {}".format(POD_TYPE_VARIABLE)
else:
title = "Resources for all pod types"
selection = dict(framework_name=FRAMEWORK_VARIABLE)
if pod_type:
selection["executor_name"] = pod_type
return G.Row(
title=title,
repeat=POD_TYPE_VARIABLE.lstrip("$") if pod_type else "",
panels=[
W.prometheus.PromGraph(
data_source=PROMETHEUS_DATA_SOURCE,
title="CPU",
expressions=[
dict(expr=reduction('sum', metric(m, selection), selection),
legendFormat=title)
for m, title in [('cpus_limit', 'Available')]
],
span=3,
steppedLine=True,
yAxes=G.YAxes(left=G.YAxis(format="short", decimals=0)),
),
W.prometheus.PromGraph(
"declines_long",
"revives",
"revives_throttles",
"declines_short",
]
resolution = "1m"
offer_timers = [
"offers_process_p50",
"offers_process_p90",
"offers_process_p99",
"offers_process_max",
]
return G.Row(
title="Scheduler statistics",
panels=[
W.prometheus.PromGraph(
data_source=PROMETHEUS_DATA_SOURCE,
title="cumulative offer statistic",
expressions=[
{"expr": sum(service_metric(m)), "legendFormat": m}
for m in offer_metrics
],
span=3,
steppedLine=True,
yAxes=G.YAxes(left=G.YAxis(format="short", decimals=0)),
),
W.prometheus.PromGraph(
data_source=PROMETHEUS_DATA_SOURCE,
title="offer events per second [{} rate]".format(resolution),
def task_row() -> G.Row:
"""
Construct a Grafana row containing scheduler task statistics
"""
task_metrics = [
"task_status_task_running",
"task_status_task_finished",
"task_status_task_lost",
"task_status_task_failed",
]
resolution = "1m"
return G.Row(
title="Task statistics",
panels=[
W.prometheus.PromGraph(
data_source=PROMETHEUS_DATA_SOURCE,
title="cumulative task statistic",
expressions=[
{"expr": sum(service_metric(m)), "legendFormat": m}
for m in task_metrics
],
span=3,
steppedLine=True,
yAxes=G.YAxes(left=G.YAxis(format="short", decimals=0)),
),
W.prometheus.PromGraph(
data_source=PROMETHEUS_DATA_SOURCE,
title="task events per second [{} rate]".format(resolution),
def Row(
panels, height=None, title='Dashboard Row', showTitle=False
):
assert isinstance(height, (type(None), int))
return core.Row(
panels=panels, height=height, title=title, showTitle=showTitle,
titleSize='h6', editable=False,
)
G.Row(
title="Cluster",
panels=[
cpu_usage(PROMETHEUS, ["1m", "5m", "10m"]),
memory_usage(PROMETHEUS),
network_usage(PROMETHEUS),
filesystem_usage(PROMETHEUS),
],
),
G.Row(
title="Cluster2",
panels=[
process_open_fds(PROMETHEUS),
],
),
G.Row(panels=[
tahoe_lafs_transfer_rate(PROMETHEUS),
s4_customer_deployments(PROMETHEUS),
unhandled_errors(PROMETHEUS),
]),
refId="D",
),
],
),
last_convergence(PROMETHEUS),
]),
G.Row(
title="Cluster",
panels=[
cpu_usage(PROMETHEUS, ["1m", "5m", "10m"]),
memory_usage(PROMETHEUS),
network_usage(PROMETHEUS),
filesystem_usage(PROMETHEUS),
],
),
G.Row(
title="Cluster2",
panels=[
process_open_fds(PROMETHEUS),
],
),
G.Row(panels=[
tahoe_lafs_transfer_rate(PROMETHEUS),
s4_customer_deployments(PROMETHEUS),
unhandled_errors(PROMETHEUS),
]),