Skip to content

Commit d339e2e

Browse files
committed
Merge branch 'release/v2.3.0' into feature/rename-buildpacks-to-runpacks
2 parents 86accef + 77ee673 commit d339e2e

File tree

12 files changed

+696
-467
lines changed

12 files changed

+696
-467
lines changed

client/src/components/apps/alerts.vue

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<template>
2+
<div>
3+
4+
<v-alert
5+
v-for="rule in rules" :key="rule.name"
6+
:text="rule.alert?.annotations.description"
7+
:title="rule.name"
8+
:type="rule.alerting ? 'error' : 'success'"
9+
variant="tonal"
10+
density="compact"
11+
style="transform: scale(0.7); transform-origin: left; margin-bottom: -8px;"
12+
></v-alert>
13+
</div>
14+
</template>
15+
16+
<script lang="ts">
17+
import axios from 'axios'
18+
19+
20+
export interface Rule {
21+
duration: number
22+
health: string
23+
labels: Object
24+
name: string
25+
query: string
26+
alerting: boolean
27+
alert?: Alert
28+
}
29+
30+
31+
export interface Alert {
32+
activeAt: string
33+
annotations: {
34+
description: string
35+
summary: string
36+
}
37+
labels: Object
38+
state: string
39+
value: number
40+
}
41+
42+
export default {
43+
data() {
44+
return {
45+
rules: [] as Rule[],
46+
timer: null as any
47+
}
48+
},
49+
props: {
50+
pipeline: {
51+
type: String,
52+
required: true
53+
},
54+
phase: {
55+
type: String,
56+
required: true
57+
},
58+
app: {
59+
type: String,
60+
required: true
61+
}
62+
},
63+
computed: {
64+
alertstate(rule: Rule) {
65+
if (rule.alerting ) {
66+
return 'error'
67+
} else {
68+
return 'info'
69+
}
70+
}
71+
},
72+
created() {
73+
this.loadRules()
74+
},
75+
mounted() {
76+
this.startTimer();
77+
},
78+
unmounted() {
79+
clearInterval(this.timer);
80+
},
81+
methods: {
82+
startTimer() {
83+
this.timer = setInterval(() => {
84+
this.loadRules()
85+
}, 10000);
86+
},
87+
loadRules() {
88+
axios.get(`/api/rules/${this.pipeline}/${this.phase}/${this.app}`)
89+
.then(response => {
90+
this.rules = response.data
91+
})
92+
}
93+
}
94+
}
95+
</script>

client/src/components/apps/detail.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default defineComponent({
118118
href: `/pipeline/${this.pipeline}/${this.phase}/${this.app}/detail`,
119119
},
120120
{
121-
title: 'App-'+this.app,
121+
title: 'App.'+this.app,
122122
disabled: true,
123123
href: `/pipeline/${this.pipeline}/${this.phase}/${this.app}/detail`,
124124
}

client/src/components/apps/metrics.vue

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
<template>
22
<v-container>
3+
4+
<div v-if="!kubero.metricsEnabled">
5+
<v-row>
6+
<v-col
7+
cols="12"
8+
md="6"
9+
style="margin-top: 20px;"
10+
>
11+
<v-alert
12+
outlined
13+
type="info"
14+
variant="tonal"
15+
border="start"
16+
>
17+
<h3>No metrics available</h3>
18+
<p>
19+
Metrics are not available for this application. Metrics can be enabled in the Kubero CRD.
20+
</p>
21+
</v-alert>
22+
</v-col>
23+
</v-row>
24+
</div>
25+
<div v-if="kubero.metricsEnabled">
326
<v-row class="justify-space-between mb-2">
427
<v-col cols="8" sm="8" md="8" lg="8" xl="8">
5-
<!--<h1>Vulnerabilities in {{ app }}</h1>-->
28+
<Alerts :app="app" :phase="phase" :pipeline="pipeline"/>
629
</v-col>
730
<v-col>
831
<v-select
@@ -30,10 +53,16 @@
3053
</v-col>
3154
</v-row>
3255
<v-row>
33-
<v-col cols="12" sm="12" md="12">
56+
<!--
57+
<v-col cols="6" sm="6" md="6">
3458
CPU usage
3559
<VueApexCharts type="line" height="180" :options="cpuOptions" :series="cpuData"></VueApexCharts>
3660
</v-col>
61+
-->
62+
<v-col cols="12" sm="12" md="12">
63+
CPU usage
64+
<VueApexCharts type="line" height="180" :options="cpuOptions" :series="cpuDataRate"></VueApexCharts>
65+
</v-col>
3766
</v-row>
3867
<!--
3968
<v-row>
@@ -65,14 +94,18 @@
6594
<VueApexCharts type="area" height="180" :options="httpResponseTrafficOptions" :series="httpResponseTrafficData"></VueApexCharts>
6695
</v-col>
6796
</v-row>
97+
</div>
6898
</v-container>
6999
</template>
70100

71101
<script lang="ts">
72102
import { defineComponent } from 'vue'
73103
import VueApexCharts from "vue3-apexcharts";
104+
import { useKuberoStore } from '../../stores/kubero'
105+
import { mapState } from 'pinia'
74106
75107
import axios from "axios";
108+
import Alerts from './alerts.vue';
76109
77110
const colors = ['#8560a9', '#a887c9', '#b99bd6', '#d2bde6']
78111
@@ -541,6 +574,10 @@ export default defineComponent({
541574
name: string,
542575
data: number[][],
543576
}[],
577+
cpuDataRate: [] as {
578+
name: string,
579+
data: number[][],
580+
}[],
544581
loadData: [] as {
545582
name: string,
546583
data: number[][],
@@ -565,19 +602,28 @@ export default defineComponent({
565602
name: string,
566603
data: number[][],
567604
}[],
568-
scale: '24h' as '2h'| '24h' | '7d',
605+
scale: '2h' as '2h'| '24h' | '7d',
606+
timer: null as any,
569607
}),
570608
components: {
571609
VueApexCharts,
610+
Alerts,
572611
},
573612
mounted() {
574613
this.refreshMetrics();
614+
this.startTimer();
615+
},
616+
unmounted() {
617+
clearInterval(this.timer);
575618
},
576619
watch: {
577620
scale: function (val) {
578621
this.refreshMetrics();
579622
}
580623
},
624+
computed: {
625+
...mapState(useKuberoStore, ['kubero']),
626+
},
581627
methods: {
582628
/*
583629
generateMetrics(limit: number) {
@@ -589,14 +635,23 @@ export default defineComponent({
589635
return metrics;
590636
},
591637
*/
638+
startTimer() {
639+
this.timer = setInterval(() => {
640+
console.log("refreshing metrics");
641+
this.refreshMetrics();
642+
}, 4000);
643+
},
592644
refreshMetrics() {
645+
if (this.kubero.metricsEnabled) {
593646
this.getMemoryMetrics();
594647
//this.getLoadMetrics();
595-
this.getCpuMetrics();
648+
//this.getCpuMetrics();
649+
this.getCpuMetricsRate();
596650
this.getHttpStatusCodeMetrics();
597651
this.getResponseTimeMetrics();
598652
this.getHttpStatusCodeIncreaseMetrics();
599653
this.getResponseTrafficMetrics();
654+
}
600655
},
601656
getMemoryMetrics() {
602657
@@ -678,6 +733,7 @@ export default defineComponent({
678733
});
679734
},
680735
getCpuMetrics() {
736+
// use 'rate' instead of 'increase' when comparing to limit and request
681737
axios.get(`/api/longtermmetrics/cpu/${this.pipeline}/${this.phase}/${this.app}/increase`, {
682738
params: {
683739
scale: this.scale
@@ -690,6 +746,20 @@ export default defineComponent({
690746
console.log(error);
691747
});
692748
},
749+
getCpuMetricsRate() {
750+
// use 'rate' instead of 'increase' when comparing to limit and request
751+
axios.get(`/api/longtermmetrics/cpu/${this.pipeline}/${this.phase}/${this.app}/rate`, {
752+
params: {
753+
scale: this.scale
754+
}
755+
})
756+
.then((response) => {
757+
this.cpuDataRate = response.data;
758+
})
759+
.catch((error) => {
760+
console.log(error);
761+
});
762+
},
693763
},
694764
});
695765
</script>

client/src/layouts/default/View.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default defineComponent({
4747
this.kubero.buildPipeline = result.data.buildPipeline;
4848
this.kubero.auditEnabled = result.data.auditEnabled;
4949
this.kubero.consoleEnabled = result.data.consoleEnabled;
50+
this.kubero.metricsEnabled = result.data.metricsEnabled;
5051
5152
})
5253
.catch((err) => {

client/src/stores/kubero.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const useKuberoStore = defineStore('kubero', {
1717
templatesEnabled: true,
1818
buildPipeline: false,
1919
consoleEnabled: false,
20+
metricsEnabled: false,
2021
},
2122
buildPipeline: false,
2223
}),

0 commit comments

Comments
 (0)