-
Notifications
You must be signed in to change notification settings - Fork 837
metrics for monitoring delete requests #2445
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 1 commit
72511f9
b0cc286
871568c
f1a4dce
1141020
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,7 @@ import ( | |||||
| "github.com/go-kit/kit/log" | ||||||
| "github.com/go-kit/kit/log/level" | ||||||
| "github.com/gogo/protobuf/proto" | ||||||
| "github.com/prometheus/client_golang/prometheus" | ||||||
| "github.com/prometheus/common/model" | ||||||
| "github.com/prometheus/prometheus/promql" | ||||||
| "github.com/weaveworks/common/user" | ||||||
|
|
@@ -24,6 +25,42 @@ import ( | |||||
|
|
||||||
| const millisecondPerDay = int64(24 * time.Hour / time.Millisecond) | ||||||
|
|
||||||
| type purgerMetrics struct { | ||||||
| deleteRequestsProcessedTotal *prometheus.CounterVec | ||||||
| deleteRequestsChunksSelectedTotal *prometheus.CounterVec | ||||||
| deleteRequestsProcessingFailures *prometheus.GaugeVec | ||||||
| } | ||||||
|
|
||||||
| func newPurgerMetrics(r prometheus.Registerer) *purgerMetrics { | ||||||
| m := purgerMetrics{} | ||||||
|
|
||||||
| m.deleteRequestsProcessedTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||||||
|
||||||
| Namespace: "cortex", | ||||||
| Name: "purger_delete_requests_processed_total", | ||||||
| Help: "Number of delete requests processed per user", | ||||||
| }, []string{"user"}) | ||||||
| m.deleteRequestsChunksSelectedTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||||||
| Namespace: "cortex", | ||||||
| Name: "purger_delete_requests_chunks_selected_total", | ||||||
| Help: "Number of chunks selected while building delete plans per user", | ||||||
| }, []string{"user"}) | ||||||
| m.deleteRequestsProcessingFailures = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||||||
|
||||||
| Namespace: "cortex", | ||||||
| Name: "purger_delete_requests_processing_failure", | ||||||
|
||||||
| Name: "purger_delete_requests_processing_failure", | |
| Name: "purger_delete_requests_processing_failures", |
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.
Is it more like processedChunkIDs?
Also there is no need to return it back from the function – modifications are already visible to the caller. Function comment should however mention this fact (that passed map is modified).
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,22 +5,48 @@ import ( | |
| "fmt" | ||
| "net/http" | ||
|
|
||
| "github.com/prometheus/client_golang/prometheus" | ||
|
|
||
| "github.com/cortexproject/cortex/pkg/util" | ||
|
|
||
| "github.com/prometheus/common/model" | ||
| "github.com/prometheus/prometheus/promql" | ||
| "github.com/weaveworks/common/user" | ||
| ) | ||
|
|
||
| type deleteRequestHandlerMetrics struct { | ||
| deleteRequestsReceivedTotal *prometheus.CounterVec | ||
| } | ||
|
|
||
| func newDeleteRequestHandlerMetrics(r prometheus.Registerer) *deleteRequestHandlerMetrics { | ||
| m := deleteRequestHandlerMetrics{} | ||
|
|
||
| m.deleteRequestsReceivedTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
|
||
| Namespace: "cortex", | ||
| Name: "purger_delete_requests_received_total", | ||
pracucci marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Help: "Number of delete requests received per user", | ||
| }, []string{"user"}) | ||
|
|
||
| if r != nil { | ||
| r.MustRegister( | ||
| m.deleteRequestsReceivedTotal, | ||
| ) | ||
| } | ||
|
|
||
| return &m | ||
| } | ||
|
|
||
| // DeleteRequestHandler provides handlers for delete requests | ||
| type DeleteRequestHandler struct { | ||
| deleteStore *DeleteStore | ||
| metrics *deleteRequestHandlerMetrics | ||
| } | ||
|
|
||
| // NewDeleteRequestHandler creates a DeleteRequestHandler | ||
| func NewDeleteRequestHandler(deleteStore *DeleteStore) *DeleteRequestHandler { | ||
| func NewDeleteRequestHandler(deleteStore *DeleteStore, registerer prometheus.Registerer) *DeleteRequestHandler { | ||
| deleteMgr := DeleteRequestHandler{ | ||
| deleteStore: deleteStore, | ||
| metrics: newDeleteRequestHandlerMetrics(registerer), | ||
| } | ||
|
|
||
| return &deleteMgr | ||
|
|
@@ -84,6 +110,8 @@ func (dm *DeleteRequestHandler) AddDeleteRequestHandler(w http.ResponseWriter, r | |
| if err := dm.deleteStore.AddDeleteRequest(ctx, userID, model.Time(startTime), model.Time(endTime), match); err != nil { | ||
| http.Error(w, err.Error(), http.StatusInternalServerError) | ||
| } | ||
|
|
||
| dm.metrics.deleteRequestsReceivedTotal.WithLabelValues(userID).Inc() | ||
| } | ||
|
|
||
| // GetAllDeleteRequestsHandler handles get all delete requests | ||
|
|
||
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.
Remove new line please, and merge these two import groups.