@@ -232,12 +232,12 @@ func TestDistributor_Push(t *testing.T) {
232
232
expectedMetrics : `
233
233
# HELP cortex_distributor_ingester_append_failures_total The total number of failed batch appends sent to ingesters.
234
234
# TYPE cortex_distributor_ingester_append_failures_total counter
235
- cortex_distributor_ingester_append_failures_total{ingester="2",status="5xx",type="samples"} 1
235
+ cortex_distributor_ingester_append_failures_total{ingester="ingester- 2",status="5xx",type="samples"} 1
236
236
# HELP cortex_distributor_ingester_appends_total The total number of batch appends sent to ingesters.
237
237
# TYPE cortex_distributor_ingester_appends_total counter
238
- cortex_distributor_ingester_appends_total{ingester="0",type="samples"} 1
239
- cortex_distributor_ingester_appends_total{ingester="1",type="samples"} 1
240
- cortex_distributor_ingester_appends_total{ingester="2",type="samples"} 1
238
+ cortex_distributor_ingester_appends_total{ingester="ingester- 0",type="samples"} 1
239
+ cortex_distributor_ingester_appends_total{ingester="ingester- 1",type="samples"} 1
240
+ cortex_distributor_ingester_appends_total{ingester="ingester- 2",type="samples"} 1
241
241
` ,
242
242
},
243
243
"A push to ingesters should report the correct metrics with no samples" : {
@@ -251,12 +251,12 @@ func TestDistributor_Push(t *testing.T) {
251
251
expectedMetrics : `
252
252
# HELP cortex_distributor_ingester_append_failures_total The total number of failed batch appends sent to ingesters.
253
253
# TYPE cortex_distributor_ingester_append_failures_total counter
254
- cortex_distributor_ingester_append_failures_total{ingester="2",status="5xx",type="metadata"} 1
254
+ cortex_distributor_ingester_append_failures_total{ingester="ingester- 2",status="5xx",type="metadata"} 1
255
255
# HELP cortex_distributor_ingester_appends_total The total number of batch appends sent to ingesters.
256
256
# TYPE cortex_distributor_ingester_appends_total counter
257
- cortex_distributor_ingester_appends_total{ingester="0",type="metadata"} 1
258
- cortex_distributor_ingester_appends_total{ingester="1",type="metadata"} 1
259
- cortex_distributor_ingester_appends_total{ingester="2",type="metadata"} 1
257
+ cortex_distributor_ingester_appends_total{ingester="ingester- 0",type="metadata"} 1
258
+ cortex_distributor_ingester_appends_total{ingester="ingester- 1",type="metadata"} 1
259
+ cortex_distributor_ingester_appends_total{ingester="ingester- 2",type="metadata"} 1
260
260
` ,
261
261
},
262
262
"A push to overloaded ingesters should report the correct metrics" : {
@@ -268,14 +268,14 @@ func TestDistributor_Push(t *testing.T) {
268
268
expectedResponse : emptyResponse ,
269
269
ingesterError : httpgrpc .Errorf (http .StatusTooManyRequests , "Fail" ),
270
270
expectedMetrics : `
271
- # HELP cortex_distributor_ingester_append_failures_total The total number of failed batch appends sent to ingesters.
272
- # TYPE cortex_distributor_ingester_append_failures_total counter
273
- cortex_distributor_ingester_append_failures_total{ingester="2",status="4xx",type="metadata"} 1
274
271
# HELP cortex_distributor_ingester_appends_total The total number of batch appends sent to ingesters.
275
272
# TYPE cortex_distributor_ingester_appends_total counter
276
- cortex_distributor_ingester_appends_total{ingester="0",type="metadata"} 1
277
- cortex_distributor_ingester_appends_total{ingester="1",type="metadata"} 1
278
- cortex_distributor_ingester_appends_total{ingester="2",type="metadata"} 1
273
+ cortex_distributor_ingester_appends_total{ingester="ingester-0",type="metadata"} 1
274
+ cortex_distributor_ingester_appends_total{ingester="ingester-1",type="metadata"} 1
275
+ cortex_distributor_ingester_appends_total{ingester="ingester-2",type="metadata"} 1
276
+ # HELP cortex_distributor_ingester_append_failures_total The total number of failed batch appends sent to ingesters.
277
+ # TYPE cortex_distributor_ingester_append_failures_total counter
278
+ cortex_distributor_ingester_append_failures_total{ingester="ingester-2",status="4xx",type="metadata"} 1
279
279
` ,
280
280
},
281
281
"A push to 3 happy ingesters should succeed, histograms" : {
@@ -436,14 +436,16 @@ func TestDistributor_MetricsCleanup(t *testing.T) {
436
436
d .latestSeenSampleTimestampPerUser .WithLabelValues ("userA" ).Set (1111 )
437
437
438
438
h , _ , _ := r .GetAllInstanceDescs (ring .WriteNoExtend )
439
- d .ingesterAppends .WithLabelValues (h [0 ].Addr , typeMetadata ).Inc ()
440
- d .ingesterAppendFailures .WithLabelValues (h [0 ].Addr , typeMetadata , "2xx" ).Inc ()
441
- d .ingesterAppends .WithLabelValues (h [1 ].Addr , typeMetadata ).Inc ()
442
- d .ingesterAppendFailures .WithLabelValues (h [1 ].Addr , typeMetadata , "2xx" ).Inc ()
443
- d .ingesterQueries .WithLabelValues (h [0 ].Addr ).Inc ()
444
- d .ingesterQueries .WithLabelValues (h [1 ].Addr ).Inc ()
445
- d .ingesterQueryFailures .WithLabelValues (h [0 ].Addr ).Inc ()
446
- d .ingesterQueryFailures .WithLabelValues (h [1 ].Addr ).Inc ()
439
+ ingId0 , _ := r .GetInstanceIdByAddr (h [0 ].Addr )
440
+ ingId1 , _ := r .GetInstanceIdByAddr (h [1 ].Addr )
441
+ d .ingesterAppends .WithLabelValues (ingId0 , typeMetadata ).Inc ()
442
+ d .ingesterAppendFailures .WithLabelValues (ingId0 , typeMetadata , "2xx" ).Inc ()
443
+ d .ingesterAppends .WithLabelValues (ingId1 , typeMetadata ).Inc ()
444
+ d .ingesterAppendFailures .WithLabelValues (ingId1 , typeMetadata , "2xx" ).Inc ()
445
+ d .ingesterQueries .WithLabelValues (ingId0 ).Inc ()
446
+ d .ingesterQueries .WithLabelValues (ingId1 ).Inc ()
447
+ d .ingesterQueryFailures .WithLabelValues (ingId0 ).Inc ()
448
+ d .ingesterQueryFailures .WithLabelValues (ingId1 ).Inc ()
447
449
448
450
require .NoError (t , testutil .GatherAndCompare (reg , strings .NewReader (`
449
451
# HELP cortex_distributor_deduped_samples_total The total number of deduplicated samples.
@@ -489,27 +491,27 @@ func TestDistributor_MetricsCleanup(t *testing.T) {
489
491
490
492
# HELP cortex_distributor_ingester_append_failures_total The total number of failed batch appends sent to ingesters.
491
493
# TYPE cortex_distributor_ingester_append_failures_total counter
492
- cortex_distributor_ingester_append_failures_total{ingester="0",status="2xx",type="metadata"} 1
493
- cortex_distributor_ingester_append_failures_total{ingester="1",status="2xx",type="metadata"} 1
494
+ cortex_distributor_ingester_append_failures_total{ingester="ingester- 0",status="2xx",type="metadata"} 1
495
+ cortex_distributor_ingester_append_failures_total{ingester="ingester- 1",status="2xx",type="metadata"} 1
494
496
# HELP cortex_distributor_ingester_appends_total The total number of batch appends sent to ingesters.
495
497
# TYPE cortex_distributor_ingester_appends_total counter
496
- cortex_distributor_ingester_appends_total{ingester="0",type="metadata"} 1
497
- cortex_distributor_ingester_appends_total{ingester="1",type="metadata"} 1
498
+ cortex_distributor_ingester_appends_total{ingester="ingester- 0",type="metadata"} 1
499
+ cortex_distributor_ingester_appends_total{ingester="ingester- 1",type="metadata"} 1
498
500
# HELP cortex_distributor_ingester_queries_total The total number of queries sent to ingesters.
499
501
# TYPE cortex_distributor_ingester_queries_total counter
500
- cortex_distributor_ingester_queries_total{ingester="0"} 1
501
- cortex_distributor_ingester_queries_total{ingester="1"} 1
502
+ cortex_distributor_ingester_queries_total{ingester="ingester- 0"} 1
503
+ cortex_distributor_ingester_queries_total{ingester="ingester- 1"} 1
502
504
# HELP cortex_distributor_ingester_query_failures_total The total number of failed queries sent to ingesters.
503
505
# TYPE cortex_distributor_ingester_query_failures_total counter
504
- cortex_distributor_ingester_query_failures_total{ingester="0"} 1
505
- cortex_distributor_ingester_query_failures_total{ingester="1"} 1
506
+ cortex_distributor_ingester_query_failures_total{ingester="ingester- 0"} 1
507
+ cortex_distributor_ingester_query_failures_total{ingester="ingester- 1"} 1
506
508
` ), metrics ... ))
507
509
508
510
d .cleanupInactiveUser ("userA" )
509
511
510
512
err := r .KVClient .CAS (context .Background (), ingester .RingKey , func (in interface {}) (interface {}, bool , error ) {
511
513
r := in .(* ring.Desc )
512
- delete (r .Ingesters , "0" )
514
+ delete (r .Ingesters , "ingester- 0" )
513
515
return in , true , nil
514
516
})
515
517
@@ -556,16 +558,16 @@ func TestDistributor_MetricsCleanup(t *testing.T) {
556
558
557
559
# HELP cortex_distributor_ingester_append_failures_total The total number of failed batch appends sent to ingesters.
558
560
# TYPE cortex_distributor_ingester_append_failures_total counter
559
- cortex_distributor_ingester_append_failures_total{ingester="1",status="2xx",type="metadata"} 1
561
+ cortex_distributor_ingester_append_failures_total{ingester="ingester- 1",status="2xx",type="metadata"} 1
560
562
# HELP cortex_distributor_ingester_appends_total The total number of batch appends sent to ingesters.
561
563
# TYPE cortex_distributor_ingester_appends_total counter
562
- cortex_distributor_ingester_appends_total{ingester="1",type="metadata"} 1
564
+ cortex_distributor_ingester_appends_total{ingester="ingester- 1",type="metadata"} 1
563
565
# HELP cortex_distributor_ingester_queries_total The total number of queries sent to ingesters.
564
566
# TYPE cortex_distributor_ingester_queries_total counter
565
- cortex_distributor_ingester_queries_total{ingester="1"} 1
567
+ cortex_distributor_ingester_queries_total{ingester="ingester- 1"} 1
566
568
# HELP cortex_distributor_ingester_query_failures_total The total number of failed queries sent to ingesters.
567
569
# TYPE cortex_distributor_ingester_query_failures_total counter
568
- cortex_distributor_ingester_query_failures_total{ingester="1"} 1
570
+ cortex_distributor_ingester_query_failures_total{ingester="ingester- 1"} 1
569
571
` ), metrics ... ))
570
572
}
571
573
@@ -2717,8 +2719,9 @@ func prepare(tb testing.TB, cfg prepConfig) ([]*Distributor, []*mockIngester, []
2717
2719
} else {
2718
2720
tokens = []uint32 {uint32 ((math .MaxUint32 / cfg .numIngesters ) * i )}
2719
2721
}
2720
- addr := fmt .Sprintf ("%d" , i )
2721
- ingesterDescs [addr ] = ring.InstanceDesc {
2722
+ ingester := fmt .Sprintf ("ingester-%d" , i )
2723
+ addr := fmt .Sprintf ("ip-ingester-%d" , i )
2724
+ ingesterDescs [ingester ] = ring.InstanceDesc {
2722
2725
Addr : addr ,
2723
2726
Zone : "" ,
2724
2727
State : ring .ACTIVE ,
0 commit comments