Set --metrics-max-age default value equal to relist interval #230
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
--metrics-max-age
flag has been introduced in #136 with a fixed default value of 20 minutes.The current default value leads to the situation that when metrics drop out of Prometheus, they are still reported in the discovery information of the Custom Metrics API (
/apis/custom.metrics.k8s.io/v1beta1
) for 20 minutes.This can be quite confusing if you don't know about the
--metrics-max-age
flag and expect the behaviour that is described in the docs. Namely that the Prometheus Adapter discovers all metrics that have been updated since the last discovery query (defined by the relist interval), which is also the reason the relist interval must be at least as large as the Prometheus scraping interval (see #229).By setting the default value of
--metrics-max-age
equal to the relist interval, the expected behaviour as described in the docs is preserved, but you can still set--metrics-max-age
to some other value if you know about it.The other way to go would be to update the docs and expect all users to set the
--metrics-max-age
flag (and the Helm chart would need to be updated to use it too). But this would make the configuration of the Prometheus Adapter even more complicated than it already is. It is probably easier to just remember to set the relist interval at least as large as the Prometheus scraping interval, than to additionally have to figure out what themetrics-max-age
is and what to set it to.