feat: expire stale advanced metrics after not being updated for some time - #1921
Conversation
25a4fc2 to
af3a22c
Compare
|
This PR will be closed in 7 days due to inactivity. |
|
Quang Nguyen (@nddq) this isn't waiting on me, any way to prevent it from being auto-closed? |
|
Matthew McKeen (@mmckeen) removed the stale tag |
|
This PR will be closed in 7 days due to inactivity. |
Quang Nguyen (nddq)
left a comment
There was a problem hiding this comment.
Sorry for taking a while to respond 😅 Gave this some thoughts
af3a22c to
b3b5e8e
Compare
2abfcbe to
8c5bf85
Compare
|
I'm working on refactoring this a bit to be able to add some better testing for the expiration case. |
8c5bf85 to
7f535de
Compare
|
Quang Nguyen (@nddq) this includes a bunch of test coverage (including making sure that the goroutine doesn't leak) as well as a refactor of the base metrics object in order to support that testing. |
7f535de to
f726e75
Compare
|
Quang Nguyen (@nddq) appreciate a review on this when you get the chance :) It's the last PR away from us being able to run the upstream version of Retina rather than our fork. |
Quang Nguyen (nddq)
left a comment
There was a problem hiding this comment.
Overall looks good to me, managed to test the feature in my local cluster and verified that it is working correctly! Just a few nit comments and also the markdown linter is failing (although we might consider disabling it in the future or make it less strict)
…time Signed-off-by: Matthew McKeen <matthew.mckeen@fastly.com>
f726e75 to
444fb85
Compare
Fixed the nits, looks like the Markdown linter is failing on main though. |
Quang Nguyen (nddq)
left a comment
There was a problem hiding this comment.
lgtm, thanks! Just realized that markdown lint is not required to merge PRs
…time (microsoft#1921) # Description With advanced metrics, high-cardinality labels can cause the metrics export to bloat leading to unbounded memory and resource usage. This PR sets up an optional TTL for advanced metrics defined in the `MetricsConfiguration` CRD. By default, the TTL is infinite and cleanup is not tracked or done. When defined, on a period equal to the TTL metrics which have not been updated within the last TTL duration will be removed from the metrics export. For counters and gauges that look like counters, this will be treated by Prometheus similar to any other missing metric (for example from an application restart). As long as functions like `rate` or `increase` are used, calculations will remain accurate. This also includes a refactor of the base metrics object as an interface, allowing mocking in tests and a clean API contract with child objects that compose it. ## Related Issue microsoft#1692 ## Checklist - [X] I have read the [contributing documentation](https://retina.sh/docs/Contributing/overview). - [X] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [X] I have correctly attributed the author(s) of the code. - [X] I have tested the changes locally. - [X] I have followed the project's style guidelines. - [x] I have updated the documentation, if necessary. - [x] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed Deployed, modified CRD to enable/disable and change the TTL. Metrics are re-initialized as expected. Made sure that CRD validation rejects invalid TTL values. Also, added comprehensive tests for the TTL-based cleanup logic. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project. Signed-off-by: Matthew McKeen <matthew.mckeen@fastly.com>
…time (microsoft#1921) # Description With advanced metrics, high-cardinality labels can cause the metrics export to bloat leading to unbounded memory and resource usage. This PR sets up an optional TTL for advanced metrics defined in the `MetricsConfiguration` CRD. By default, the TTL is infinite and cleanup is not tracked or done. When defined, on a period equal to the TTL metrics which have not been updated within the last TTL duration will be removed from the metrics export. For counters and gauges that look like counters, this will be treated by Prometheus similar to any other missing metric (for example from an application restart). As long as functions like `rate` or `increase` are used, calculations will remain accurate. This also includes a refactor of the base metrics object as an interface, allowing mocking in tests and a clean API contract with child objects that compose it. ## Related Issue microsoft#1692 ## Checklist - [X] I have read the [contributing documentation](https://retina.sh/docs/Contributing/overview). - [X] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [X] I have correctly attributed the author(s) of the code. - [X] I have tested the changes locally. - [X] I have followed the project's style guidelines. - [x] I have updated the documentation, if necessary. - [x] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed Deployed, modified CRD to enable/disable and change the TTL. Metrics are re-initialized as expected. Made sure that CRD validation rejects invalid TTL values. Also, added comprehensive tests for the TTL-based cleanup logic. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project. Signed-off-by: Matthew McKeen <matthew.mckeen@fastly.com>
Description
With advanced metrics, high-cardinality labels can cause the metrics export to bloat leading to unbounded memory and resource usage.
This PR sets up an optional TTL for advanced metrics defined in the
MetricsConfigurationCRD. By default, the TTL is infinite and cleanup is not tracked or done.When defined, on a period equal to the TTL metrics which have not been updated within the last TTL duration will be removed from the metrics export.
For counters and gauges that look like counters, this will be treated by Prometheus similar to any other missing metric (for example from an application restart). As long as functions like
rateorincreaseare used, calculations will remain accurate.This also includes a refactor of the base metrics object as an interface, allowing mocking in tests and a clean API contract with child objects that compose it.
Related Issue
#1692
Checklist
git commit -S -s ...). See this documentation on signing commits.Screenshots (if applicable) or Testing Completed
Deployed, modified CRD to enable/disable and change the TTL.
Metrics are re-initialized as expected.
Made sure that CRD validation rejects invalid TTL values.
Also, added comprehensive tests for the TTL-based cleanup logic.
Please refer to the CONTRIBUTING.md file for more information on how to contribute to this project.