-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat: report user query bytes #27188
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
Changes from 9 commits
3a11b43
12f68e6
f5cfdbc
d1922d3
eb0e6eb
4dc0c47
d9e1abc
2237e7c
6d159e0
813f59b
cfe36bf
649924e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,7 @@ import ( | |||||
| "github.com/influxdata/influxdb/models" | ||||||
| "github.com/influxdata/influxdb/monitor" | ||||||
| "github.com/influxdata/influxdb/monitor/diagnostics" | ||||||
| "github.com/influxdata/influxdb/pkg/data/gensyncmap" | ||||||
| "github.com/influxdata/influxdb/prometheus" | ||||||
| "github.com/influxdata/influxdb/query" | ||||||
| "github.com/influxdata/influxdb/services/meta" | ||||||
|
|
@@ -143,12 +144,13 @@ type Handler struct { | |||||
| Controller Controller | ||||||
| CompilerMappings flux.CompilerMappings | ||||||
|
|
||||||
| Config *Config | ||||||
| Logger *zap.Logger | ||||||
| CLFLogger *log.Logger | ||||||
| accessLog *os.File | ||||||
| accessLogFilters StatusFilters | ||||||
| stats *Statistics | ||||||
| Config *Config | ||||||
| Logger *zap.Logger | ||||||
| CLFLogger *log.Logger | ||||||
| accessLog *os.File | ||||||
| accessLogFilters StatusFilters | ||||||
| stats *Statistics | ||||||
| queryBytesPerUser gensyncmap.Map[string, *atomic.Int64] | ||||||
davidby-influx marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| requestTracker *RequestTracker | ||||||
| writeThrottler *Throttler | ||||||
|
|
@@ -322,7 +324,12 @@ func NewHandler(c Config) *Handler { | |||||
| return func(w http.ResponseWriter, r *http.Request, user meta.User) { | ||||||
| // TODO: This is the only place we use AuthorizeUnrestricted. It would be better to use an explicit permission | ||||||
| if user == nil || !user.AuthorizeUnrestricted() { | ||||||
| h.Logger.Info("Unauthorized request", zap.String("user", user.ID()), zap.String("path", r.URL.Path)) | ||||||
| // Don't panic | ||||||
| id := "" | ||||||
| if user != nil { | ||||||
davidby-influx marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| id = user.ID() | ||||||
| } | ||||||
| h.Logger.Info("Unauthorized request", zap.String("user", id), zap.String("path", r.URL.Path)) | ||||||
| h.httpError(w, "error authorizing admin access", http.StatusForbidden) | ||||||
| return | ||||||
| } | ||||||
|
|
@@ -442,7 +449,7 @@ type Statistics struct { | |||||
|
|
||||||
| // Statistics returns statistics for periodic monitoring. | ||||||
| func (h *Handler) Statistics(tags map[string]string) []models.Statistic { | ||||||
| return []models.Statistic{{ | ||||||
| stats := []models.Statistic{{ | ||||||
| Name: "httpd", | ||||||
| Tags: tags, | ||||||
| Values: map[string]interface{}{ | ||||||
|
|
@@ -472,6 +479,35 @@ func (h *Handler) Statistics(tags map[string]string) []models.Statistic { | |||||
| statFluxQueryRequestBytesTransmitted: atomic.LoadInt64(&h.stats.FluxQueryRequestBytesTransmitted), | ||||||
| }, | ||||||
| }} | ||||||
|
|
||||||
| // Add per-user query bytes as separate statistics (one per user) if enabled | ||||||
| if h.Config.UserQueryBytesEnabled && !h.queryBytesPerUser.IsEmpty() { | ||||||
|
||||||
| if h.Config.UserQueryBytesEnabled && !h.queryBytesPerUser.IsEmpty() { | |
| if h.Config.UserQueryBytesEnabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsEmpty() does not require a full traversal of the sync.Map. This comment is wrong
Uh oh!
There was an error while loading. Please reload this page.