[metrics]: Allow request metadata as Prometheus labels - #149
Open
pseudomuto wants to merge 1 commit into
Open
Conversation
Proxy metrics could only be sliced by dimensions the proxy itself knows: the method, the upstream, the outcome. An operator running one proxy for several tenants or clusters has no way to attribute traffic to them, because the thing that identifies them travels in request metadata the collectors never see. Add a metrics.tags list, written as "<header>:<label>", that carries an inbound metadata value onto the metrics emitted while serving a request. The gateway's own request metrics, the routing decision, and the vault operations all gain the configured labels. Things that aren't request based are is left as is. `crypto.Observer`, for example, which has no request context, and has some logic in a go routine with no request available at all. Having 2 different headers mapping to the same label is a startup (validation) error, since Prometheus would panic at runtime with two values set for the same one. There's also some validation for the header and label names to keep them inline with gRPC/Prometheus requirements and ensure they're caught at startup and not at runtime. gRPC binary metadata (ending in `-bin`) are not allowed. Finally, gRPC metadata is a `map[string][]string` where each value is the ordered set of values set for the key. In the case that multiple values exist, the last value is used as the label.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proxy metrics could only be sliced by dimensions the proxy itself knows: the method, the upstream, the outcome. An operator running a single proxy for several tenants or clusters has no way to attribute traffic to them because the identifiers that identify them travel in request metadata that the collectors never see.
Add a
:", that carries an inbound metadata value onto the metrics emitted while serving a request. The gateway's own request metrics, the routing decision, and the vault operations all gain the configured labels.metrics.tagslist, written as "Things that aren't request-based are left as is.
crypto.Observer, for example, has no request context and runs some logic in a goroutine with no request available, so nothing is added there.Having 2 different headers mapping to the same label is a startup (validation) error, since Prometheus would panic at runtime with two values set for the same one. There's also validation for the header and label names to keep them in line with gRPC/Prometheus requirements and ensure issues are caught at startup rather than at runtime. gRPC binary metadata (ending in
-bin) is not allowed.Finally, gRPC metadata is a
map[string][]stringwhere each value is the ordered set of values set for the key. If multiple values exist, the last value is used as the label.