diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index e34ea5668d..18ae6dfdf1 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -693,6 +693,7 @@ func QueryHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) e Start: start, End: start, Step: step, + RemoteAddr: r.RemoteAddr, Deadline: deadline, LookbackDelta: lookbackDelta, } @@ -777,6 +778,7 @@ func queryRangeHandler(startTime time.Time, w http.ResponseWriter, query string, Start: start, End: end, Step: step, + RemoteAddr: r.RemoteAddr, Deadline: deadline, MayCache: mayCache, LookbackDelta: lookbackDelta, diff --git a/app/vmselect/promql/active_queries.go b/app/vmselect/promql/active_queries.go index 079502dc56..a0078a38ad 100644 --- a/app/vmselect/promql/active_queries.go +++ b/app/vmselect/promql/active_queries.go @@ -20,7 +20,8 @@ func WriteActiveQueries(w io.Writer) { now := time.Now() for _, aqe := range aqes { d := now.Sub(aqe.startTime) - fmt.Fprintf(w, "\tduration: %.3fs, id=%016X, query=%q, start=%d, end=%d, step=%d\n", d.Seconds(), aqe.qid, aqe.q, aqe.start, aqe.end, aqe.step) + fmt.Fprintf(w, "\tduration: %.3fs, id=%016X, remote_addr=%q, query=%q, start=%d, end=%d, step=%d\n", + d.Seconds(), aqe.qid, aqe.remoteAddr, aqe.q, aqe.start, aqe.end, aqe.step) } } @@ -32,12 +33,13 @@ type activeQueries struct { } type activeQueryEntry struct { - start int64 - end int64 - step int64 - qid uint64 - q string - startTime time.Time + start int64 + end int64 + step int64 + qid uint64 + remoteAddr string + q string + startTime time.Time } func newActiveQueries() *activeQueries { @@ -52,6 +54,7 @@ func (aq *activeQueries) Add(ec *EvalConfig, q string) uint64 { aqe.end = ec.End aqe.step = ec.Step aqe.qid = atomic.AddUint64(&nextActiveQueryID, 1) + aqe.remoteAddr = ec.RemoteAddr aqe.q = q aqe.startTime = time.Now() diff --git a/app/vmselect/promql/eval.go b/app/vmselect/promql/eval.go index df67f7743a..d6c3a3e367 100644 --- a/app/vmselect/promql/eval.go +++ b/app/vmselect/promql/eval.go @@ -75,7 +75,8 @@ type EvalConfig struct { End int64 Step int64 - Deadline netstorage.Deadline + RemoteAddr string + Deadline netstorage.Deadline MayCache bool