Dabz / ccloudexporter

Prometheus exporter for Confluent Cloud API metric
https://docs.confluent.io/current/cloud/metrics-api.html
87 stars 53 forks source link

Query intervals should be aligned to minute boundaries #46

Closed sirianni closed 4 years ago

sirianni commented 4 years ago

The query interval timeFrom is taken by applying the configured delay to time.Now() https://github.com/Dabz/ccloudexporter/blob/77195baebee292593d6a56255a971e5c415beb41/cmd/internal/collector/query.go#L72

Instead, the start time should be time.Now() with the seconds truncated (i.e. rounded down to the nearest minute). Since the Metrics API only stores data at minutely granularity, using time.Now() is effectively rounding up to the next minute, which makes the effective delay less than the configured delay.

For example:

Dabz commented 4 years ago

Good catch, that explains a few behaviors :/ Let me do the PR, it should be pretty straightforward.

Dabz commented 4 years ago

47 truncate the seconds in the interval. It seems to make the delay effective: at 10:27 with a 2 minutes delay, I got the point from 10:25.