# HTTP proxy server to use to connect to the targets.
[ proxy_url: <string> ]
- # The preferred IP protocol of the HTTP probe (ip4, ip6).
+ # The IP protocol of the HTTP probe (ip4, ip6).
[ preferred_ip_protocol: <string> | default = "ip6" ]
+ [ ip_protocol_fallback: <boolean | default = true> ]
# The body of the HTTP request used in probe.
body: [ <string> ]
```yml
-# The preferred IP protocol of the TCP probe (ip4, ip6).
+# The IP protocol of the TCP probe (ip4, ip6).
[ preferred_ip_protocol: <string> | default = "ip6" ]
+[ ip_protocol_fallback: <boolean | default = true> ]
# The source IP address.
[ source_ip_address: <string> ]
```yml
-# The preferred IP protocol of the DNS probe (ip4, ip6).
+# The IP protocol of the DNS probe (ip4, ip6).
[ preferred_ip_protocol: <string> | default = "ip6" ]
+[ ip_protocol_fallback: <boolean | default = true> ]
# The source IP address.
[ source_ip_address: <string> ]
```yml
-# The preferred IP protocol of the ICMP probe (ip4, ip6).
+# The IP protocol of the ICMP probe (ip4, ip6).
[ preferred_ip_protocol: <string> | default = "ip6" ]
+[ ip_protocol_fallback: <boolean | default = true> ]
# The source IP address.
[ source_ip_address: <string> ]
// Defaults to 2xx.
ValidStatusCodes []int `yaml:"valid_status_codes,omitempty"`
ValidHTTPVersions []string `yaml:"valid_http_versions,omitempty"`
- PreferredIPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
+ IPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
+ IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
NoFollowRedirects bool `yaml:"no_follow_redirects,omitempty"`
FailIfSSL bool `yaml:"fail_if_ssl,omitempty"`
FailIfNotSSL bool `yaml:"fail_if_not_ssl,omitempty"`
}
type TCPProbe struct {
- PreferredIPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
- SourceIPAddress string `yaml:"source_ip_address,omitempty"`
- QueryResponse []QueryResponse `yaml:"query_response,omitempty"`
- TLS bool `yaml:"tls,omitempty"`
- TLSConfig config.TLSConfig `yaml:"tls_config,omitempty"`
+ IPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
+ IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
+ SourceIPAddress string `yaml:"source_ip_address,omitempty"`
+ QueryResponse []QueryResponse `yaml:"query_response,omitempty"`
+ TLS bool `yaml:"tls,omitempty"`
+ TLSConfig config.TLSConfig `yaml:"tls_config,omitempty"`
}
type ICMPProbe struct {
- PreferredIPProtocol string `yaml:"preferred_ip_protocol,omitempty"` // Defaults to "ip6".
- SourceIPAddress string `yaml:"source_ip_address,omitempty"`
- PayloadSize int `yaml:"payload_size,omitempty"`
- DontFragment bool `yaml:"dont_fragment,omitempty"`
+ IPProtocol string `yaml:"preferred_ip_protocol,omitempty"` // Defaults to "ip6".
+ IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
+ SourceIPAddress string `yaml:"source_ip_address,omitempty"`
+ PayloadSize int `yaml:"payload_size,omitempty"`
+ DontFragment bool `yaml:"dont_fragment,omitempty"`
}
type DNSProbe struct {
- PreferredIPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
- SourceIPAddress string `yaml:"source_ip_address,omitempty"`
- TransportProtocol string `yaml:"transport_protocol,omitempty"`
- QueryName string `yaml:"query_name,omitempty"`
- QueryType string `yaml:"query_type,omitempty"` // Defaults to ANY.
- ValidRcodes []string `yaml:"valid_rcodes,omitempty"` // Defaults to NOERROR.
- ValidateAnswer DNSRRValidator `yaml:"validate_answer_rrs,omitempty"`
- ValidateAuthority DNSRRValidator `yaml:"validate_authority_rrs,omitempty"`
- ValidateAdditional DNSRRValidator `yaml:"validate_additional_rrs,omitempty"`
+ IPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
+ IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
+ SourceIPAddress string `yaml:"source_ip_address,omitempty"`
+ TransportProtocol string `yaml:"transport_protocol,omitempty"`
+ QueryName string `yaml:"query_name,omitempty"`
+ QueryType string `yaml:"query_type,omitempty"` // Defaults to ANY.
+ ValidRcodes []string `yaml:"valid_rcodes,omitempty"` // Defaults to NOERROR.
+ ValidateAnswer DNSRRValidator `yaml:"validate_answer_rrs,omitempty"`
+ ValidateAuthority DNSRRValidator `yaml:"validate_authority_rrs,omitempty"`
+ ValidateAdditional DNSRRValidator `yaml:"validate_additional_rrs,omitempty"`
}
type DNSRRValidator struct {
dns:
query_name: example.com
preferred_ip_protocol: ip4
+ ip_protocol_fallback: false
validate_answer_rrs:
fail_if_matches_regexp: [test]
tls_config:
insecure_skip_verify: false
preferred_ip_protocol: "ip4" # defaults to "ip6"
+ ip_protocol_fallback: false # no fallback to "ip6"
http_post_2xx:
prober: http
timeout: 5s
prober: dns
dns:
transport_protocol: "tcp" # defaults to "udp"
- preferred_ip_protocol: "ip4" # defaults to "ip6"
+ preferred_ip_protocol: "ip4" # defaults to "ip6"
query_name: "www.prometheus.io"
port = "53"
targetAddr = target
}
- ip, _, err = chooseProtocol(module.DNS.PreferredIPProtocol, targetAddr, registry, logger)
+ ip, _, err = chooseProtocol(module.DNS.IPProtocol, module.DNS.IPProtocolFallback, targetAddr, registry, logger)
if err != nil {
level.Error(logger).Log("msg", "Error resolving address", "err", err)
return false
}{
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
}, true,
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
- ValidRcodes: []string{"SERVFAIL", "NXDOMAIN"},
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
+ ValidRcodes: []string{"SERVFAIL", "NXDOMAIN"},
}, false,
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
ValidateAnswer: config.DNSRRValidator{
FailIfMatchesRegexp: []string{".*7200.*"},
FailIfNotMatchesRegexp: []string{".*3600.*"},
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
ValidateAuthority: config.DNSRRValidator{
FailIfMatchesRegexp: []string{".*7200.*"},
},
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
ValidateAdditional: config.DNSRRValidator{
FailIfNotMatchesRegexp: []string{".*3600.*"},
},
}{
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
}, true,
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
- QueryType: "SOA",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
+ QueryType: "SOA",
}, true,
}, {
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
- ValidRcodes: []string{"SERVFAIL", "NXDOMAIN"},
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
+ ValidRcodes: []string{"SERVFAIL", "NXDOMAIN"},
}, false,
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
ValidateAnswer: config.DNSRRValidator{
FailIfMatchesRegexp: []string{".*3600.*"},
FailIfNotMatchesRegexp: []string{".*3600.*"},
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
ValidateAnswer: config.DNSRRValidator{
FailIfMatchesRegexp: []string{".*7200.*"},
FailIfNotMatchesRegexp: []string{".*7200.*"},
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
ValidateAuthority: config.DNSRRValidator{
FailIfNotMatchesRegexp: []string{"ns.*.isp.net"},
},
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
ValidateAdditional: config.DNSRRValidator{
FailIfNotMatchesRegexp: []string{"^ns.*.isp"},
},
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
ValidateAdditional: config.DNSRRValidator{
FailIfMatchesRegexp: []string{"^ns.*.isp"},
},
}{
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
}, false,
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
- ValidRcodes: []string{"SERVFAIL", "NXDOMAIN"},
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
+ ValidRcodes: []string{"SERVFAIL", "NXDOMAIN"},
}, true,
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
- QueryType: "NOT_A_VALID_QUERY_TYPE",
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
+ QueryType: "NOT_A_VALID_QUERY_TYPE",
}, false,
},
{
config.DNSProbe{
- PreferredIPProtocol: "ipv4",
- QueryName: "example.com",
- ValidRcodes: []string{"NOT_A_VALID_RCODE"},
+ IPProtocol: "ipv4",
+ QueryName: "example.com",
+ ValidRcodes: []string{"NOT_A_VALID_RCODE"},
}, false,
},
}
module := config.Module{
Timeout: time.Second,
DNS: config.DNSProbe{
- QueryName: "example.com",
- TransportProtocol: protocol,
- PreferredIPProtocol: "ip4",
+ QueryName: "example.com",
+ TransportProtocol: protocol,
+ IPProtocol: "ip4",
},
}
registry := prometheus.NewRegistry()
module = config.Module{
Timeout: time.Second,
DNS: config.DNSProbe{
- QueryName: "example.com",
- TransportProtocol: protocol,
- PreferredIPProtocol: "ip6",
+ QueryName: "example.com",
+ TransportProtocol: protocol,
+ IPProtocol: "ip6",
},
}
registry = prometheus.NewRegistry()
module = config.Module{
Timeout: time.Second,
DNS: config.DNSProbe{
- QueryName: "example.com",
- TransportProtocol: protocol,
- PreferredIPProtocol: "ip6",
+ QueryName: "example.com",
+ TransportProtocol: protocol,
+ IPProtocol: "ip6",
},
}
registry = prometheus.NewRegistry()
module = config.Module{
Timeout: time.Second,
DNS: config.DNSProbe{
- QueryName: "example.com",
- TransportProtocol: protocol,
- PreferredIPProtocol: "ip4",
+ QueryName: "example.com",
+ TransportProtocol: protocol,
+ IPProtocol: "ip4",
},
}
registry = prometheus.NewRegistry()
targetHost = targetURL.Host
}
- ip, lookupTime, err := chooseProtocol(module.HTTP.PreferredIPProtocol, targetHost, registry, logger)
+ ip, lookupTime, err := chooseProtocol(module.HTTP.IPProtocol, module.HTTP.IPProtocolFallback, targetHost, registry, logger)
if err != nil {
level.Error(logger).Log("msg", "Error resolving address", "err", err)
return false
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{ValidStatusCodes: test.ValidStatusCodes}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, ValidStatusCodes: test.ValidStatusCodes}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if result != test.ShouldSucceed {
t.Fatalf("Test %d had unexpected result: %s", i, body)
registry := prometheus.NewRegistry()
result := ProbeHTTP(context.Background(), ts.URL,
config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{
- ValidHTTPVersions: test.ValidHTTPVersions,
+ IPProtocolFallback: true,
+ ValidHTTPVersions: test.ValidHTTPVersions,
}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if result != test.ShouldSucceed {
registry := prometheus.NewRegistry()
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
- result := ProbeHTTP(testCTX, ts.URL, config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{}}, registry, log.NewNopLogger())
+ result := ProbeHTTP(testCTX, ts.URL, config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if !result {
t.Fatalf("Redirect test failed unexpectedly, got %s", body)
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{NoFollowRedirects: true, ValidStatusCodes: []int{302}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, NoFollowRedirects: true, ValidStatusCodes: []int{302}}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if !result {
t.Fatalf("Redirect test failed unexpectedly, got %s", body)
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{Method: "POST"}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, Method: "POST"}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if !result {
t.Fatalf("Post test failed unexpectedly, got %s", body)
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{
+ IPProtocolFallback: true,
HTTPClientConfig: pconfig.HTTPClientConfig{
TLSConfig: pconfig.TLSConfig{InsecureSkipVerify: false},
BasicAuth: &pconfig.BasicAuth{Username: "username", Password: "password"},
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{
+ IPProtocolFallback: true,
HTTPClientConfig: pconfig.HTTPClientConfig{
BearerToken: pconfig.Secret("mysecret"),
},
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfNotSSL: true}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfNotSSL: true}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if result {
t.Fatalf("Fail if not SSL test suceeded unexpectedly, got %s", body)
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfMatchesRegexp: []string{"could not connect to database"}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfMatchesRegexp: []string{"could not connect to database"}}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if result {
t.Fatalf("Regexp test succeeded unexpectedly, got %s", body)
recorder = httptest.NewRecorder()
registry = prometheus.NewRegistry()
result = ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfMatchesRegexp: []string{"could not connect to database"}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfMatchesRegexp: []string{"could not connect to database"}}}, registry, log.NewNopLogger())
body = recorder.Body.String()
if !result {
t.Fatalf("Regexp test failed unexpectedly, got %s", body)
recorder = httptest.NewRecorder()
registry = prometheus.NewRegistry()
result = ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfMatchesRegexp: []string{"could not connect to database", "internal error"}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfMatchesRegexp: []string{"could not connect to database", "internal error"}}}, registry, log.NewNopLogger())
body = recorder.Body.String()
if result {
t.Fatalf("Regexp test succeeded unexpectedly, got %s", body)
recorder = httptest.NewRecorder()
registry = prometheus.NewRegistry()
result = ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfMatchesRegexp: []string{"could not connect to database", "internal error"}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfMatchesRegexp: []string{"could not connect to database", "internal error"}}}, registry, log.NewNopLogger())
body = recorder.Body.String()
if !result {
t.Fatalf("Regexp test failed unexpectedly, got %s", body)
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfNotMatchesRegexp: []string{"Download the latest version here"}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfNotMatchesRegexp: []string{"Download the latest version here"}}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if result {
t.Fatalf("Regexp test succeeded unexpectedly, got %s", body)
recorder = httptest.NewRecorder()
registry = prometheus.NewRegistry()
result = ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfNotMatchesRegexp: []string{"Download the latest version here"}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfNotMatchesRegexp: []string{"Download the latest version here"}}}, registry, log.NewNopLogger())
body = recorder.Body.String()
if !result {
t.Fatalf("Regexp test failed unexpectedly, got %s", body)
recorder = httptest.NewRecorder()
registry = prometheus.NewRegistry()
result = ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfNotMatchesRegexp: []string{"Download the latest version here", "Copyright 2015"}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfNotMatchesRegexp: []string{"Download the latest version here", "Copyright 2015"}}}, registry, log.NewNopLogger())
body = recorder.Body.String()
if result {
t.Fatalf("Regexp test succeeded unexpectedly, got %s", body)
recorder = httptest.NewRecorder()
registry = prometheus.NewRegistry()
result = ProbeHTTP(testCTX, ts.URL,
- config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{FailIfNotMatchesRegexp: []string{"Download the latest version here", "Copyright 2015"}}}, registry, log.NewNopLogger())
+ config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true, FailIfNotMatchesRegexp: []string{"Download the latest version here", "Copyright 2015"}}}, registry, log.NewNopLogger())
body = recorder.Body.String()
if !result {
t.Fatalf("Regexp test failed unexpectedly, got %s", body)
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result := ProbeHTTP(testCTX, ts.URL, config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{
- Headers: headers,
+ Headers: headers, IPProtocolFallback: true,
}}, registry, log.NewNopLogger())
if !result {
t.Fatalf("Probe failed unexpectedly.")
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{
+ IPProtocolFallback: true,
HTTPClientConfig: pconfig.HTTPClientConfig{
TLSConfig: pconfig.TLSConfig{InsecureSkipVerify: false},
},
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{
+ IPProtocolFallback: true,
HTTPClientConfig: pconfig.HTTPClientConfig{
TLSConfig: pconfig.TLSConfig{InsecureSkipVerify: true},
},
defer cancel()
result := ProbeHTTP(testCTX, ts.URL,
config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{
+ IPProtocolFallback: true,
HTTPClientConfig: pconfig.HTTPClientConfig{
TLSConfig: pconfig.TLSConfig{InsecureSkipVerify: false},
},
module := config.Module{
Timeout: time.Second,
HTTP: config.HTTPProbe{
- PreferredIPProtocol: "ip4",
+ IPProtocol: "ip4",
+ IPProtocolFallback: true,
HTTPClientConfig: pconfig.HTTPClientConfig{
TLSConfig: pconfig.TLSConfig{
CAFile: tmpCaFile.Name(),
defer cancel()
result := ProbeHTTP(testCTX, ts.URL, config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{
+ IPProtocolFallback: true,
HTTPClientConfig: pconfig.HTTPClientConfig{
TLSConfig: pconfig.TLSConfig{InsecureSkipVerify: true},
},
registry := prometheus.NewRegistry()
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
- result := ProbeHTTP(testCTX, ts.URL, config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{}}, registry, log.NewNopLogger())
+ result := ProbeHTTP(testCTX, ts.URL, config.Module{Timeout: time.Second, HTTP: config.HTTPProbe{IPProtocolFallback: true}}, registry, log.NewNopLogger())
body := recorder.Body.String()
if !result {
t.Fatalf("Redirect test failed unexpectedly, got %s", body)
timeoutDeadline, _ := ctx.Deadline()
deadline := time.Now().Add(timeoutDeadline.Sub(time.Now()))
- ip, lookupTime, err := chooseProtocol(module.ICMP.PreferredIPProtocol, target, registry, logger)
+ ip, lookupTime, err := chooseProtocol(module.ICMP.IPProtocol, module.ICMP.IPProtocolFallback, target, registry, logger)
if err != nil {
level.Warn(logger).Log("msg", "Error resolving address", "err", err)
return false
return nil, err
}
- ip, _, err := chooseProtocol(module.TCP.PreferredIPProtocol, targetAddress, registry, logger)
+ ip, _, err := chooseProtocol(module.TCP.IPProtocol, module.TCP.IPProtocolFallback, targetAddress, registry, logger)
if err != nil {
level.Error(logger).Log("msg", "Error resolving address", "err", err)
return nil, err
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
registry := prometheus.NewRegistry()
- if !ProbeTCP(testCTX, ln.Addr().String(), config.Module{}, registry, log.NewNopLogger()) {
+ if !ProbeTCP(testCTX, ln.Addr().String(), config.Module{TCP: config.TCPProbe{IPProtocolFallback: true}}, registry, log.NewNopLogger()) {
t.Fatalf("TCP module failed, expected success.")
}
<-ch
registry := prometheus.NewRegistry()
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
- if ProbeTCP(testCTX, ":0", config.Module{}, registry, log.NewNopLogger()) {
+ if ProbeTCP(testCTX, ":0", config.Module{TCP: config.TCPProbe{IPProtocolFallback: true}}, registry, log.NewNopLogger()) {
t.Fatalf("TCP module suceeded, expected failure.")
}
}
// Expect name-verified TLS connection.
module := config.Module{
TCP: config.TCPProbe{
- PreferredIPProtocol: "ipv4",
- TLS: true,
+ IPProtocol: "ipv4",
+ IPProtocolFallback: true,
+ TLS: true,
TLSConfig: pconfig.TLSConfig{
CAFile: tmpCaFile.Name(),
InsecureSkipVerify: false,
// Define some (bogus) example SMTP dialog with STARTTLS.
module := config.Module{
TCP: config.TCPProbe{
+ IPProtocolFallback: true,
QueryResponse: []config.QueryResponse{
{Expect: "^220.*ESMTP.*$"},
{Send: "EHLO tls.prober"},
module := config.Module{
TCP: config.TCPProbe{
+ IPProtocolFallback: true,
QueryResponse: []config.QueryResponse{
{Send: "NICK prober"},
{Send: "USER prober prober prober :prober"},
time.Sleep(time.Millisecond * 100)
module := config.Module{
TCP: config.TCPProbe{
+ IPProtocolFallback: true,
QueryResponse: []config.QueryResponse{
{
Expect: "SSH-2.0-(OpenSSH_6.9p1) Debian-2",
// Force IPv4
module := config.Module{
TCP: config.TCPProbe{
- PreferredIPProtocol: "ip4",
+ IPProtocol: "ip4",
+ IPProtocolFallback: true,
},
}
// Prefer IPv4
module = config.Module{
TCP: config.TCPProbe{
- PreferredIPProtocol: "ip4",
+ IPProtocol: "ip4",
},
}
// Prefer IPv6
module = config.Module{
TCP: config.TCPProbe{
- PreferredIPProtocol: "ip6",
+ IPProtocol: "ip6",
+ IPProtocolFallback: true,
},
}
defer cancel()
registry := prometheus.NewRegistry()
if ProbeTCP(testCTX, ln.Addr().String(), config.Module{TCP: config.TCPProbe{
+ IPProtocolFallback: true,
QueryResponse: []config.QueryResponse{
{
Expect: "SSH-2.0-(OpenSSH_6.9p1) Debian-2",
"github.com/prometheus/client_golang/prometheus"
)
-// Returns the IP for the preferedIPProtocol and lookup time.
-func chooseProtocol(preferredIPProtocol string, target string, registry *prometheus.Registry, logger log.Logger) (ip *net.IPAddr, lookupTime float64, err error) {
+// Returns the IP for the IPProtocol and lookup time.
+func chooseProtocol(IPProtocol string, fallbackIPProtocol bool, target string, registry *prometheus.Registry, logger log.Logger) (ip *net.IPAddr, lookupTime float64, err error) {
var fallbackProtocol string
probeDNSLookupTimeSeconds := prometheus.NewGauge(prometheus.GaugeOpts{
Name: "probe_dns_lookup_time_seconds",
registry.MustRegister(probeIPProtocolGauge)
registry.MustRegister(probeDNSLookupTimeSeconds)
- if preferredIPProtocol == "ip6" || preferredIPProtocol == "" {
- preferredIPProtocol = "ip6"
+ if IPProtocol == "ip6" || IPProtocol == "" {
+ IPProtocol = "ip6"
fallbackProtocol = "ip4"
} else {
- preferredIPProtocol = "ip4"
+ IPProtocol = "ip4"
fallbackProtocol = "ip6"
}
- if preferredIPProtocol == "ip6" {
+ if IPProtocol == "ip6" {
fallbackProtocol = "ip4"
} else {
fallbackProtocol = "ip6"
}
- level.Info(logger).Log("msg", "Resolving target address", "preferred_ip_protocol", preferredIPProtocol)
+ level.Info(logger).Log("msg", "Resolving target address", "ip_protocol", IPProtocol)
resolveStart := time.Now()
defer func() {
probeDNSLookupTimeSeconds.Add(lookupTime)
}()
- ip, err = net.ResolveIPAddr(preferredIPProtocol, target)
+ ip, err = net.ResolveIPAddr(IPProtocol, target)
if err != nil {
- level.Warn(logger).Log("msg", "Resolution with preferred IP protocol failed, attempting fallback protocol", "fallback_protocol", fallbackProtocol, "err", err)
- ip, err = net.ResolveIPAddr(fallbackProtocol, target)
+ if fallbackIPProtocol == false {
+ level.Error(logger).Log("msg", "Resolution with IP protocol failed (fallback_ip_protocol is false): err", err)
+ } else {
+ level.Warn(logger).Log("msg", "Resolution with IP protocol failed, attempting fallback protocol", "fallback_protocol", fallbackProtocol, "err", err)
+ ip, err = net.ResolveIPAddr(fallbackProtocol, target)
+ }
+
if err != nil {
return ip, 0.0, err
}