Skip to content

Commit

Permalink
Add filters to View in CostExplorer link
Browse files Browse the repository at this point in the history
  • Loading branch information
mendaomn authored and mtfranchetto committed May 16, 2023
1 parent 1b4c3df commit 5a58daa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frontend/src/old-pages/Clusters/Costs/CostData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ const months = [
i18next.t('costMonitoring.costData.chart.months.dec'),
]

function buildCostExplorerLink(domain: string, clusterName: string) {
const uri = `${domain}/cost-management/home#/cost-explorer?granularity=Monthly&historicalRelativeRange=LAST_12_MONTHS&groupBy=[]&filter=[{"dimension":{"id":"TagKey","displayValue":"Tag"},"operator":"INCLUDES","values":[{"value":"${clusterName}"}],"growableValue":{"value":"parallelcluster:cluster-name","displayValue":"parallelcluster:cluster-name"}}]`

return encodeURI(uri)
}

export function CostData({clusterName}: Props) {
const {t} = useTranslation()
const defaultRegion = useState(['aws', 'region'])
Expand Down Expand Up @@ -112,7 +118,8 @@ export function CostData({clusterName}: Props) {
)

const domain = consoleDomain(region)
const costExplorerHref = `${domain}/cost-management/home#/cost-explorer`
const costExplorerHref = buildCostExplorerLink(domain, clusterName)

const budgetsHref = `${domain}/billing/home#/budgets`

const i18nStrings: BarChartProps<XAxisValueType>['i18nStrings'] = useMemo(
Expand Down

0 comments on commit 5a58daa

Please sign in to comment.