From 786b67c9e0a80c4ae830ba356a0b1d929acc0035 Mon Sep 17 00:00:00 2001 From: Cody Jackson Date: Thu, 18 Mar 2021 13:49:21 -0700 Subject: [PATCH 1/2] Adding grafana graphs to the explorer index --- components/Accordion.vue | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 components/Accordion.vue diff --git a/components/Accordion.vue b/components/Accordion.vue new file mode 100644 index 0000000000..1306c39ab8 --- /dev/null +++ b/components/Accordion.vue @@ -0,0 +1,53 @@ + + + + + From 5a3a86149aeb3d40a2951e88cad511a9bd827098 Mon Sep 17 00:00:00 2001 From: Cody Jackson Date: Tue, 13 Apr 2021 08:58:19 -0700 Subject: [PATCH 2/2] Adding metrics to workloads, pods and nodes rancher/dashboard#2678 --- assets/translations/en-us.yaml | 2 + components/Accordion.vue | 53 --------------------------- components/DashboardMetrics.vue | 6 +++ components/GrafanaDashboard.vue | 12 ++++++ detail/node.vue | 40 +++++++++++++++++--- detail/pod.vue | 44 +++++++++++++++++++++- detail/workload/index.vue | 47 ++++++++++++++++++++++-- pages/c/_cluster/monitoring/index.vue | 47 +++++++++++------------- 8 files changed, 163 insertions(+), 88 deletions(-) delete mode 100644 components/Accordion.vue diff --git a/assets/translations/en-us.yaml b/assets/translations/en-us.yaml index 8f62c6abd0..c878895365 100644 --- a/assets/translations/en-us.yaml +++ b/assets/translations/en-us.yaml @@ -1832,6 +1832,7 @@ node: tab: conditions: Conditions images: Images + metrics: Metrics info: label: Info key: @@ -3468,6 +3469,7 @@ workload: networkSettings: Network Settings podAnnotations: Pod Annotations podLabels: Pod Labels + metrics: Metrics podScheduling: Pod Scheduling nodeScheduling: Node Scheduling ports: Ports diff --git a/components/Accordion.vue b/components/Accordion.vue deleted file mode 100644 index 1306c39ab8..0000000000 --- a/components/Accordion.vue +++ /dev/null @@ -1,53 +0,0 @@ - - - - - diff --git a/components/DashboardMetrics.vue b/components/DashboardMetrics.vue index d31d9d5762..e099fb5549 100644 --- a/components/DashboardMetrics.vue +++ b/components/DashboardMetrics.vue @@ -14,6 +14,10 @@ export default { type: String, required: true, }, + vars: { + type: Object, + default: () => ({}) + }, graphHeight: { type: String, required: true @@ -55,6 +59,7 @@ export default { :refresh-rate="graphOptions.refreshRate" :range="graphOptions.range" :url="detailUrl" + :vars="vars" /> diff --git a/components/GrafanaDashboard.vue b/components/GrafanaDashboard.vue index f1cae8b4fa..cce69135d9 100644 --- a/components/GrafanaDashboard.vue +++ b/components/GrafanaDashboard.vue @@ -10,6 +10,10 @@ export default { type: String, required: true, }, + vars: { + type: Object, + default: () => ({}) + }, range: { type: String, default: null @@ -127,6 +131,14 @@ export default { params.refresh = this.refreshRate; } + if (Object.keys(this.vars).length > 0) { + Object.entries(this.vars).forEach((entry) => { + const paramName = `var-${ entry[0] }`; + + params[paramName] = entry[1]; + }); + } + params.theme = this.theme; return params; diff --git a/detail/node.vue b/detail/node.vue index 6479b71fc4..c1cba213c6 100644 --- a/detail/node.vue +++ b/detail/node.vue @@ -15,7 +15,13 @@ import Poller from '@/utils/poller'; import { METRIC, POD } from '@/config/types'; import createEditView from '@/mixins/create-edit-view'; import { formatSi, exponentNeeded, UNITS } from '@/utils/units'; +import DashboardMetrics from '@/components/DashboardMetrics'; +import { mapGetters } from 'vuex'; +import { allDashboardsExist } from '@/utils/grafana'; +import Loading from '@/components/Loading'; +const NODE_METRICS_DETAIL_URL = '/api/v1/namespaces/cattle-monitoring-system/services/http:rancher-monitoring-grafana:80/proxy/d/rancher-node-detail-1/rancher-node-detail?orgId=1'; +const NODE_METRICS_SUMMARY_URL = '/api/v1/namespaces/cattle-monitoring-system/services/http:rancher-monitoring-grafana:80/proxy/d/rancher-node-1/rancher-node?orgId=1'; const METRICS_POLL_RATE_MS = 30000; const MAX_FAILURES = 2; @@ -25,6 +31,8 @@ export default { components: { Alert, ConsumptionGauge, + DashboardMetrics, + Loading, ResourceTabs, Tab, SortableTable, @@ -39,8 +47,10 @@ export default { }, }, - fetch() { - this.$store.dispatch('cluster/findAll', { type: POD }); + async fetch() { + this.showMetrics = await allDashboardsExist(this.$store.dispatch, this.currentCluster.id, [NODE_METRICS_DETAIL_URL, NODE_METRICS_SUMMARY_URL]); + + return this.$store.dispatch('cluster/findAll', { type: POD }); }, data() { @@ -70,11 +80,15 @@ export default { VALUE, EFFECT ], - podTableHeaders: this.$store.getters['type-map/headersFor'](podSchema) + podTableHeaders: this.$store.getters['type-map/headersFor'](podSchema), + NODE_METRICS_DETAIL_URL, + NODE_METRICS_SUMMARY_URL, + showMetrics: false }; }, computed: { + ...mapGetters(['currentCluster']), memoryUnits() { const exponent = exponentNeeded(this.value.ramCapacity, 1024); @@ -118,6 +132,10 @@ export default { taintTableRows() { return this.value.spec.taints || []; }, + + graphVars() { + return { instance: `${ this.value.internalIp }:9796` }; + } }, mounted() { @@ -160,7 +178,8 @@ export default { - + - + + + + diff --git a/pages/c/_cluster/monitoring/index.vue b/pages/c/_cluster/monitoring/index.vue index 16f00aae6b..33b6b868b9 100644 --- a/pages/c/_cluster/monitoring/index.vue +++ b/pages/c/_cluster/monitoring/index.vue @@ -1,5 +1,4 @@