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

query-frontend: add experimental header for tracking throughput #7966

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

krajorama
Copy link
Contributor

@krajorama krajorama commented Apr 25, 2024

What this PR does

Add an experimental configuration parameter -query-frontend.extra-stats-headers to be able to send fetched chunk bytes to the gateway for measuring throughput.

Which issue(s) this PR fixes or relates to

N/A

Checklist

  • Tests updated.
  • N/A Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • N/A (internal for now) about-versioning.md updated with experimental features.

@@ -62,6 +64,7 @@ func (cfg *HandlerConfig) RegisterFlags(f *flag.FlagSet) {
f.Var(&cfg.LogQueryRequestHeaders, "query-frontend.log-query-request-headers", "Comma-separated list of request header names to include in query logs. Applies to both query stats and slow queries logs.")
f.Int64Var(&cfg.MaxBodySize, "query-frontend.max-body-size", 10*1024*1024, "Max body size for downstream prometheus.")
f.BoolVar(&cfg.QueryStatsEnabled, "query-frontend.query-stats-enabled", true, "False to disable query statistics tracking. When enabled, a message with some statistics is logged for every query.")
f.BoolVar(&cfg.ExtraQueryStatsHeaders, "query-frontend.extra-stats-headers", false, "Add extra query stats headers to the response.")
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a drawback to always returning the header?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, not really, but this is super experimental, don't want people to depend on it

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as Dimitar. You can just document it as experimental in about-version and we're good.

@@ -448,6 +454,12 @@ func writeServiceTimingHeader(queryResponseTime time.Duration, headers http.Head
}
}

func writeStatsHeader(headers http.Header, stats *querier_stats.Stats) {
if stats != nil {
headers.Set(MimirQueryStatsHeaderName, fmt.Sprintf("fetched_chunk_bytes=%d", stats.GetFetchedChunkBytes()))
Copy link
Contributor

Choose a reason for hiding this comment

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

The stats are modified using atomics - so they should be read with:

func (s *Stats) LoadFetchedChunkBytes() uint64 {

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
@krajorama krajorama force-pushed the krajo/samples-loaded-header branch from 83f4820 to f216056 Compare May 9, 2024 10:53
@krajorama
Copy link
Contributor Author

Rebased and removed the flag. Next: change to track samples loaded.

We'll use this instead of chunks bytes as it is simpler for the enduser
to understand.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
@krajorama krajorama force-pushed the krajo/samples-loaded-header branch from 75e398b to 186306e Compare May 9, 2024 14:28
krajorama added a commit to krajorama/prometheus that referenced this pull request May 18, 2024
defaultStatsRenderer->DefaultStatsRenderer
Add short docstrings.

I'd like to use the stats renderer to peek at the statistics in
grafana/mimir#7966

However I cannot call the original function without this export afterwards.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
krajorama added a commit to prometheus/prometheus that referenced this pull request May 18, 2024
defaultStatsRenderer->DefaultStatsRenderer
Add short docstrings.

I'd like to use the stats renderer to peek at the statistics in
grafana/mimir#7966

However I cannot call the original function without this export afterwards.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
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.

None yet

4 participants