regions added
This commit is contained in:
parent
98187b4c0b
commit
3c70bcc5ec
@ -269,3 +269,18 @@ export const yearlySpendSummary = `
|
||||
GROUP BY year
|
||||
ORDER BY usageYear ASC;
|
||||
`;
|
||||
|
||||
|
||||
///dashboard/regions
|
||||
export const resourceBreakdownByRegion = `
|
||||
SELECT
|
||||
COALESCE(NULLIF(TRIM(product_region_code), ''), 'global') AS regionCode,
|
||||
SUM(line_item_blended_cost) AS totalBlendedCost,
|
||||
COUNT(DISTINCT line_item_resource_id) AS resourceCount,
|
||||
COUNT(DISTINCT line_item_product_code) AS serviceCount,
|
||||
COUNT(DISTINCT line_item_usage_account_id) AS accountCount
|
||||
FROM ${process.env.ATHENA_CU_TABLE}
|
||||
WHERE line_item_blended_cost > 0
|
||||
GROUP BY COALESCE(NULLIF(TRIM(product_region_code), ''), 'global')
|
||||
ORDER BY totalBlendedCost DESC
|
||||
`;
|
||||
|
||||
13
server.js
13
server.js
@ -387,6 +387,19 @@ server.get("/dashboard/yearly-spend", async (request, reply) => {
|
||||
const results = await retrieveResultsAsync(queryExecutionId);
|
||||
return results;
|
||||
});
|
||||
server.get("/dashboard/regions", async (request, reply) => {
|
||||
try {
|
||||
const queryExecutionId = await executeQueryAsync(dashboardQueries.resourceBreakdownByRegion);
|
||||
const results = await retrieveResultsAsync(queryExecutionId);
|
||||
return results;
|
||||
} catch (err) {
|
||||
request.log.error(err);
|
||||
return reply.status(500).send({
|
||||
error: "Failed to fetch resource breakdown by region",
|
||||
details: err.message
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user