Skip to content

Commit

Permalink
Document how to enable ingest old data (#87)
Browse files Browse the repository at this point in the history
* Fix/improvement for issue #81

#81

- Now sending always the timestamp in the Prometheus metrics.
- For ElectricityMaps, we now use the historic endpoint instead of the carbon-intensity one, so we can get both the latest estimated and real values.
- Tested that it works with Ember and CarbonIntensityOrgUK, Watttime not yet (I need to register)
- The label is_estimated has been added in the Prometheus metrics. For ElectricityMaps it can provide values for both, or for one of the two, depending on the location.
- For the other providers it always returns the value as is_estimated=false (the default) because I didn't make any changes. I'm. not 100% sure this is correct for all of them, or if some of the providers also return estimations (to investigate).
- The error handling when parsing generates a lot of clutter, not sure if there's a better way to do it in go...

* Fix for Watttime - was missing the is_estimated label...

for relative carbon intensity

Otherwise we see this error, for example:

panic: inconsistent label cardinality: expected 5 label values but got 6 in []string{"CAISO_NORTH", "", "WattTime", "", "percent", "false"}

* Cleaned up some commented code

* It turns out that all the other providers return estimated values

Thus, we are setting IsEstimated to true.
See for more info #83 (comment)

* Some renaming as suggested by Chris

* Update pkg/provider/electricity_maps.go

Co-authored-by: Ross Fairbanks <ross@rossfairbanks.com>

* Document how to fix "old" samples not being ingested

in Prometheus.

Related to PR #83 "For the Prometheus exporter, the values based on ElecticityMaps provider are estimations and not the real values"

* Corrections suggested by Ross

Co-authored-by: Ross Fairbanks <ross@rossfairbanks.com>

---------

Co-authored-by: Flavia Paganelli <flavia@30mhz.com>
Co-authored-by: Ross Fairbanks <ross@rossfairbanks.com>
  • Loading branch information
3 people authored Aug 29, 2024
1 parent 785bd57 commit e9456c2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,18 @@ View the metrics with curl.
$ curl -s http://localhost:8000/metrics | grep grid
# HELP grid_intensity_carbon_average Average carbon intensity for the electricity grid in this location.
# TYPE grid_intensity_carbon_average gauge
grid_intensity_carbon_average{provider="Ember",location="FR",units="gCO2 per kWh"} 67.781
grid_intensity_carbon_average{provider="Ember",location="FR",units="gCO2 per kWh"} 67.781 1718258400000
```

**Note about Prometheus and samples in the past**

If you are using the exporter with the ElectricityMaps provider, it will return a value for estimated, which will be the most recent one, and another value for the real value, which can be a few hours in the past. Depending on your Prometheus installation, it could be that the metrics that have a timestamp in the past are not accepted, with an error such as this:

`Error on ingesting samples that are too old or are too far into the future`

In that case, you can configure the property `tsdb.outOfOrderTimeWindow` to extend the time window accepted, for example to `3h`.


### Docker Image

Build the docker image to deploy the exporter.
Expand Down

0 comments on commit e9456c2

Please sign in to comment.