Skip to content

Commit 1986f51

Browse files
committed
Fix Prometheus collector
Now that we fetch the forecast too we need to ensure we only process today's value. Tomorrow at the same time might have the same price which will lead to errors.
1 parent 12b717d commit 1986f51

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

prometheus.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ func (v *vattenfallCollector) Collect(ch chan<- prometheus.Metric) {
3939
log.Println(err)
4040
}
4141
for _, entry := range data {
42+
if entry.Timestamp.Day() != now.Day() {
43+
continue
44+
}
4245
if entry.Timestamp.Hour() == now.Hour() {
4346
ch <- prometheus.MustNewConstMetric(v.prices,
4447
prometheus.GaugeValue, entry.Value, entry.Region)

0 commit comments

Comments
 (0)