@@ -67,9 +67,10 @@ type expectedMetricRelabelConfigTestResult struct {
67
67
}
68
68
69
69
type expectedTestResultJobMap struct {
70
- Targets []string
71
- Labels model.LabelSet
72
- MetricRelabelConfig * expectedMetricRelabelConfigTestResult
70
+ Targets []string
71
+ Labels model.LabelSet
72
+ MetricRelabelConfig * expectedMetricRelabelConfigTestResult
73
+ ScrapeFallbackProtocol promconfig.ScrapeProtocol
73
74
}
74
75
75
76
type expectedTestResult struct {
@@ -284,14 +285,15 @@ func TestTargetAllocatorJobRetrieval(t *testing.T) {
284
285
"/scrape_configs" : {
285
286
mockTargetAllocatorResponseRaw {code : 200 , data : map [string ]map [string ]any {
286
287
"job1" : {
287
- "job_name" : "job1" ,
288
- "scrape_interval" : "30s" ,
289
- "scrape_timeout" : "30s" ,
290
- "scrape_protocols" : []string {"OpenMetricsText1.0.0" , "OpenMetricsText0.0.1" , "PrometheusText0.0.4" },
291
- "metrics_path" : "/metrics" ,
292
- "scheme" : "http" ,
293
- "relabel_configs" : nil ,
294
- "metric_relabel_configs" : nil ,
288
+ "job_name" : "job1" ,
289
+ "scrape_interval" : "30s" ,
290
+ "scrape_timeout" : "30s" ,
291
+ "scrape_protocols" : []string {"OpenMetricsText1.0.0" , "OpenMetricsText0.0.1" , "PrometheusText0.0.4" },
292
+ "metrics_path" : "/metrics" ,
293
+ "scheme" : "http" ,
294
+ "relabel_configs" : nil ,
295
+ "metric_relabel_configs" : nil ,
296
+ "fallback_scrape_protocol" : promconfig .PrometheusText1_0_0 ,
295
297
},
296
298
"job2" : {
297
299
"job_name" : "job2" ,
@@ -369,13 +371,15 @@ func TestTargetAllocatorJobRetrieval(t *testing.T) {
369
371
"__meta_datacenter" : "london" ,
370
372
"__meta_prometheus_job" : "node" ,
371
373
},
374
+ ScrapeFallbackProtocol : promconfig .PrometheusText1_0_0 ,
372
375
},
373
376
"job2" : {
374
377
Targets : []string {"10.0.40.2:9100" , "10.0.40.3:9100" },
375
378
Labels : map [model.LabelName ]model.LabelValue {
376
379
"__meta_datacenter" : "london" ,
377
380
"__meta_prometheus_job" : "alertmanager" ,
378
381
},
382
+ ScrapeFallbackProtocol : promconfig .PrometheusText0_0_4 , // Tests default value
379
383
},
380
384
},
381
385
},
@@ -778,6 +782,15 @@ func TestTargetAllocatorJobRetrieval(t *testing.T) {
778
782
}
779
783
}
780
784
}
785
+
786
+ if s .ScrapeFallbackProtocol != "" {
787
+ for _ , sc := range manager .promCfg .ScrapeConfigs {
788
+ if sc .JobName == job {
789
+ require .Equal (t , sc .ScrapeFallbackProtocol , s .ScrapeFallbackProtocol )
790
+ }
791
+ }
792
+ }
793
+
781
794
found = true
782
795
}
783
796
require .True (t , found , "Returned job is not defined in expected values" , group )
0 commit comments