diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index e2ea24cf8..8e0f26322 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -774,6 +774,7 @@ func QueryHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r Start: start, End: start, Step: step, + RemoteAddr: r.RemoteAddr, Deadline: deadline, LookbackDelta: lookbackDelta, @@ -861,6 +862,7 @@ func queryRangeHandler(startTime time.Time, at *auth.Token, w http.ResponseWrite 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 6e6a0db41..e27a2b976 100644 --- a/app/vmselect/promql/active_queries.go +++ b/app/vmselect/promql/active_queries.go @@ -20,8 +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, accountID=%d, projectID=%d, query=%q, start=%d, end=%d, step=%d\n", - d.Seconds(), aqe.qid, aqe.accountID, aqe.projectID, aqe.q, aqe.start, aqe.end, aqe.step) + fmt.Fprintf(w, "\tduration: %.3fs, id=%016X, remote_addr=%q, accountID=%d, projectID=%d, query=%q, start=%d, end=%d, step=%d\n", + d.Seconds(), aqe.qid, aqe.remoteAddr, aqe.accountID, aqe.projectID, aqe.q, aqe.start, aqe.end, aqe.step) } } @@ -33,14 +33,15 @@ type activeQueries struct { } type activeQueryEntry struct { - accountID uint32 - projectID uint32 - start int64 - end int64 - step int64 - qid uint64 - q string - startTime time.Time + accountID uint32 + projectID uint32 + start int64 + end int64 + step int64 + qid uint64 + remoteAddr string + q string + startTime time.Time } func newActiveQueries() *activeQueries { @@ -57,6 +58,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 feed1f29c..023c209bb 100644 --- a/app/vmselect/promql/eval.go +++ b/app/vmselect/promql/eval.go @@ -77,7 +77,8 @@ type EvalConfig struct { End int64 Step int64 - Deadline netstorage.Deadline + RemoteAddr string + Deadline netstorage.Deadline MayCache bool