@@ -287,7 +287,7 @@ func New(cfg Config, clientConfig ingester_client.Config, limits *validation.Ove
287
287
incomingMetadata : promauto .With (reg ).NewCounterVec (prometheus.CounterOpts {
288
288
Namespace : "cortex" ,
289
289
Name : "distributor_metadata_in_total" ,
290
- Help : "The total number of metadata the have come in to the distributor, including rejected." ,
290
+ Help : "The total number of metadata that have come in to the distributor, including rejected." ,
291
291
}, []string {"user" }),
292
292
nonHASamples : promauto .With (reg ).NewCounterVec (prometheus.CounterOpts {
293
293
Namespace : "cortex" ,
@@ -538,7 +538,7 @@ func (d *Distributor) validateSeries(ts cortexpb.PreallocTimeseries, userID stri
538
538
for _ , e := range ts .Exemplars {
539
539
if err := validation .ValidateExemplar (userID , ts .Labels , e ); err != nil {
540
540
// An exemplar validation error prevents ingesting samples
541
- // in the same series object. However because the current Prometheus
541
+ // in the same series object. However, because the current Prometheus
542
542
// remote write implementation only populates one or the other,
543
543
// there never will be any.
544
544
return emptyPreallocSeries , err
@@ -547,11 +547,23 @@ func (d *Distributor) validateSeries(ts cortexpb.PreallocTimeseries, userID stri
547
547
}
548
548
}
549
549
550
+ var histograms []cortexpb.Histogram
551
+ if len (ts .Histograms ) > 0 {
552
+ // Only alloc when data present
553
+ histograms = make ([]cortexpb.Histogram , 0 , len (ts .Histograms ))
554
+ // TODO(yeya24): we need to have validations for native histograms
555
+ // at some point. Skip validations for now.
556
+ for _ , h := range ts .Histograms {
557
+ histograms = append (histograms , h )
558
+ }
559
+ }
560
+
550
561
return cortexpb.PreallocTimeseries {
551
562
TimeSeries : & cortexpb.TimeSeries {
552
- Labels : ts .Labels ,
553
- Samples : samples ,
554
- Exemplars : exemplars ,
563
+ Labels : ts .Labels ,
564
+ Samples : samples ,
565
+ Exemplars : exemplars ,
566
+ Histograms : histograms ,
555
567
},
556
568
},
557
569
nil
@@ -589,10 +601,11 @@ func (d *Distributor) Push(ctx context.Context, req *cortexpb.WriteRequest) (*co
589
601
numSamples := 0
590
602
numExemplars := 0
591
603
for _ , ts := range req .Timeseries {
592
- numSamples += len (ts .Samples )
604
+ // Should we differentiate normal sample and histogram sample?
605
+ numSamples += len (ts .Samples ) + len (ts .Histograms )
593
606
numExemplars += len (ts .Exemplars )
594
607
}
595
- // Count the total samples in, prior to validation or deduplication, for comparison with other metrics.
608
+ // Count the total samples, exemplars in, prior to validation or deduplication, for comparison with other metrics.
596
609
d .incomingSamples .WithLabelValues (userID ).Add (float64 (numSamples ))
597
610
d .incomingExemplars .WithLabelValues (userID ).Add (float64 (numExemplars ))
598
611
// Count the total number of metadata in.
@@ -772,6 +785,7 @@ func (d *Distributor) prepareSeriesKeys(ctx context.Context, req *cortexpb.Write
772
785
if len (ts .Samples ) > 0 {
773
786
latestSampleTimestampMs = util_math .Max64 (latestSampleTimestampMs , ts .Samples [len (ts .Samples )- 1 ].TimestampMs )
774
787
}
788
+ // TODO: use timestamp of the latest native histogram in the series as well.
775
789
776
790
if mrc := limits .MetricRelabelConfigs ; len (mrc ) > 0 {
777
791
l , _ := relabel .Process (cortexpb .FromLabelAdaptersToLabels (ts .Labels ), mrc ... )
@@ -836,6 +850,7 @@ func (d *Distributor) prepareSeriesKeys(ctx context.Context, req *cortexpb.Write
836
850
837
851
seriesKeys = append (seriesKeys , key )
838
852
validatedTimeseries = append (validatedTimeseries , validatedSeries )
853
+ // TODO(yeya24): add histogram samples as well when supported.
839
854
validatedSamples += len (ts .Samples )
840
855
validatedExemplars += len (ts .Exemplars )
841
856
}
0 commit comments