From 4c4a5ed0d9c3f87f74aa2548fbe37c810ff46b19 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Fri, 4 Oct 2024 22:48:38 +0200 Subject: [PATCH] cloud cost dashboard: fix repeating panels --- grafana-dashboards/common.libsonnet | 6 ++-- grafana-dashboards/cost-attribution.jsonnet | 32 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/grafana-dashboards/common.libsonnet b/grafana-dashboards/common.libsonnet index 430dbd7c0..dec6b5f66 100644 --- a/grafana-dashboards/common.libsonnet +++ b/grafana-dashboards/common.libsonnet @@ -15,12 +15,9 @@ local var = grafonnet.dashboard.variable; query: "", queryType: "infinity", infinityQuery: { - columns: [], - filters: [], format: "table", parser: "backend", refId: "variable", - root_selector: "", source: "url", type: "json", url: "http://aws-ce-grafana-backend.support.svc.cluster.local/hub-names?from=${__from:date}&to=${__to:date}", @@ -32,8 +29,9 @@ local var = grafonnet.dashboard.variable; } ) + var.query.withDatasourceFromVariable(self.infinity_datasource) - + var.query.generalOptions.showOnDashboard.withNothing() + var.query.selectionOptions.withIncludeAll(value=true) + + var.query.generalOptions.showOnDashboard.withNothing() + + var.query.refresh.onTime() , }, } diff --git a/grafana-dashboards/cost-attribution.jsonnet b/grafana-dashboards/cost-attribution.jsonnet index dc63d43c2..f1aa1d237 100644 --- a/grafana-dashboards/cost-attribution.jsonnet +++ b/grafana-dashboards/cost-attribution.jsonnet @@ -43,7 +43,14 @@ local totalDailyCosts = columns: [ {selector: "cost", text: "Cost", type: "number", unit: "currencyUSD"}, {selector: "date", text: "Date", type: "timestamp"} - ] + ], + parser: "backend", + type: "json", + source: "url", + url_options: { + "method": "GET", + "data": "", + }, } ]); @@ -94,6 +101,13 @@ local totalDailyCostsPerHub = {selector: "name", text: "Name", type: "string"}, {selector: "cost", text: "Cost", type: "number"} ], + parser: "backend", + type: "json", + source: "url", + url_options: { + "method": "GET", + "data": "", + }, } ]); @@ -144,6 +158,13 @@ local totalDailyCostsPerComponent = {selector: "name", text: "Name", type: "string"}, {selector: "cost", text: "Cost", type: "number"} ], + parser: "backend", + type: "json", + source: "url", + url_options: { + "method": "GET", + "data": "", + }, } ]); @@ -155,6 +176,8 @@ local totalDailyCostsPerComponentAndHub = Total daily costs per component, for ${hub} ||| ) + + ts.panelOptions.withRepeat('hub') + + ts.panelOptions.withMaxPerRow(2) + ts.options.withTooltip({ mode: 'single', sort: "none" }) + ts.options.withLegend({ "calcs": [ @@ -194,6 +217,13 @@ local totalDailyCostsPerComponentAndHub = {selector: "name", text: "Name", type: "string"}, {selector: "cost", text: "Cost", type: "number"} ], + parser: "backend", + type: "json", + source: "url", + url_options: { + "method": "GET", + "data": "", + }, } ]);