Skip to content

Commit 2c34494

Browse files
committed
add resource limit fields to utilization queries and charts for applications
1 parent e16ea4a commit 2c34494

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

schema.graphql

+3
Original file line numberDiff line numberDiff line change
@@ -6404,6 +6404,9 @@ type WorkloadUtilization {
64046404
"""Get the current usage for the requested resource type."""
64056405
current(resourceType: UtilizationResourceType!): Float!
64066406

6407+
"""Gets the limit of the resources for the requested resource type."""
6408+
limit(resourceType: UtilizationResourceType!): Float
6409+
64076410
"""
64086411
Gets the requested amount of resources for the requested resource type.
64096412
"""

src/routes/team/[team]/[env]/app/[app]/utilization/+page.gql

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ query ResourceUtilizationForApp(
1717
current_memory: current(resourceType: MEMORY)
1818
requested_cpu: requested(resourceType: CPU)
1919
requested_memory: requested(resourceType: MEMORY)
20+
limit_cpu: limit(resourceType: CPU)
21+
limit_memory: limit(resourceType: MEMORY)
2022
cpu_series: series(input: { start: $start, end: $end, resourceType: CPU }) {
2123
timestamp
2224
value

src/routes/team/[team]/[env]/app/[app]/utilization/+page.svelte

+21-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
readonly value: number;
2424
}[];
2525
26-
function options(data: resourceUsage, request: number, color: string = '#000000'): EChartsOption {
26+
function options(
27+
data: resourceUsage,
28+
request: number,
29+
limit?: number,
30+
color: string = '#000000'
31+
): EChartsOption {
2732
const dates = data?.map((d) => d.timestamp) || [];
2833
return {
2934
tooltip: {
@@ -54,12 +59,19 @@
5459
data: data?.map((d) => d.value) || [],
5560
color
5661
},
62+
{
63+
name: 'Limit',
64+
type: 'line',
65+
data: data?.map(() => limit) || [],
66+
showSymbol: false,
67+
color: '#C30000'
68+
},
5769
{
5870
name: 'Requested',
5971
type: 'line',
6072
data: data?.map(() => request) || [],
6173
showSymbol: false,
62-
color: '#C30000'
74+
color: '#00C300'
6375
}
6476
],
6577
@@ -177,6 +189,7 @@
177189
return { timestamp: d.timestamp, value: d.value / 1024 / 1024 / 1024 };
178190
}),
179191
utilization.requested_memory / 1024 / 1024 / 1024,
192+
utilization.limit_memory ? utilization.limit_memory / 1024 / 1024 / 1024 : undefined,
180193
'rgb(145, 220, 117)'
181194
)}
182195
style="height: 400px"
@@ -186,7 +199,12 @@
186199
<h3 style="margin-bottom: 0">CPU usage</h3>
187200
</span>
188201
<EChart
189-
options={options(utilization.cpu_series, utilization.requested_cpu, 'rgb(131, 191, 246)')}
202+
options={options(
203+
utilization.cpu_series,
204+
utilization.requested_cpu,
205+
utilization.limit_cpu ? utilization.limit_cpu : undefined,
206+
'rgb(131, 191, 246)'
207+
)}
190208
style="height: 400px"
191209
/>
192210
</Card>

0 commit comments

Comments
 (0)