-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat: Introduce policy
to received_bytes
#16056
base: main
Are you sure you want to change the base?
Conversation
5324437
to
9f8915b
Compare
9f8915b
to
fa2f99e
Compare
edf28f0
to
9006a87
Compare
…na/loki into introduce-policy-to-received-bytes
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.
LGTM! Left some comments. Before merging I think we should"
- Make sure no one besides Loki is using the push.Stats object
- Test in dev (even ops) to make sure this works as expected.
@@ -111,7 +116,7 @@ func (t *PushTarget) run() error { | |||
func (t *PushTarget) handleLoki(w http.ResponseWriter, r *http.Request) { | |||
logger := util_log.WithContext(r.Context(), util_log.Logger) | |||
userID, _ := tenant.TenantID(r.Context()) | |||
req, err := push.ParseRequest(logger, userID, r, nil, push.EmptyLimits{}, push.ParseLokiRequest, nil, nil, false) | |||
req, err := push.ParseRequest(logger, userID, r, nil, push.EmptyLimits{}, push.ParseLokiRequest, nil, t.PolicyResolver, false) |
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.
What about passing nil here? Then the parsers can do:
var policy string
if policyResolver != nil {
policy = policyResolver...
}
pkg/validation/limits.go
Outdated
@@ -1124,6 +1124,10 @@ func (o *Overrides) EnforcedLabels(userID string) []string { | |||
return o.getOverridesForUser(userID).EnforcedLabels | |||
} | |||
|
|||
func (o *Overrides) PolicyFor(userID string, lbs labels.Labels) string { |
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.
I think this one is unused?
@@ -439,6 +491,10 @@ func (f *fakeLimits) OTLPConfig(_ string) OTLPConfig { | |||
return DefaultOTLPConfig(defaultGlobalOTLPConfig) | |||
} | |||
|
|||
func (f *fakeLimits) PolicyFor(_ string, lbs labels.Labels) string { |
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.
If unused, we can remove this one as well
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.
we need a PolicyFor
implementation and i'm using the environment
label to tell which policy to use
expectedStructuredMetadataBytes int | ||
expectedBytes int | ||
expectedLines int | ||
expectedStructuredMetadataBytes map[string]int |
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.
I think we should add a test here with multiple named and unnamed policies
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.
Also passing nil as the policyResolver, in which case only one item per map should be expected ("")
pkg/loghttp/push/push.go
Outdated
} | ||
|
||
totalNumLines := int64(0) |
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.
nit: this is more idiomatic
var totalNumLines int64
pkg/loghttp/push/otlp.go
Outdated
@@ -37,20 +37,21 @@ const ( | |||
|
|||
func newPushStats() *Stats { |
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.
nit: I know this one was already here, but I think it makes more sense to move this new function to push.go right below the definition of Stats
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.
lol good find, totally overlooked that stats were defined in the other file. fixed.
Co-authored-by: Salva Corts <[email protected]> Signed-off-by: Dylan Guedes <[email protected]>
What this PR does / why we need it:
Introduce the
policy
label to the received_bytes metric family to be able to distinguish between different policies ingestion.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
deprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR