Skip to content

feat: support expire prometheus metrics#10869

Merged
juststillthinking merged 5 commits into
apache:masterfrom
juststillthinking:support-expire-prometheus-metrics
Feb 18, 2024
Merged

feat: support expire prometheus metrics#10869
juststillthinking merged 5 commits into
apache:masterfrom
juststillthinking:support-expire-prometheus-metrics

Conversation

@juststillthinking

Copy link
Copy Markdown
Contributor

Description

The prometheus metrics we record are stored in LRUs, and although there is no memory leakage, the metrics are not eliminated until they reach the upper limit of the LRUs. As the metrics become more and more numerous, the prometheus server consumes more and more CPU when pulling data, and a mechanism is needed to eliminate the outdated data.

Fixes #9627

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@juststillthinking
juststillthinking marked this pull request as draft January 25, 2024 12:53
@ShenFeng312

Copy link
Copy Markdown
Contributor

LGTM!

Comment thread conf/config-default.yaml Outdated
# - 100
# - 200
# - 500
# expire: 86400 # the expiration time after metrics become inactive, unit: second

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default value should be 0 to keep the same strategy as before, no expiration time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@theweakgod

Copy link
Copy Markdown
Contributor

👍

@juststillthinking
juststillthinking marked this pull request as ready for review February 6, 2024 10:16

@shreemaan-abhishek shreemaan-abhishek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread conf/config-default.yaml Outdated

@membphis membphis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@god12311

Copy link
Copy Markdown

@monkeyDluffy6017 Hello, if I want to fix this issue in version 3.2.2 of APISIX, can I make the changes according to the code in this link (https://github.com/apache/apisix/pull/10869/files), or can I directly replace the prometheus/exporter.lua file? Looking forward to your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: apisix 内存管理-过期监控key不释放问题

8 participants