diff --git a/api/prometheus/v1/example_test.go b/api/prometheus/v1/example_test.go index 9cd42863e..66f45bf38 100644 --- a/api/prometheus/v1/example_test.go +++ b/api/prometheus/v1/example_test.go @@ -28,9 +28,11 @@ import ( v1 "github.com/prometheus/client_golang/api/prometheus/v1" ) +const DemoPrometheusURL = "https://demo.prometheus.io:443" + func ExampleAPI_query() { client, err := api.NewClient(api.Config{ - Address: "http://demo.robustperception.io:9090", + Address: DemoPrometheusURL, }) if err != nil { fmt.Printf("Error creating client: %v\n", err) @@ -53,7 +55,7 @@ func ExampleAPI_query() { func ExampleAPI_queryRange() { client, err := api.NewClient(api.Config{ - Address: "http://demo.robustperception.io:9090", + Address: DemoPrometheusURL, }) if err != nil { fmt.Printf("Error creating client: %v\n", err) @@ -104,7 +106,7 @@ func (u userAgentRoundTripper) RoundTrip(r *http.Request) (*http.Response, error func ExampleAPI_queryRangeWithUserAgent() { client, err := api.NewClient(api.Config{ - Address: "http://demo.robustperception.io:9090", + Address: DemoPrometheusURL, RoundTripper: userAgentRoundTripper{name: "Client-Golang", rt: api.DefaultRoundTripper}, }) if err != nil { @@ -133,7 +135,7 @@ func ExampleAPI_queryRangeWithUserAgent() { func ExampleAPI_queryRangeWithBasicAuth() { client, err := api.NewClient(api.Config{ - Address: "http://demo.robustperception.io:9090", + Address: DemoPrometheusURL, // We can use amazing github.com/prometheus/common/config helper! RoundTripper: config.NewBasicAuthRoundTripper( config.NewInlineSecret("me"), @@ -167,7 +169,7 @@ func ExampleAPI_queryRangeWithBasicAuth() { func ExampleAPI_queryRangeWithAuthBearerToken() { client, err := api.NewClient(api.Config{ - Address: "http://demo.robustperception.io:9090", + Address: DemoPrometheusURL, // We can use amazing github.com/prometheus/common/config helper! RoundTripper: config.NewAuthorizationCredentialsRoundTripper( "Bearer", @@ -201,7 +203,7 @@ func ExampleAPI_queryRangeWithAuthBearerToken() { func ExampleAPI_queryRangeWithAuthBearerTokenHeadersRoundTripper() { client, err := api.NewClient(api.Config{ - Address: "http://demo.robustperception.io:9090", + Address: DemoPrometheusURL, // We can use amazing github.com/prometheus/common/config helper! RoundTripper: config.NewHeadersRoundTripper( &config.Headers{ @@ -240,7 +242,7 @@ func ExampleAPI_queryRangeWithAuthBearerTokenHeadersRoundTripper() { func ExampleAPI_series() { client, err := api.NewClient(api.Config{ - Address: "http://demo.robustperception.io:9090", + Address: DemoPrometheusURL, }) if err != nil { fmt.Printf("Error creating client: %v\n", err)