Skip to content

Commit ae6c234

Browse files
committed
Update slow query CLI flag to use frontend scope instead of querier
Signed-off-by: Praveen Shukla <[email protected]>
1 parent 7854473 commit ae6c234

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* `-ingester.max-global-series-per-metric`
1111
* [FEATURE] Flush chunks with stale markers early with `ingester.max-stale-chunk-idle`. #1759
1212
* [FEATURE] EXPERIMENTAL: Added new KV Store backend based on memberlist library. Components can gossip about tokens and ingester states, instead of using Consul or Etcd. #1721
13+
* [FEATURE] Allow Query Frontend to log slow queries #1744
1314
* [ENHANCEMENT] Allocation improvements in adding samples to Chunk. #1706
1415
* [ENHANCEMENT] Consul client now follows recommended practices for blocking queries wrt returned Index value. #1708
1516
* [ENHANCEMENT] Consul client can optionally rate-limit itself during Watch (used e.g. by ring watchers) and WatchPrefix (used by HA feature) operations. Rate limiting is disabled by default. New flags added: `--consul.watch-rate-limit`, and `--consul.watch-burst-size`. #1708
16-
* [FEATURE] Allow Query Frontend to log slow queries #1744
1717

1818
## 0.3.0 / 2019-10-11
1919

pkg/querier/frontend/frontend.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
5555
f.IntVar(&cfg.MaxOutstandingPerTenant, "querier.max-outstanding-requests-per-tenant", 100, "Maximum number of outstanding requests per tenant per frontend; requests beyond this error with HTTP 429.")
5656
f.BoolVar(&cfg.CompressResponses, "querier.compress-http-responses", false, "Compress HTTP responses.")
5757
f.StringVar(&cfg.DownstreamURL, "frontend.downstream-url", "", "URL of downstream Prometheus.")
58-
f.DurationVar(&cfg.LogQueriesLongerThan, "querier.log-queries-longer-than", 0, "Log slow queries")
58+
f.DurationVar(&cfg.LogQueriesLongerThan, "frontend.log-queries-longer-than", 0, "Log slow queries")
5959
}
6060

6161
// Frontend queues HTTP requests, dispatches them to backends, and handles retries
@@ -143,16 +143,16 @@ func (f *Frontend) Handler() http.Handler {
143143
}
144144

145145
func (f *Frontend) handle(w http.ResponseWriter, r *http.Request) {
146-
startTime := time.Now()
147-
resp, err := f.roundTripper.RoundTrip(r)
148-
queryResponseTime := time.Now().Sub(startTime)
149-
150146
userID, err := user.ExtractOrgID(r.Context())
151147
if err != nil {
152148
server.WriteError(w, err)
153149
return
154150
}
155151

152+
startTime := time.Now()
153+
resp, err := f.roundTripper.RoundTrip(r)
154+
queryResponseTime := time.Now().Sub(startTime)
155+
156156
if f.cfg.LogQueriesLongerThan > 0 && queryResponseTime > f.cfg.LogQueriesLongerThan {
157157
level.Warn(f.log).Log("msg", "slow query", "orgID", userID, "url", fmt.Sprintf("http://%s", r.Host+r.RequestURI), "time-taken", queryResponseTime.String())
158158
}

0 commit comments

Comments
 (0)