Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
uses: ./.github/workflows/step_packaging.yml

docker:
needs: [build]
needs: [build, test-e2e]
uses: ./.github/workflows/step_images.yml
# Since workflow_dispatch inputs are only available on manual triggers
# we need to set default values to the context vars here
Expand All @@ -96,7 +96,7 @@ jobs:
registry_provider: ${{ inputs.docker_hub_registry_provider || 'dockerhub' }}

quay:
needs: [build]
needs: [build, test-e2e]
uses: ./.github/workflows/step_images.yml
# Since workflow_dispatch inputs are only available on manual triggers
# we need to set default values to the context vars here
Expand Down
2 changes: 1 addition & 1 deletion etc/litestream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ litestream replicate -config=/etc/litestream/config.yml

assuming the config file is installed at `/etc/litestream/config.yml`.

An [Ansible role](https://mahendrapaipuri.github.io/ansible/branch/main/litestream_role.html)
An [Ansible role](https://ceems-dev.github.io/ansible/branch/main/litestream_role.html)
is also available to be able to install and configure litestream using Ansible.
7 changes: 4 additions & 3 deletions pkg/collector/emissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ const emissionsCollectorSubsystem = "emissions"
var (
emissionProviders = CEEMSExporterApp.Flag(
"collector.emissions.provider",
`Exports emission factors from these providers (default: all).
`Exports emission factors from these providers (default: global, owid).
Supported providers:
- "global": World average carbon intensity (https://www.iea.org/reports/electricity-2025/emissions)
- "owid": Our World In Data (https://ourworldindata.org/grapher/carbon-intensity-electricity?tab=table)
- "emaps": Electricity Maps (https://app.electricitymaps.com/)
- "rte": RTE eCO2 Mix (Only for France) (https://www.rte-france.com/en/eco2mix/co2-emissions)
- "wt": Watt Time (https://docs.watttime.org/#tag/Introduction)`,
).Enums("owid", "emaps", "rte", "wt")
).Default("global", "owid").Enums("global", "owid", "emaps", "rte", "wt")
)

type emissionsCollector struct {
Expand All @@ -51,7 +52,7 @@ func NewEmissionsCollector(logger *slog.Logger) (Collector, error) {
// Create a new instance of EmissionCollector
emissionFactorProviders, err := emissions.NewFactorProviders(logger, *emissionProviders)
if err != nil {
logger.Error("Failed to create new EmissionCollector", "err", err)
logger.Error("Failed to create new emissions collector", "err", err)

return nil, err
}
Expand Down

Large diffs are not rendered by default.

144 changes: 72 additions & 72 deletions pkg/emissions/data/carbon-intensity-owid.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2371,30 +2371,30 @@ Haiti,HTI,2019,556.60376
Haiti,HTI,2020,568.62744
Haiti,HTI,2021,572.81555
Haiti,HTI,2022,534.6535
High-income countries,,2000,497.98947
High-income countries,,2001,497.03085
High-income countries,,2002,497.4434
High-income countries,,2003,507.51978
High-income countries,,2004,498.94467
High-income countries,,2005,499.22586
High-income countries,,2006,496.14996
High-income countries,,2007,501.36987
High-income countries,,2008,495.17072
High-income countries,,2009,479.0897
High-income countries,,2010,479.5317
High-income countries,,2011,478.7199
High-income countries,,2012,480.07574
High-income countries,,2013,474.80606
High-income countries,,2014,468.51764
High-income countries,,2015,457.3982
High-income countries,,2016,446.0089
High-income countries,,2017,440.9906
High-income countries,,2018,432.45615
High-income countries,,2019,414.2442
High-income countries,,2020,393.32025
High-income countries,,2021,399.64816
High-income countries,,2022,398.7797
High-income countries,,2023,378.95743
High-income countries,,2000,497.6921
High-income countries,,2001,496.73584
High-income countries,,2002,497.1337
High-income countries,,2003,507.21478
High-income countries,,2004,498.6189
High-income countries,,2005,498.91058
High-income countries,,2006,495.83844
High-income countries,,2007,501.05676
High-income countries,,2008,494.8443
High-income countries,,2009,478.75827
High-income countries,,2010,479.21304
High-income countries,,2011,478.40503
High-income countries,,2012,479.74597
High-income countries,,2013,474.49698
High-income countries,,2014,468.2066
High-income countries,,2015,457.02835
High-income countries,,2016,445.65448
High-income countries,,2017,440.62003
High-income countries,,2018,432.0989
High-income countries,,2019,413.89804
High-income countries,,2020,392.97186
High-income countries,,2021,399.27426
High-income countries,,2022,398.41647
High-income countries,,2023,378.63004
Honduras,HND,2000,263.73624
Honduras,HND,2001,345.26855
Honduras,HND,2002,404.81924
Expand Down Expand Up @@ -3100,30 +3100,30 @@ Low-income countries,,2019,327.9304
Low-income countries,,2020,302.78467
Low-income countries,,2021,291.4869
Low-income countries,,2022,273.10455
Lower-middle-income countries,,2000,638.6798
Lower-middle-income countries,,2001,640.9345
Lower-middle-income countries,,2002,641.7841
Lower-middle-income countries,,2003,636.46857
Lower-middle-income countries,,2004,625.31744
Lower-middle-income countries,,2005,625.97675
Lower-middle-income countries,,2006,623.28906
Lower-middle-income countries,,2007,624.4456
Lower-middle-income countries,,2008,632.91266
Lower-middle-income countries,,2009,638.0642
Lower-middle-income countries,,2010,634.08215
Lower-middle-income countries,,2011,626.46606
Lower-middle-income countries,,2012,634.3922
Lower-middle-income countries,,2013,632.4382
Lower-middle-income countries,,2014,642.1003
Lower-middle-income countries,,2015,651.0639
Lower-middle-income countries,,2016,656.00507
Lower-middle-income countries,,2017,645.78735
Lower-middle-income countries,,2018,646.3905
Lower-middle-income countries,,2019,639.54004
Lower-middle-income countries,,2020,627.2164
Lower-middle-income countries,,2021,624.2525
Lower-middle-income countries,,2022,615.04095
Lower-middle-income countries,,2023,630.8106
Lower-middle-income countries,,2000,637.8539
Lower-middle-income countries,,2001,640.25684
Lower-middle-income countries,,2002,641.0282
Lower-middle-income countries,,2003,635.74097
Lower-middle-income countries,,2004,624.68384
Lower-middle-income countries,,2005,625.2358
Lower-middle-income countries,,2006,622.664
Lower-middle-income countries,,2007,623.82764
Lower-middle-income countries,,2008,632.395
Lower-middle-income countries,,2009,637.53644
Lower-middle-income countries,,2010,633.6427
Lower-middle-income countries,,2011,626.0287
Lower-middle-income countries,,2012,633.9165
Lower-middle-income countries,,2013,632.08344
Lower-middle-income countries,,2014,641.7062
Lower-middle-income countries,,2015,650.68536
Lower-middle-income countries,,2016,655.6774
Lower-middle-income countries,,2017,645.4199
Lower-middle-income countries,,2018,646.1169
Lower-middle-income countries,,2019,639.2874
Lower-middle-income countries,,2020,626.84436
Lower-middle-income countries,,2021,623.993
Lower-middle-income countries,,2022,614.84106
Lower-middle-income countries,,2023,630.4919
Luxembourg,LUX,2000,225
Luxembourg,LUX,2001,287.35632
Luxembourg,LUX,2002,317.85715
Expand Down Expand Up @@ -5483,30 +5483,30 @@ United States Virgin Islands,VIR,2020,640.625
United States Virgin Islands,VIR,2021,636.3636
United States Virgin Islands,VIR,2022,632.35297
United States Virgin Islands,VIR,2023,641.791
Upper-middle-income countries,,2000,589.51373
Upper-middle-income countries,,2001,597.01056
Upper-middle-income countries,,2002,604.2267
Upper-middle-income countries,,2003,620.6766
Upper-middle-income countries,,2004,619.2279
Upper-middle-income countries,,2005,628.1388
Upper-middle-income countries,,2006,638.1497
Upper-middle-income countries,,2007,648.1559
Upper-middle-income countries,,2008,631.01917
Upper-middle-income countries,,2009,638.2973
Upper-middle-income countries,,2010,633.89417
Upper-middle-income countries,,2011,646.51526
Upper-middle-income countries,,2012,631.7128
Upper-middle-income countries,,2013,634.2011
Upper-middle-income countries,,2014,625.7929
Upper-middle-income countries,,2015,607.29956
Upper-middle-income countries,,2016,596.53204
Upper-middle-income countries,,2017,592.25507
Upper-middle-income countries,,2018,588.7053
Upper-middle-income countries,,2019,575.83
Upper-middle-income countries,,2020,566.4339
Upper-middle-income countries,,2021,562.7759
Upper-middle-income countries,,2022,551.98206
Upper-middle-income countries,,2023,547.6743
Upper-middle-income countries,,2000,590.8655
Upper-middle-income countries,,2001,598.29144
Upper-middle-income countries,,2002,605.5407
Upper-middle-income countries,,2003,621.88983
Upper-middle-income countries,,2004,620.4181
Upper-middle-income countries,,2005,629.28143
Upper-middle-income countries,,2006,639.2033
Upper-middle-income countries,,2007,649.15857
Upper-middle-income countries,,2008,631.9719
Upper-middle-income countries,,2009,639.24506
Upper-middle-income countries,,2010,634.74115
Upper-middle-income countries,,2011,647.32184
Upper-middle-income countries,,2012,632.5038
Upper-middle-income countries,,2013,634.90125
Upper-middle-income countries,,2014,626.4753
Upper-middle-income countries,,2015,608.058
Upper-middle-income countries,,2016,597.2393
Upper-middle-income countries,,2017,592.9675
Upper-middle-income countries,,2018,589.355
Upper-middle-income countries,,2019,576.4437
Upper-middle-income countries,,2020,567.07104
Upper-middle-income countries,,2021,563.38776
Upper-middle-income countries,,2022,552.54614
Upper-middle-income countries,,2023,548.1984
Uruguay,URY,2000,67.19367
Uruguay,URY,2001,25.945946
Uruguay,URY,2002,27.083332
Expand Down
6 changes: 4 additions & 2 deletions pkg/emissions/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"log/slog"
)

// Global carbon intensity.
// Ref: https://www.iea.org/reports/electricity-2025/emissions
const (
globalEmissionFactor = 475
globalEmissionFactor = 445
globalEmissionsProvider = "global"
)

Expand All @@ -18,7 +20,7 @@ type globalProvider struct {

func init() {
// Register emissions provider
Register(globalEmissionsProvider, "World Average", NewGlobalProvider)
Register(globalEmissionsProvider, "IEA", NewGlobalProvider)
}

// NewGlobalProvider returns a new Provider that returns a constant global average emission factor.
Expand Down
66 changes: 33 additions & 33 deletions pkg/emissions/owid.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,42 @@ func init() {
Register(owidEmissionsProvider, "OWID", NewOWIDProvider)
}

// NewOWIDProvider returns a new Provider that returns emission factor from OWID data.
func NewOWIDProvider(logger *slog.Logger) (Provider, error) {
// Read CSV file
carbonIntensityCSV, err := dataDir.ReadFile("data/carbon-intensity-owid.csv")
if err != nil {
return nil, fmt.Errorf("failed to read OWID data file: %w", err)
}

// Read OWID data CSV file
emissionData, err := readOWIDData(carbonIntensityCSV)
if err != nil {
return nil, err
}

logger.Info("Emission factors from OWID data will be reported.")

return &owidProvider{
logger: logger,
emissionData: emissionData,
}, nil
}

// Get emission factor for a given country.
func (s *owidProvider) Update() (EmissionFactors, error) {
return s.emissionData, nil
}

// Stop updaters and release all resources.
func (s *owidProvider) Stop() error {
return nil
}

// readOWIDData reads the carbon intensity CSV file and returns the most "recent"
// factor for each country.
// The file can be fetched from https://ourworldindata.org/grapher/carbon-intensity-electricity?tab=table
// The data is updated every year and the next update will be in June 2025
// The data is updated every year and the next update will be in June 2026
// Data sources: Ember - Yearly Electricity Data (2023); Ember - European Electricity Review (2022); Energy Institute - Statistical Review of World Energy (2023).
func readOWIDData(contents []byte) (EmissionFactors, error) {
// Read all records
Expand Down Expand Up @@ -76,35 +108,3 @@ func readOWIDData(contents []byte) (EmissionFactors, error) {

return emissionFactors, nil
}

// NewOWIDProvider returns a new Provider that returns emission factor from OWID data.
func NewOWIDProvider(logger *slog.Logger) (Provider, error) {
// Read CSV file
carbonIntensityCSV, err := dataDir.ReadFile("data/carbon-intensity-owid.csv")
if err != nil {
return nil, fmt.Errorf("failed to read OWID data file: %w", err)
}

// Read OWID data CSV file
emissionData, err := readOWIDData(carbonIntensityCSV)
if err != nil {
return nil, err
}

logger.Info("Emission factor from OWID data will be reported.")

return &owidProvider{
logger: logger,
emissionData: emissionData,
}, nil
}

// Get emission factor for a given country.
func (s *owidProvider) Update() (EmissionFactors, error) {
return s.emissionData, nil
}

// Stop updaters and release all resources.
func (s *owidProvider) Stop() error {
return nil
}
2 changes: 1 addition & 1 deletion scripts/checkmetrics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
search_dir="$2"
for entry in "$search_dir"/*
do
lint=$($1 check metrics < "$entry" 2>&1 | grep -v -E "^ceems_compute_unit_(memory_fail_count|memsw_fail_count)|ceems_meminfo_|ceems_cpu_count|ceems_cpu_per_core_count|ceems_compute_unit_gpu_sm_count")
lint=$($1 check metrics < "$entry" 2>&1 | grep -v -E "^ceems_compute_unit_(memory_fail_count|memsw_fail_count)|ceems_meminfo_|ceems_cpu_count|ceems_cpu_per_core_count|ceems_compute_unit_gpu_sm_count|ceems_emissions_gCo2_kWh")

if [[ -n $lint ]]; then
echo -e "Some Prometheus metrics do not follow best practices:\n"
Expand Down
1 change: 1 addition & 0 deletions scripts/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ then
--collector.ipmi.test-mode \
--collector.infiniband \
--collector.rapl \
--collector.emissions \
--web.listen-address "127.0.0.1:${port}" \
--web.disable-exporter-metrics \
--log.level="debug" > "${logfile}" 2>&1 &
Expand Down
9 changes: 8 additions & 1 deletion website/docs/configuration/ceems-exporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,18 @@ token to make requests for emission factors.
:::tip[TIP]

This collector is not enabled by default as it is not needed to run on every compute node.
This collector can be run separately on a node that has internet access by disabling the
When dynamic emission factors provided (like RTE, Electricity Maps or Watt Time) are enabled,
this collector can be run separately on a node that has internet access by disabling the
rest of the collectors.

:::

In the case of OWID static data,
[ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes
are used in Prometheus label `country_code`. Electricity maps has its own codes of
regions that report emission factors and the same codes are exported in Prometheus
data.

## eBPF based continuous profiling

CEEMS exporter has an optional component that can continuous profiling compute units
Expand Down
7 changes: 0 additions & 7 deletions website/docs/configuration/grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ Similarly, CEEMS API server must be added as
datasource to pull the list of compute units and their usage metrics. Following snippet shows
a basic configuration for the datasource:

:::important[IMPORTANT]

Header name `X-Ceems-Disable-User-Check` must always be set even when the value is set to `false`
just to ensure that end users cannot spoof the header value from the browser requests.

:::

```yaml
# List of datasources that CEEMS uses
datasources:
Expand Down
6 changes: 3 additions & 3 deletions website/docs/installation/ansible.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ use the role `ceems.ansible.ceems_api_server`.

The documentation for each role can be found at the following links:

- [CEEMS Exporter Role](https://ceems.github.io/ansible/branch/main/ceems_exporter_role.html)
- [CEEMS API Server Role](https://ceems.github.io/ansible/branch/main/ceems_api_server_role.html)
- [CEEMS Load Balancer Role](https://ceems.github.io/ansible/branch/main/ceems_lb_role.html)
- [CEEMS Exporter Role](https://@ceemsOrg@.github.io/ansible/branch/main/ceems_exporter_role.html)
- [CEEMS API Server Role](https://@ceemsOrg@.github.io/ansible/branch/main/ceems_api_server_role.html)
- [CEEMS Load Balancer Role](https://@ceemsOrg@.github.io/ansible/branch/main/ceems_lb_role.html)