Skip to content

fix: improve the judgment of the legitimacy of prometheus metrics #2228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

czmjbl
Copy link
Contributor

@czmjbl czmjbl commented May 21, 2025

When scrape request returns "404", it may be considered as a metric. Improve the logic so we can get the correct metrics count.

@@ -104,7 +104,7 @@ bool IsValidMetric(const StringView& line) {
if (c == ' ' || c == '\t') {
continue;
}
if (c == '#') {
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == ':')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个判断条件有什么规范依据吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prometheus 指标名称规范

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -101,6 +101,8 @@ void ScrapeScheduler::OnMetricResult(HttpResponse& response, uint64_t) {
streamScraper->mStreamIndex++;
if (upState) {
streamScraper->FlushCache();
} else {
streamScraper->ClearEventGroup();
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里为啥clear? clear之后,SendMetrics,里面不都是空数据吗

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.

2 participants