@ -69,6 +69,10 @@ func mustParseURL(u string) *config.URL {
return & config . URL { URL : parsed }
return & config . URL { URL : parsed }
}
}
func boolPtr ( b bool ) * bool {
return & b
}
const (
const (
globBodySizeLimit = 15 * units . MiB
globBodySizeLimit = 15 * units . MiB
globSampleLimit = 1500
globSampleLimit = 1500
@ -98,6 +102,7 @@ var expectedConf = &Config{
LabelNameLengthLimit : globLabelNameLengthLimit ,
LabelNameLengthLimit : globLabelNameLengthLimit ,
LabelValueLengthLimit : globLabelValueLengthLimit ,
LabelValueLengthLimit : globLabelValueLengthLimit ,
ScrapeProtocols : DefaultGlobalConfig . ScrapeProtocols ,
ScrapeProtocols : DefaultGlobalConfig . ScrapeProtocols ,
ConvertClassicHistogramsToNHCB : false ,
} ,
} ,
Runtime : RuntimeConfig {
Runtime : RuntimeConfig {
@ -218,6 +223,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : "testdata/fail_prom.log" ,
ScrapeFailureLogFile : "testdata/fail_prom.log" ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -333,6 +339,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
HTTPClientConfig : config . HTTPClientConfig {
HTTPClientConfig : config . HTTPClientConfig {
BasicAuth : & config . BasicAuth {
BasicAuth : & config . BasicAuth {
@ -433,6 +440,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -491,6 +499,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : "/metrics" ,
MetricsPath : "/metrics" ,
Scheme : "http" ,
Scheme : "http" ,
@ -527,6 +536,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -569,6 +579,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -611,6 +622,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -643,6 +655,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -683,6 +696,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -720,6 +734,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -764,6 +779,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -798,6 +814,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -835,6 +852,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -865,6 +883,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -898,6 +917,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : "/federate" ,
MetricsPath : "/federate" ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -931,6 +951,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -964,6 +985,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -994,6 +1016,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1032,6 +1055,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1069,6 +1093,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1103,6 +1128,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1136,6 +1162,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1173,6 +1200,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1213,6 +1241,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1272,6 +1301,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1302,6 +1332,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
HTTPClientConfig : config . DefaultHTTPClientConfig ,
HTTPClientConfig : config . DefaultHTTPClientConfig ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
@ -1343,6 +1374,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
HTTPClientConfig : config . DefaultHTTPClientConfig ,
HTTPClientConfig : config . DefaultHTTPClientConfig ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
@ -1390,6 +1422,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1428,6 +1461,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
HTTPClientConfig : config . DefaultHTTPClientConfig ,
HTTPClientConfig : config . DefaultHTTPClientConfig ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
@ -1446,6 +1480,7 @@ var expectedConf = &Config{
} ,
} ,
{
{
JobName : "ionos" ,
JobName : "ionos" ,
HonorTimestamps : true ,
HonorTimestamps : true ,
ScrapeInterval : model . Duration ( 15 * time . Second ) ,
ScrapeInterval : model . Duration ( 15 * time . Second ) ,
ScrapeTimeout : DefaultGlobalConfig . ScrapeTimeout ,
ScrapeTimeout : DefaultGlobalConfig . ScrapeTimeout ,
@ -1460,6 +1495,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -1495,6 +1531,7 @@ var expectedConf = &Config{
ScrapeFailureLogFile : globScrapeFailureLogFile ,
ScrapeFailureLogFile : globScrapeFailureLogFile ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -2317,7 +2354,7 @@ func TestEmptyGlobalBlock(t *testing.T) {
}
}
func TestGetScrapeConfigs ( t * testing . T ) {
func TestGetScrapeConfigs ( t * testing . T ) {
sc := func ( jobName string , scrapeInterval , scrapeTimeout model . Duration ) * ScrapeConfig {
sc := func ( jobName string , scrapeInterval , scrapeTimeout model . Duration , convertClassicHistToNHCB bool ) * ScrapeConfig {
return & ScrapeConfig {
return & ScrapeConfig {
JobName : jobName ,
JobName : jobName ,
HonorTimestamps : true ,
HonorTimestamps : true ,
@ -2343,6 +2380,7 @@ func TestGetScrapeConfigs(t *testing.T) {
} ,
} ,
} ,
} ,
} ,
} ,
ConvertClassicHistogramsToNHCB : boolPtr ( convertClassicHistToNHCB ) ,
}
}
}
}
@ -2355,20 +2393,20 @@ func TestGetScrapeConfigs(t *testing.T) {
{
{
name : "An included config file should be a valid global config." ,
name : "An included config file should be a valid global config." ,
configFile : "testdata/scrape_config_files.good.yml" ,
configFile : "testdata/scrape_config_files.good.yml" ,
expectedResult : [ ] * ScrapeConfig { sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) ) } ,
expectedResult : [ ] * ScrapeConfig { sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) , false ) } ,
} ,
} ,
{
{
name : "A global config that only include a scrape config file." ,
name : "A global config that only include a scrape config file." ,
configFile : "testdata/scrape_config_files_only.good.yml" ,
configFile : "testdata/scrape_config_files_only.good.yml" ,
expectedResult : [ ] * ScrapeConfig { sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) ) } ,
expectedResult : [ ] * ScrapeConfig { sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) , false ) } ,
} ,
} ,
{
{
name : "A global config that combine scrape config files and scrape configs." ,
name : "A global config that combine scrape config files and scrape configs." ,
configFile : "testdata/scrape_config_files_combined.good.yml" ,
configFile : "testdata/scrape_config_files_combined.good.yml" ,
expectedResult : [ ] * ScrapeConfig {
expectedResult : [ ] * ScrapeConfig {
sc ( "node" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) ) ,
sc ( "node" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) , false ) ,
sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) ) ,
sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) , false ) ,
sc ( "alertmanager" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) ) ,
sc ( "alertmanager" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) , false ) ,
} ,
} ,
} ,
} ,
{
{
@ -2384,6 +2422,7 @@ func TestGetScrapeConfigs(t *testing.T) {
ScrapeProtocols : DefaultGlobalConfig . ScrapeProtocols ,
ScrapeProtocols : DefaultGlobalConfig . ScrapeProtocols ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
MetricsPath : DefaultScrapeConfig . MetricsPath ,
Scheme : DefaultScrapeConfig . Scheme ,
Scheme : DefaultScrapeConfig . Scheme ,
@ -2419,6 +2458,7 @@ func TestGetScrapeConfigs(t *testing.T) {
ScrapeProtocols : DefaultGlobalConfig . ScrapeProtocols ,
ScrapeProtocols : DefaultGlobalConfig . ScrapeProtocols ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameValidationScheme : UTF8ValidationConfig ,
MetricNameEscapingScheme : model . AllowUTF8 ,
MetricNameEscapingScheme : model . AllowUTF8 ,
ConvertClassicHistogramsToNHCB : boolPtr ( false ) ,
HTTPClientConfig : config . HTTPClientConfig {
HTTPClientConfig : config . HTTPClientConfig {
TLSConfig : config . TLSConfig {
TLSConfig : config . TLSConfig {
@ -2466,6 +2506,21 @@ func TestGetScrapeConfigs(t *testing.T) {
configFile : "testdata/scrape_config_files_global.bad.yml" ,
configFile : "testdata/scrape_config_files_global.bad.yml" ,
expectedError : ` scrape timeout greater than scrape interval for scrape config with job name "prometheus" ` ,
expectedError : ` scrape timeout greater than scrape interval for scrape config with job name "prometheus" ` ,
} ,
} ,
{
name : "A global config that enables convert classic histograms to nhcb." ,
configFile : "testdata/global_convert_classic_hist_to_nhcb.good.yml" ,
expectedResult : [ ] * ScrapeConfig { sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) , true ) } ,
} ,
{
name : "A global config that enables convert classic histograms to nhcb and scrape config that disables the conversion" ,
configFile : "testdata/local_disable_convert_classic_hist_to_nhcb.good.yml" ,
expectedResult : [ ] * ScrapeConfig { sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) , false ) } ,
} ,
{
name : "A global config that disables convert classic histograms to nhcb and scrape config that enables the conversion" ,
configFile : "testdata/local_convert_classic_hist_to_nhcb.good.yml" ,
expectedResult : [ ] * ScrapeConfig { sc ( "prometheus" , model . Duration ( 60 * time . Second ) , model . Duration ( 10 * time . Second ) , true ) } ,
} ,
}
}
for _ , tc := range testCases {
for _ , tc := range testCases {