exposes line length hist on distributors (#6309)

* exposes line length hist on distributors + fixes some metric instantiation

* adjusts buckets
pull/6285/merge
Owen Diehl 4 years ago committed by GitHub
parent 1ad75d0b63
commit cd7ebf2ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      pkg/distributor/validator.go
  2. 18
      pkg/validation/validate.go

@ -63,6 +63,7 @@ func (v Validator) getValidationContextForTime(now time.Time, userID string) val
// ValidateEntry returns an error if the entry is invalid
func (v Validator) ValidateEntry(ctx validationContext, labels string, entry logproto.Entry) error {
ts := entry.Timestamp.UnixNano()
validation.LineLengthHist.Observe(float64(len(entry.Line)))
// Makes time string on the error message formatted consistently.
formatedEntryTime := entry.Timestamp.Format(timeFormat)

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/grafana/loki/pkg/util/flagext"
)
@ -66,7 +67,7 @@ func (e *ErrStreamRateLimit) Error() string {
}
// MutatedSamples is a metric of the total number of lines mutated, by reason.
var MutatedSamples = prometheus.NewCounterVec(
var MutatedSamples = promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: "loki",
Name: "mutated_samples_total",
@ -76,7 +77,7 @@ var MutatedSamples = prometheus.NewCounterVec(
)
// MutatedBytes is a metric of the total mutated bytes, by reason.
var MutatedBytes = prometheus.NewCounterVec(
var MutatedBytes = promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: "loki",
Name: "mutated_bytes_total",
@ -86,7 +87,7 @@ var MutatedBytes = prometheus.NewCounterVec(
)
// DiscardedBytes is a metric of the total discarded bytes, by reason.
var DiscardedBytes = prometheus.NewCounterVec(
var DiscardedBytes = promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: "loki",
Name: "discarded_bytes_total",
@ -96,7 +97,7 @@ var DiscardedBytes = prometheus.NewCounterVec(
)
// DiscardedSamples is a metric of the number of discarded samples, by reason.
var DiscardedSamples = prometheus.NewCounterVec(
var DiscardedSamples = promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: "loki",
Name: "discarded_samples_total",
@ -105,6 +106,9 @@ var DiscardedSamples = prometheus.NewCounterVec(
[]string{ReasonLabel, "tenant"},
)
func init() {
prometheus.MustRegister(DiscardedSamples, DiscardedBytes)
}
var LineLengthHist = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: "loki",
Name: "bytes_per_line",
Help: "The total number of bytes per line.",
Buckets: prometheus.ExponentialBuckets(1, 8, 8), // 1B -> 16MB
})

Loading…
Cancel
Save