diff --git a/pkg/distributor/validator.go b/pkg/distributor/validator.go index 1b816de4ac2ba..933ff5201937b 100644 --- a/pkg/distributor/validator.go +++ b/pkg/distributor/validator.go @@ -12,6 +12,7 @@ import ( "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util/flagext" + "github.com/grafana/loki/pkg/util/validation" ) type Validator struct { @@ -38,6 +39,7 @@ func (v Validator) ValidateEntry(userID string, entry logproto.Entry) error { // an orthogonal concept (we need not use ValidateLabels in this context) // but the upstream cortex_validation pkg uses it, so we keep this // for parity. + validation.DiscardedSamples.WithLabelValues(validation.LineTooLong, userID).Inc() return httpgrpc.Errorf( http.StatusBadRequest, "max line size (%s) exceeded while adding (%s) size line", diff --git a/pkg/util/validation/validate.go b/pkg/util/validation/validate.go index 8c59fdc828c5a..9293a989c17fb 100644 --- a/pkg/util/validation/validate.go +++ b/pkg/util/validation/validate.go @@ -8,6 +8,8 @@ const ( // RateLimited is one of the values for the reason to discard samples. // Declared here to avoid duplication in ingester and distributor. RateLimited = "rate_limited" + // LineTooLong is a reason for discarding too long log lines. + LineTooLong = "line_too_long" ) // DiscardedBytes is a metric of the total discarded bytes, by reason.