Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def network_usage(datasource):
return G.Graph(
title="Network Usage",
dataSource=datasource,
xAxis=X_TIME,
yAxes=[
G.YAxis(
# 2^20 bytes / second
format="MBs",
label="Transferred",
),
G.YAxis(
show=False,
),
],
targets=[
G.Target(
# Get the rate of data received on the public interface (eth0)
# for each entire node (id="/") over the last minute.
expr="""
receive:container_network_bytes:rate1m / 2 ^ 20
""",
legendFormat="receive",
def single_y_axis(**kwargs):
"""Specify that a graph has a single Y axis.
Parameters are those passed to `YAxis`. Returns a `YAxes` object (i.e. a
pair of axes) that can be used as the yAxes parameter of a graph.
"""
axis = YAxis(**kwargs)
return YAxes(left=axis)
def s4_customer_deployments(datasource):
return G.Graph(
title="Customer Deployments",
dataSource=datasource,
xAxis=X_TIME,
yAxes=[
G.YAxis(
format="none",
label="Total Customer Deployments",
min=0,
max=100,
),
G.YAxis(
show=False,
),
],
targets=[
G.Target(
# Each replicaset and pod end up with their own series. Label
# these more succinctly. Leave them distinct in case it is
# interesting to see where restarts have happened.
expr="""
def PercentUnitAxis(label=None):
"""A Y axis that shows a percentage based on a unit value."""
return G.YAxis(
format=G.PERCENT_UNIT_FORMAT,
label=label,
logBase=1,
max=1,
min=0,
)
def memory_usage(datasource):
return G.Graph(
title="Memory Usage",
dataSource=datasource,
xAxis=X_TIME,
yAxes=[
G.YAxis(
# 2 ^ 30 bytes
format="gbytes",
label="Memory",
),
G.YAxis(
show=False,
),
],
targets=[
G.Target(
expr="""
sum(machine_memory_bytes) / 2 ^ 30
""",
legendFormat="Total Physical Memory",
refId="A",
),
G.Target(
expr="""
rss:container_memory:total / 2 ^ 30
""",
legendFormat="Total Container RSS",
for i in count():
yield unicode(i)
refid = refidgen()
return G.Graph(
title="Tahoe-LAFS Benchmarked Transfer Rate",
dataSource=datasource,
xAxis=X_TIME,
yAxes=[
G.YAxis(
format="Bps",
label="Transfer Rate",
),
G.YAxis(
show=False,
),
],
targets=list(
G.Target(
# The metric is a Histogram. The _sum goes up by the number of
# bytes/second observed by each sample taken. For example, if
# the first benchmark run observes 100 bytes/sec transfer
# rate, the _sum is 100. If the second benchmark run observes
# 75 bytes/sec transfer rate, the _sum is then 175. The
# _count gives the total number of samples present in the
# _sum.
#
# The rate() of the _sum over a recent interval is
# bytes/sec/sec. The rate() of the _count over the same
def filesystem_usage(datasource):
return G.Graph(
title="Filesystem Usage",
dataSource=datasource,
xAxis=X_TIME,
yAxes=[
G.YAxis(
format="percent",
),
G.YAxis(
show=False,
),
],
targets=[
G.Target(
# Get the proportion used of each filesystem on a volume from
# a PersistentVolumeClaim on each node of the cluster. It's
# hard to figure out the role each filesystem serves from this
# graph (since all we get is the PVC name). Better than
# nothing, though. Hopefully later we can do better.
expr="""
100
* filesystem_used_bytes{volume=~"pvc-.*"}
def cpu_usage(datasource, intervals):
return G.Graph(
title="CPU usage",
dataSource=datasource,
xAxis=X_TIME,
yAxes=[
G.YAxis(
format="percent",
label="Average",
min=0,
max=100,
),
G.YAxis(
format="percent",
label="Average",
),
],
targets=list(
G.Target(
# CPU usage (as a percentage of maximum possible) averaged
# over a period is given as 100 times the sum (over all
# containers) of the rate of increase (in seconds) divided by
# the maximum possible increase (1 second per CPU).
def filesystem_usage(datasource):
return G.Graph(
title="Filesystem Usage",
dataSource=datasource,
xAxis=X_TIME,
yAxes=[
G.YAxis(
format="percent",
),
G.YAxis(
show=False,
),
],
targets=[
G.Target(
# Get the proportion used of each filesystem on a volume from
# a PersistentVolumeClaim on each node of the cluster. It's
# hard to figure out the role each filesystem serves from this
# graph (since all we get is the PVC name). Better than
# nothing, though. Hopefully later we can do better.
expr="""
100
* filesystem_used_bytes{volume=~"pvc-.*"}
/ filesystem_size_bytes{volume=~"pvc-.*"}
""",
legendFormat="{{volume}}",