Carbon data collection quick start
Structured quick-reference sections for prerequisites, installation, usage, and troubleshooting.
Prerequisites
- Python environment with OCI SDK installed (`pip install oci`)
- OCI credentials and profile configured with Usage/Cost API access
- Read access to target compartments and emissions/usage APIs
- Writable path for CSV and JSON export outputs
Data availability timing
OCI carbon/emissions data can lag by 1-2 months. Schedule recurring collections after the data availability window to avoid empty datasets.
Standard collection workflow
- 1Start with a single compartment or small scope to validate authentication and output shape.
- 2Use monthly granularity first to align with sustainability dashboards and reporting cadence.
- 3Expand to tenancy-wide collection once you confirm API access, date availability, and export formats.
- 4Automate monthly collections and feed CSV/JSON outputs into dashboards or downstream analysis.
pip install ocipython oci-carbon-emissions-collector.py --profile DEFAULT --compartment-id ocid1.compartment... --granularity monthlypython oci-carbon-emissions-collector.py --all-compartments --output ./carbon-reports --format csv,jsonFilters and outputs
| Capability | Why it matters | Typical use |
|---|---|---|
| Compartment filtering | Target business units/environments | Pilot runs, delegated ownership reviews |
| Time/date filtering | Control reporting windows | Monthly/quarterly sustainability reports |
| CSV export | Dashboard ingestion and analysis | Power BI / Tableau |
| JSON export | Automation and data pipelines | Custom integrations / APIs |
Recommended reporting cadence
| Cadence | Scope | Goal |
|---|---|---|
| Monthly | All production + shared compartments | Trend tracking and stakeholder reporting |
| Quarterly | Full tenancy | Program review and optimization planning |
| Ad hoc | Specific compartment | Investigate spikes or anomalies |
- Keep a consistent output path/naming convention to make historical comparisons easier.
Troubleshooting
- If results are empty, confirm the requested date range is available in OCI and retry with an older reporting window.
- If authentication fails, verify OCI config/profile settings and test CLI/API access before rerunning.
- If the script errors on filters, simplify to a minimal query first (single compartment + monthly granularity) and expand incrementally.
Data interpretation
Treat exported values as OCI-sourced sustainability inputs; validate methodology alignment before comparing against other providers in a single dashboard.
Quick Start Guide
Get your OCI carbon emissions data cooking in minutes with our step-by-step recipe for sustainability success.
Setup & Authentication
• Install OCI SDK: pip install oci
• Configure OCI credentials and profile
• Verify Usage API access permissions
Run Your First Collection
• Start with single compartment testing
• Use monthly granularity for initial runs
• Verify data availability and format
Scale & Automate
• Expand to enterprise-wide collection
• Schedule automated monthly reports
• Integrate with sustainability dashboards
Comprehensive Carbon Intelligence
Our OCI Carbon Emissions Collector provides enterprise-grade features for complete sustainability visibility across your Oracle Cloud Infrastructure.
Multi-Compartment Collection
Harvest carbon emissions data across your entire OCI tenancy with compartment-specific filtering and aggregation.
Flexible Export Formats
Generate CSV and JSON reports optimized for Power BI, Tableau, and custom sustainability dashboards.
Enterprise Authentication
OCI config file and profile-based authentication with support for multiple tenancies and environments.
Advanced Filtering
Service, region, compartment, and time-based filtering with support for complex query combinations.
Multiple Granularities
Daily and monthly carbon emissions reporting with automatic date validation and formatting.
Comprehensive Error Handling
Detailed error reporting with troubleshooting guidance and graceful handling of API limitations.
Flexible Date Ranges
Custom date range selection with automatic first-of-month validation and data availability checks.
Multiple Emission Types
Location-based and market-based carbon emission calculations with power-based and spend-based methods.
Recipe Examples
Master the art of carbon data collection with these proven recipes for different sustainability scenarios.
Basic Monthly Collection
Perfect for getting started with carbon emissions tracking across your OCI environment.
python oci_carbon_emissions.py \
--start-date 2024-01-01 \
--end-date 2024-03-01 \
--output-format csvCompartment-Specific Analysis
Target specific compartments for detailed carbon footprint analysis and optimization.
python oci_carbon_emissions.py \
--start-date 2024-01-01 \
--end-date 2024-02-01 \
--compartment-ids comp1,comp2 \
--group-by service,region \
--output-format jsonDaily Granularity Reporting
Generate detailed daily carbon emissions reports for precise tracking and analysis.
python oci_carbon_emissions.py \
--start-date 2024-01-01 \
--end-date 2024-01-31 \
--granularity DAILY \
--emission-type MARKET_BASED \
--output-format csvEnterprise Automation
Automated execution for scheduled sustainability reporting with custom profiles.
python oci_carbon_emissions.py \
--config-file /path/to/config \
--profile PRODUCTION \
--start-date 2024-01-01 \
--end-date 2024-02-01 \
--limit 500 \
--summaryTechnical Specifications
Enterprise-grade carbon emissions collection with comprehensive OCI integration and professional-quality output formats.
Requirements
Python 3.6+ with OCI SDK
Install with: pip install oci
OCI Configuration
Config file or environment variables properly configured
Usage API Access
Permissions on target OCI compartments
Internet Connectivity
Access to OCI API endpoints
Data Availability Understanding
Carbon data is available monthly with processing delays
Configuration Options
Emission Types
• Location-based: Based on grid emission factors
• Market-based: Based on contractual arrangements
Calculation Methods
• Power-based: Energy consumption calculations
• Spend-based: Financial spend calculations
Output Formats
• CSV: Optimized for Excel and dashboard tools
• JSON: Structured data for API integration
Granularity Options
• Daily: Detailed day-by-day tracking
• Monthly: Month-over-month trends
Chef's Best Practices
Master the art of carbon emissions collection with these proven techniques from the CloudCostChefs kitchen.
Start Small, Scale Smart
Begin with a single compartment and monthly granularity to test authentication and service availability before scaling to enterprise-wide carbon data collection.
Pro Tip: Like testing a new recipe with a small portion first, validate your setup with limited scope before expanding to full production collection.
Monthly Automation Schedule
Schedule monthly runs on the 5th to ensure data availability for the previous month. Carbon data typically has processing delays.
Implementation: Use cron jobs or task schedulers with OCI config file authentication for automated reporting.
Choose Appropriate Granularity
Use monthly granularity for trend analysis and executive reporting. Reserve daily granularity for detailed optimization analysis.
Performance: Monthly reports are faster and more suitable for dashboard consumption and trend analysis.
Monitor and Review Errors
The script provides detailed error messages with troubleshooting guidance. Review error logs regularly and address permission or service issues.
Error Handling: Common issues include API limits, permission errors, and data availability delays.
Ready to Get Started?
Download the OCI Carbon Emissions Data Collector and start harvesting sustainability insights from your Oracle Cloud Infrastructure today.
OCI Carbon Emissions Collector
Professional Python script with comprehensive OCI integration, flexible export formats, and enterprise-grade error handling.
Why CloudCostChefs?
No Enterprise Bloat
Practical, actionable tools without unnecessary complexity or vendor lock-in.
Community-Driven
Open-source tools developed by practitioners for practitioners.
Immediate Value
Start collecting carbon emissions data in minutes, not months.
Related CloudCostChefs Tools
Complete your sustainability toolkit with these complementary tools from the CloudCostChefs kitchen.
Azure Carbon Emissions Collector
PowerShell script for collecting Azure carbon emissions data across subscriptions with comprehensive reporting.
OCI Cost Optimization Guide
Comprehensive guide for optimizing Oracle Cloud Infrastructure costs with sustainability best practices.
Mise-en-Place VM Scheduler
Multi-cloud VM scheduling for cost optimization and carbon footprint reduction across all major cloud providers.
What to do next
Pick the path that fits where you are right now.