Skip to content

Commit

Permalink
Add remaining two panels, hub variable is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgianaElena committed Oct 4, 2024
1 parent 907593c commit d29c73c
Showing 1 changed file with 110 additions and 2 deletions.
112 changes: 110 additions & 2 deletions grafana-dashboards/cost-attribution.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
local grafonnet = import 'github.com/grafana/grafonnet/gen/grafonnet-v10.4.0/main.libsonnet';
local dashboard = grafonnet.dashboard;
local ts = grafonnet.panel.timeSeries;
local var = grafonnet.dashboard.variable;

local totalDailyCosts =
ts.new('Total daily costs')
Expand All @@ -11,7 +12,7 @@ local totalDailyCosts =
|||
)
+ ts.standardOptions.withMin(20)
+ ts.options.withTooltip({ mode: 'multi' })
+ ts.options.withTooltip({ mode: 'single' })
+ ts.options.withLegend({
"calcs": [
"count",
Expand Down Expand Up @@ -86,17 +87,124 @@ local totalDailyCostsPerHub =
}
]);

local hubQueryVar =
var.query.new('hub')
+ var.query.queryTypes.withLabelValues(
'Hub',
)
+ var.query.withDatasource(
type= 'yesoreyeram-infinity-datasource', uid='fdsrfvebctptsf'

)
+ var.query.selectionOptions.withIncludeAll();


local totalDailyCostsPerComponent =
ts.new('Total daily costs per component')
+ ts.panelOptions.withDescription(
|||
Total daily costs per component
|||
)
+ ts.options.withTooltip({ mode: 'single', sort: "none" })
+ ts.options.withLegend({
"calcs": [
"count",
"min",
"mean",
"max",
"sum"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true,
"sortBy": "Min (above zero)",
"sortDesc": true
})
+ ts.fieldConfig.defaults.custom.withLineInterpolation('stepAfter')
+ ts.fieldConfig.defaults.custom.withFillOpacity(10)
+ ts.fieldConfig.defaults.custom.withStacking("none")
+ ts.standardOptions.color.withMode("palette-classic")
+ ts.standardOptions.thresholds.withMode("absolute")
+ ts.standardOptions.thresholds.withSteps([
{color: "green", value: null},
{color: "red", value: 80}
])
+ ts.standardOptions.withUnit('currencyUSD')
+ ts.queryOptions.withTargets([
{
datasource: { type: 'yesoreyeram-infinity-datasource', uid: 'fdsrfvebctptsf' },
url: "http://aws-ce-grafana-backend.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}",
format: "timeseries",
refId: "A",
columns: [
{selector: "date", text: "Date", type: "timestamp"},
{selector: "name", text: "Name", type: "string"},
{selector: "cost", text: "Cost", type: "number"}
],
}
]);


local totalDailyCostsPerComponentandHub =
ts.new('Total daily costs per component, for ${hub}')
+ ts.panelOptions.withDescription(
|||
Total daily costs per component, for ${hub}
|||
)
+ ts.options.withTooltip({ mode: 'single', sort: "none" })
+ ts.options.withLegend({
"calcs": [
"count",
"min",
"mean",
"max",
"sum"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true,
"sortBy": "Min (above zero)",
"sortDesc": true
})
+ ts.fieldConfig.defaults.custom.withLineInterpolation('stepAfter')
+ ts.fieldConfig.defaults.custom.withFillOpacity(10)
+ ts.fieldConfig.defaults.custom.withStacking("none")
+ ts.standardOptions.color.withMode("palette-classic")
+ ts.standardOptions.thresholds.withMode("absolute")
+ ts.standardOptions.thresholds.withSteps([
{color: "green", value: null},
{color: "red", value: 80}
])
+ ts.standardOptions.withUnit('currencyUSD')
+ ts.queryOptions.withTargets([
{
datasource: { type: 'yesoreyeram-infinity-datasource', uid: 'fdsrfvebctptsf' },
url: "http://aws-ce-grafana-backend.support.svc.cluster.local/total-costs-per-component?from=${__from:date}&to=${__to:date}&hub=${hub}",
format: "timeseries",
refId: "A",
columns: [
{selector: "date", text: "Date", type: "timestamp"},
{selector: "name", text: "Name", type: "string"},
{selector: "cost", text: "Cost", type: "number"}
],
}
]);


dashboard.new('Cloud cost attribution')
+ dashboard.withUid('edw06h7udjwg0b')
+ dashboard.withEditable(true)
+ dashboard.time.withFrom('now-30d')
+ dashboard.withVariables(hubQueryVar)
+ dashboard.withPanels(
grafonnet.util.grid.makeGrid(
[
totalDailyCosts,
totalDailyCostsPerHub
totalDailyCostsPerHub,
totalDailyCostsPerComponent,
totalDailyCostsPerComponentandHub
],
panelWidth=24,
panelHeight=12,
Expand Down

0 comments on commit d29c73c

Please sign in to comment.