diff --git a/cmd/loki/loki-local-config.yaml b/cmd/loki/loki-local-config.yaml index 4e6978c49486..17e3511305ee 100644 --- a/cmd/loki/loki-local-config.yaml +++ b/cmd/loki/loki-local-config.yaml @@ -31,6 +31,8 @@ storage_config: limits_config: enforce_metric_name: false + reject_old_samples: true + reject_old_samples_max_age: 168h chunk_store_config: max_look_back_period: 0 diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index a768c98bb0d2..a0063b88b26f 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -5,6 +5,7 @@ import ( "flag" "hash/fnv" "sync/atomic" + "time" cortex_client "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/cortexproject/cortex/pkg/ring" @@ -21,6 +22,8 @@ import ( "github.com/grafana/loki/pkg/util" ) +const metricName = "logs" + var ( ingesterAppends = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: "loki", @@ -130,6 +133,21 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log continue } + entries := make([]logproto.Entry, 0, len(stream.Entries)) + for _, entry := range stream.Entries { + if err := d.overrides.ValidateSample(userID, metricName, cortex_client.Sample{ + TimestampMs: entry.Timestamp.UnixNano() / int64(time.Millisecond), + }); err != nil { + validationErr = err + continue + } + entries = append(entries, entry) + } + + if len(entries) == 0 { + continue + } + stream.Entries = entries keys = append(keys, tokenFor(userID, stream.Labels)) streams = append(streams, streamTracker{ stream: stream, diff --git a/production/helm/loki-stack/Chart.yaml b/production/helm/loki-stack/Chart.yaml index 1209a6ad8b40..b4df444c686c 100644 --- a/production/helm/loki-stack/Chart.yaml +++ b/production/helm/loki-stack/Chart.yaml @@ -1,5 +1,5 @@ name: loki-stack -version: 0.10.0 +version: 0.10.1 appVersion: 0.0.1 kubeVersion: "^1.10.0-0" description: "Loki: like Prometheus, but for logs." diff --git a/production/helm/loki/Chart.yaml b/production/helm/loki/Chart.yaml index d0ef9035a057..22ce5789e6d2 100644 --- a/production/helm/loki/Chart.yaml +++ b/production/helm/loki/Chart.yaml @@ -1,5 +1,5 @@ name: loki -version: 0.9.0 +version: 0.9.1 appVersion: 0.0.1 kubeVersion: "^1.10.0-0" description: "Loki: like Prometheus, but for logs." diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index c1825e85b987..e871de7ab1cb 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -40,6 +40,8 @@ config: # consistentreads: true limits_config: enforce_metric_name: false + reject_old_samples: true + reject_old_samples_max_age: 168h schema_config: configs: - from: 2018-04-15 diff --git a/production/ksonnet/loki/config.libsonnet b/production/ksonnet/loki/config.libsonnet index b1dd463c9845..7eaedd333b72 100644 --- a/production/ksonnet/loki/config.libsonnet +++ b/production/ksonnet/loki/config.libsonnet @@ -33,6 +33,8 @@ limits_config: { enforce_metric_name: false, + reject_old_samples: true, + reject_old_samples_max_age: '168h', }, ingester: {