Skip to content
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

Add -frontend.enabled-ruler-query-stats flag #6504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SungJin1212
Copy link
Contributor

@SungJin1212 SungJin1212 commented Jan 13, 2025

This PR adds a -frontend.enabled-ruler-query-stats flag to configure whether to report the query stats log for queries coming from the Ruler.

Context & Use case

When the -ruler.frontend-address and -frontend.enabled-ruler-query-stats are enabled, the query-frontend reports the query stats log for queries from the Ruler and other sources. However, the user would want to report the log only from other sources since its main role is to export API endpoints for other sources.
To address this concern, this PR adds -frontend.enabled-ruler-query-stats to report queries only from the other sources.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@SungJin1212 SungJin1212 force-pushed the Add-frontend.enabled-ruler-query-stats branch from 3665b72 to 62d1df3 Compare January 19, 2025 00:18
@pull-request-size pull-request-size bot added size/M and removed size/L labels Jan 19, 2025
@SungJin1212 SungJin1212 force-pushed the Add-frontend.enabled-ruler-query-stats branch from 62d1df3 to 0ad89c4 Compare January 19, 2025 00:21
@pull-request-size pull-request-size bot added size/L and removed size/M labels Jan 19, 2025
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

However, the user would want to report the log only from other sources since its main role is to export API endpoints for other sources.

Idk if I agree that QFE wants to mainly log requests from API endpoints. Why we don't always log all requests?

} else {
level.Info(util_log.WithContext(r.Context(), f.log)).Log(logMessage...)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some duplicate code. Can we just do if else?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking we can just do

shouldLog := source == tripperware.SourceAPI || (f.cfg.EnabledRulerQueryStatsLog && source == tripperware.SourceRuler)
if shouldLog {
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I also like it. I just updated the PR.

LogQueriesLongerThan time.Duration `yaml:"log_queries_longer_than"`
MaxBodySize int64 `yaml:"max_body_size"`
QueryStatsEnabled bool `yaml:"query_stats_enabled"`
EnabledRulerQueryStatsLog bool `yaml:"enabled_ruler_query_stats-log"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we name it enabled_ruler_query_stats_log?

if f.cfg.EnabledRulerQueryStatsLog {
logMessage = append(logMessage, formatQueryString(queryString)...)
level.Info(util_log.WithContext(r.Context(), f.log)).Log(logMessage...)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@SungJin1212
Copy link
Contributor Author

SungJin1212 commented Jan 20, 2025

@yeya24
After using the -ruler.frontend-address, I felt that the logging that the ruler leaves every time it evaluates a rule was interfering with viewing the logs for other requests.

Since the Ruler leaves the rule evaluation log, the -frontend.enabled-ruler-query-stats could remove the duplicated log.

@yeya24
Copy link
Contributor

yeya24 commented Jan 20, 2025

I see. I wonder if we want to make it more extensible or it is too much. Should we accept a list of wildcards of user agent to log or not log?
I am ok with this flag, too

@SungJin1212
Copy link
Contributor Author

@yeya24
I think it'll be enough for now. WDYT?

@SungJin1212 SungJin1212 force-pushed the Add-frontend.enabled-ruler-query-stats branch from 0ad89c4 to c3dc48c Compare January 20, 2025 02:52
@pull-request-size pull-request-size bot added size/M and removed size/L labels Jan 20, 2025
@SungJin1212 SungJin1212 force-pushed the Add-frontend.enabled-ruler-query-stats branch from c3dc48c to e9c8cfb Compare January 20, 2025 04:06
@SungJin1212 SungJin1212 requested a review from yeya24 January 21, 2025 00:57
@SungJin1212 SungJin1212 force-pushed the Add-frontend.enabled-ruler-query-stats branch 3 times, most recently from 25a9850 to 345dc85 Compare January 21, 2025 01:52
@CharlieTLe
Copy link
Member

Hello @SungJin1212, thank you for opening this PR.

There is a release in progress. As such, please rebase your CHANGELOG entry on top of the master branch and move the CHANGELOG entry to the top under ## master / unreleased.

Thanks,
Charlie

@SungJin1212 SungJin1212 force-pushed the Add-frontend.enabled-ruler-query-stats branch from 345dc85 to 2196382 Compare January 23, 2025 04:01
@SungJin1212
Copy link
Contributor Author

@CharlieTLe
I update the CHANGELOG . Thanks!

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

Successfully merging this pull request may close these issues.

4 participants