Power BI
Power BI Integration
Extract cost data from the Koku API into Microsoft Excel using Power Query, then visualize and distribute reports using Microsoft Power BI Desktop and Power BI Service.
Source code: cost-mgmt-powerbi-sample
Overview
This integration uses Excel Power Query as the data extraction layer and Power BI for visualization. Excel workbooks call the Cost Management REST API, transform and flatten the responses, and store the data locally. Power BI reads the Excel files and renders them as interactive report pages.
graph LR
A[Cost Management API] -->|REST + OAuth2| B[Excel Power Query]
B -->|.xlsx files| C[Power BI Desktop]
C -->|Publish| D[Power BI Service]
D --> E[Report Consumers]
Architecture
| Layer | Technology | Role |
|---|---|---|
| Data extraction | Excel Power Query (M language) | Calls API, handles pagination, flattens JSON |
| Authentication | Service account (Client ID + Secret) | OAuth2 via auth.csv file |
| Data storage | Excel workbooks (.xlsx) | Intermediate cache between API and Power BI |
| Visualization | Power BI Desktop (.pbix) | Interactive dashboards and charts |
| Distribution | Power BI Service | Published reports for stakeholders |
Available Excel Workbooks
| Workbook | Data Source | Content |
|---|---|---|
Hello.xlsx | Basic connectivity test | Verifies API access works |
OpenShift_Daily_Costs.xlsx | OpenShift costs | Daily costs for all group-by dimensions |
OpenShift_Daily_Usage.xlsx | OpenShift usage | Resource usage metrics |
AWS_Daily_Costs.xlsx | AWS costs | Daily costs for all AWS group-by dimensions |
Optimizations.xlsx | Resource optimization | Rightsizing recommendations |
Power BI Report Pages
The Cost Management console pages map to Power BI report pages:
| Console Area | Power BI Page |
|---|---|
| OpenShift → Details | OpenShift Details |
| OpenShift → Cost overview / Historical | Cost Overview |
| Amazon Web Services → Details | Amazon Web Services |
| Optimizations | Optimizations |
Quick Start
Prerequisites
- Windows machine with Microsoft Excel 2016+ (Power Query must be available)
- Power BI Desktop (latest version from Microsoft)
- A Red Hat service account with Cost Management access
Setup
- Download the latest release and unzip
- Copy
auth.csv.sampletodata/auth.csv - Replace the placeholder values with your service account Client ID and Client Secret (comma-separated)
Load Data into Excel
- Open one of the Excel workbooks (start with
Hello.xlsxto test connectivity) - Go to Data → Get Data → Data Source Settings and update the
auth.csvfile path - In the Data_Period sheet, set Start and End dates (format:
mm/dd/yyyy) - Click Refresh All in the Data ribbon
- Wait for all sheets to refresh, then save
Load into Power BI
- Open
PowerBI/CostManagement.pbixin Power BI Desktop - Go to Home → Transform Data → Data source settings
- Update the folder path to point to your
data/cost_management/directory - Click Apply changes when prompted
- Click Refresh to load the latest data
- Publish to Power BI Service: Home → Publish
API Endpoints Used
The Excel workbooks call these Koku API endpoints:
| Workbook | Endpoint |
|---|---|
| OpenShift costs | GET /api/cost-management/v1/reports/openshift/costs/ |
| OpenShift usage | GET /api/cost-management/v1/reports/openshift/memory/ and /cpu/ |
| AWS costs | GET /api/cost-management/v1/reports/aws/costs/ |
| Optimizations | GET /api/cost-management/v1/recommendations/openshift/ |
Parameters include filter[resolution]=daily, filter[time_scope_value] for
the date range, and various group_by dimensions.
Data Retention
The Cost Management API retains the last 90 days of data. To maintain a longer history:
- Refresh Excel workbooks on a regular schedule (weekly or monthly)
- Keep copies of workbooks with different date ranges
- Store older workbooks alongside current ones — Power BI will read all
.xlsxfiles in the data source directory
Extending
To add support for other providers (Azure, GCP):
- Create a new Excel workbook modeled after
AWS_Daily_Costs.xlsx - Update the Power Query to target the appropriate API endpoint
(e.g.,
/reports/azure/costs/,/reports/gcp/costs/) - Add the workbook to the
data/cost_management/directory - Create new Power BI report pages to visualize the additional data
- Refresh all data and republish
Refer to the API Catalog for available endpoints and parameters.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Authentication error during refresh | Incorrect credentials in auth.csv | Verify Client ID and Secret are correct |
| Privacy level prompt | Excel security settings | Set to “Ignore Privacy Levels” in Query Options → Privacy |
| Data source access error | auth.csv path mismatch | Update path in Data Source Settings |
| Long refresh times | Large date range | Use shorter periods (≤ 30 days per workbook) |
| Empty sheets after refresh | API returns no data for the date range | Check date format and ensure data exists in Cost Management |
Further Reading
- cost-mgmt-powerbi-sample README — Full setup guide with screenshots
- Power Query Documentation — Microsoft Power Query reference
- Cost Management API Reference — API endpoint catalog