diff --git a/config/config_test.go b/config/config_test.go index 7a84f5c77..822185dba 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -109,6 +109,7 @@ var expectedConf = &Config{ }, }, FollowRedirects: true, + EnableHTTP2: true, }, }, { @@ -123,6 +124,7 @@ var expectedConf = &Config{ KeyFile: filepath.FromSlash("testdata/valid_key_file"), }, FollowRedirects: true, + EnableHTTP2: true, }, Headers: map[string]string{"name": "value"}, }, @@ -130,11 +132,14 @@ var expectedConf = &Config{ RemoteReadConfigs: []*RemoteReadConfig{ { - URL: mustParseURL("http://remote1/read"), - RemoteTimeout: model.Duration(1 * time.Minute), - ReadRecent: true, - Name: "default", - HTTPClientConfig: config.DefaultHTTPClientConfig, + URL: mustParseURL("http://remote1/read"), + RemoteTimeout: model.Duration(1 * time.Minute), + ReadRecent: true, + Name: "default", + HTTPClientConfig: config.HTTPClientConfig{ + FollowRedirects: true, + EnableHTTP2: false, + }, FilterExternalLabels: true, }, { @@ -149,6 +154,7 @@ var expectedConf = &Config{ KeyFile: filepath.FromSlash("testdata/valid_key_file"), }, FollowRedirects: true, + EnableHTTP2: true, }, FilterExternalLabels: true, }, @@ -172,6 +178,7 @@ var expectedConf = &Config{ CredentialsFile: filepath.FromSlash("testdata/valid_token_file"), }, FollowRedirects: true, + EnableHTTP2: true, }, ServiceDiscoveryConfigs: discovery.Configs{ @@ -243,6 +250,7 @@ var expectedConf = &Config{ Password: "multiline\nmysecret\ntest", }, FollowRedirects: true, + EnableHTTP2: true, }, MetricsPath: "/my_path", Scheme: "https", @@ -348,6 +356,7 @@ var expectedConf = &Config{ InsecureSkipVerify: false, }, FollowRedirects: true, + EnableHTTP2: true, }, }, }, @@ -385,6 +394,7 @@ var expectedConf = &Config{ }, FollowRedirects: true, + EnableHTTP2: true, }, }, { @@ -412,6 +422,7 @@ var expectedConf = &Config{ KeyFile: filepath.FromSlash("testdata/valid_key_file"), }, FollowRedirects: true, + EnableHTTP2: true, }, NamespaceDiscovery: kubernetes.NamespaceDiscovery{}, }, @@ -432,6 +443,7 @@ var expectedConf = &Config{ PasswordFile: filepath.FromSlash("testdata/valid_password_file"), }, FollowRedirects: true, + EnableHTTP2: true, }, ServiceDiscoveryConfigs: discovery.Configs{ @@ -491,6 +503,7 @@ var expectedConf = &Config{ KeyFile: filepath.FromSlash("testdata/valid_key_file"), }, FollowRedirects: true, + EnableHTTP2: true, }, }, }, @@ -725,6 +738,7 @@ var expectedConf = &Config{ Credentials: "abcdef", }, FollowRedirects: true, + EnableHTTP2: true, }, Port: 80, RefreshInterval: model.Duration(60 * time.Second), @@ -821,6 +835,7 @@ var expectedConf = &Config{ RefreshInterval: model.Duration(60 * time.Second), HTTPClientConfig: config.HTTPClientConfig{ FollowRedirects: true, + EnableHTTP2: true, TLSConfig: config.TLSConfig{ CAFile: "testdata/valid_ca_file", CertFile: "testdata/valid_cert_file", @@ -848,6 +863,7 @@ var expectedConf = &Config{ Credentials: "abcdef", }, FollowRedirects: true, + EnableHTTP2: true, }, Port: 80, RefreshInterval: model.Duration(60 * time.Second), @@ -857,6 +873,7 @@ var expectedConf = &Config{ HTTPClientConfig: config.HTTPClientConfig{ BasicAuth: &config.BasicAuth{Username: "abcdef", Password: "abcdef"}, FollowRedirects: true, + EnableHTTP2: true, }, Port: 80, RefreshInterval: model.Duration(60 * time.Second), @@ -889,16 +906,15 @@ var expectedConf = &Config{ HonorTimestamps: true, ScrapeInterval: model.Duration(15 * time.Second), ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout, - HTTPClientConfig: config.HTTPClientConfig{FollowRedirects: true}, - - MetricsPath: DefaultScrapeConfig.MetricsPath, - Scheme: DefaultScrapeConfig.Scheme, + HTTPClientConfig: config.DefaultHTTPClientConfig, + MetricsPath: DefaultScrapeConfig.MetricsPath, + Scheme: DefaultScrapeConfig.Scheme, ServiceDiscoveryConfigs: discovery.Configs{ &scaleway.SDConfig{ APIURL: "https://api.scaleway.com", AccessKey: "SCWXXXXXXXXXXXXXXXXX", - HTTPClientConfig: config.HTTPClientConfig{FollowRedirects: true}, + HTTPClientConfig: config.DefaultHTTPClientConfig, Port: 80, Project: "11111111-1111-1111-1111-111111111112", RefreshInterval: model.Duration(60 * time.Second), @@ -909,7 +925,7 @@ var expectedConf = &Config{ &scaleway.SDConfig{ APIURL: "https://api.scaleway.com", AccessKey: "SCWXXXXXXXXXXXXXXXXX", - HTTPClientConfig: config.HTTPClientConfig{FollowRedirects: true}, + HTTPClientConfig: config.DefaultHTTPClientConfig, Port: 80, Project: "11111111-1111-1111-1111-111111111112", RefreshInterval: model.Duration(60 * time.Second), @@ -938,6 +954,7 @@ var expectedConf = &Config{ Credentials: "abcdef", }, FollowRedirects: true, + EnableHTTP2: true, }, Port: 80, TagSeparator: linode.DefaultSDConfig.TagSeparator, @@ -951,7 +968,7 @@ var expectedConf = &Config{ HonorTimestamps: true, ScrapeInterval: model.Duration(15 * time.Second), ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout, - HTTPClientConfig: config.HTTPClientConfig{FollowRedirects: true}, + HTTPClientConfig: config.DefaultHTTPClientConfig, MetricsPath: DefaultScrapeConfig.MetricsPath, Scheme: DefaultScrapeConfig.Scheme, ServiceDiscoveryConfigs: discovery.Configs{ diff --git a/config/testdata/conf.good.yml b/config/testdata/conf.good.yml index 34d9dde8a..33e9639d6 100644 --- a/config/testdata/conf.good.yml +++ b/config/testdata/conf.good.yml @@ -39,6 +39,7 @@ remote_read: - url: http://remote1/read read_recent: true name: default + enable_http2: false - url: http://remote3/read read_recent: false name: read_special diff --git a/discovery/consul/consul_test.go b/discovery/consul/consul_test.go index 49b69af7d..9dc2d660b 100644 --- a/discovery/consul/consul_test.go +++ b/discovery/consul/consul_test.go @@ -417,6 +417,7 @@ func TestUnmarshalConfig(t *testing.T) { Password: "1234", }, FollowRedirects: true, + EnableHTTP2: true, } cases := []struct { diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index 7027b78bb..08349e241 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -198,6 +198,9 @@ oauth2: # Configure whether scrape requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # Configures the scrape request's TLS settings. tls_config: [ ] @@ -396,6 +399,9 @@ endpoint_params: # Configures the token request's TLS settings. tls_config: [ ] + +# Optional proxy URL. +[ proxy_url: ] ``` ### `` @@ -478,6 +484,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # TLS configuration. tls_config: [ ] @@ -574,6 +583,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # TLS configuration. tls_config: [ ] @@ -649,6 +661,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # TLS configuration. tls_config: [ ] @@ -744,6 +759,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + ``` The [relabeling phase](#relabel_config) is the preferred and more powerful @@ -909,6 +927,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + ``` The [relabeling phase](#relabel_config) is the preferred and more powerful @@ -1211,6 +1232,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] + +# Whether to enable HTTP2. +[ enable_http2: | default: true ] ``` See [this example Prometheus configuration file](/documentation/examples/prometheus-puppetdb.yml) @@ -1416,6 +1440,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # TLS configuration. tls_config: [ ] @@ -1498,6 +1525,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # TLS configuration. tls_config: [ ] @@ -1697,6 +1727,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # TLS configuration. tls_config: [ ] @@ -1801,6 +1834,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] + +# Whether to enable HTTP2. +[ enable_http2: | default: true ] ``` The [relabeling phase](#relabel_config) is the preferred and more powerful way @@ -1918,6 +1954,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # TLS configuration. tls_config: [ ] @@ -2001,6 +2040,9 @@ oauth2: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # TLS configuration for connecting to marathon servers tls_config: [ ] @@ -2211,6 +2253,9 @@ tls_config: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # Refresh interval to re-read the app instance list. [ refresh_interval: | default = 30s ] ``` @@ -2315,6 +2360,9 @@ tags_filter: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # Optional proxy URL. [ proxy_url: ] @@ -2383,10 +2431,13 @@ oauth2: [ ] # Optional proxy URL. - [ proxy_url: ] +[ proxy_url: ] # Configure whether HTTP requests follow HTTP 3xx redirects. - [ follow_redirects: | default = true ] +[ follow_redirects: | default = true ] + +# Whether to enable HTTP2. +[ enable_http2: | default: true ] # TLS configuration. tls_config: @@ -2570,6 +2621,9 @@ tls_config: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # List of Azure service discovery configurations. azure_sd_configs: [ - ... ] @@ -2789,6 +2843,9 @@ tls_config: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # Configures the queue used to write to remote storage. queue_config: # Number of samples to buffer per shard before we block reading of more @@ -2890,6 +2947,9 @@ tls_config: # Configure whether HTTP requests follow HTTP 3xx redirects. [ follow_redirects: | default = true ] +# Whether to enable HTTP2. +[ enable_http2: | default: true ] + # Whether to use the external labels as selectors for the remote read endpoint. [ filter_external_labels: | default = true ] ``` diff --git a/go.mod b/go.mod index 89b782c6d..c08df3077 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/prometheus/alertmanager v0.23.0 github.com/prometheus/client_golang v1.12.1 github.com/prometheus/client_model v0.2.0 - github.com/prometheus/common v0.32.1 + github.com/prometheus/common v0.33.0 github.com/prometheus/common/assets v0.1.0 github.com/prometheus/common/sigv4 v0.1.0 github.com/prometheus/exporter-toolkit v0.7.1 @@ -66,8 +66,8 @@ require ( go.opentelemetry.io/otel/trace v1.4.1 go.uber.org/atomic v1.9.0 go.uber.org/goleak v1.1.12 - golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd - golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 + golang.org/x/net v0.0.0-20220225172249-27dd8689420f + golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sys v0.0.0-20220222172238-00053529121e golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 diff --git a/go.sum b/go.sum index 819461aa9..da4f7b1b1 100644 --- a/go.sum +++ b/go.sum @@ -1121,8 +1121,9 @@ github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB8 github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.33.0 h1:rHgav/0a6+uYgGdNt3jwz8FNSesO/Hsang3O0T9A5SE= +github.com/prometheus/common v0.33.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= github.com/prometheus/common/assets v0.1.0 h1:8WlWPDRjbfff4FWCBjaUF0NEIgDD2Mv2anoKfwG+Ums= github.com/prometheus/common/assets v0.1.0/go.mod h1:D17UVUE12bHbim7HzwUvtqm6gwBEaDQ0F+hIGbFbccI= github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= @@ -1512,8 +1513,9 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1529,8 +1531,9 @@ golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b h1:clP8eMhB30EHdc0bd2Twtq6kgU7yl5ub2cQLSdrv1Dg= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=