Name: "config_last_reload_success_timestamp_seconds",
Help: "Timestamp of the last successful configuration reload.",
})
+
+ // DefaultModule set default configuration for the Module
+ DefaultModule = Module{
+ HTTP: DefaultHTTPProbe,
+ TCP: DefaultTCPProbe,
+ ICMP: DefaultICMPProbe,
+ DNS: DefaultDNSProbe,
+ }
+
+ // DefaultHTTPProbe set default value for HTTPProbe
+ DefaultHTTPProbe = HTTPProbe{
+ IPProtocolFallback: true,
+ }
+
+ // DefaultTCPProbe set default value for TCPProbe
+ DefaultTCPProbe = TCPProbe{
+ IPProtocolFallback: true,
+ }
+
+ // DefaultICMPProbe set default value for ICMPProbe
+ DefaultICMPProbe = ICMPProbe{
+ IPProtocolFallback: true,
+ }
+
+ // DefaultDNSProbe set default value for DNSProbe
+ DefaultDNSProbe = DNSProbe{
+ IPProtocolFallback: true,
+ }
)
func init() {
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (s *Module) UnmarshalYAML(unmarshal func(interface{}) error) error {
+ *s = DefaultModule
type plain Module
if err := unmarshal((*plain)(s)); err != nil {
return err
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (s *HTTPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error {
+ *s = DefaultHTTPProbe
type plain HTTPProbe
if err := unmarshal((*plain)(s)); err != nil {
return err
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (s *DNSProbe) UnmarshalYAML(unmarshal func(interface{}) error) error {
+ *s = DefaultDNSProbe
type plain DNSProbe
if err := unmarshal((*plain)(s)); err != nil {
return err
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (s *TCPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error {
+ *s = DefaultTCPProbe
type plain TCPProbe
if err := unmarshal((*plain)(s)); err != nil {
return err
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (s *ICMPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error {
+ *s = DefaultICMPProbe
type plain ICMPProbe
if err := unmarshal((*plain)(s)); err != nil {
return err
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, IPProtocolFallback: true,
+ IPProtocolFallback: true,
+ Headers: headers,
}}, registry, log.NewNopLogger())
if !result {
t.Fatalf("Probe failed unexpectedly.")
registry := prometheus.NewRegistry()
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
- if ProbeTCP(testCTX, ":0", config.Module{TCP: config.TCPProbe{IPProtocolFallback: true}}, registry, log.NewNopLogger()) {
+ if ProbeTCP(testCTX, ":0", config.Module{TCP: config.TCPProbe{}}, registry, log.NewNopLogger()) {
t.Fatalf("TCP module suceeded, expected failure.")
}
}
// Expect name-verified TLS connection.
module := config.Module{
TCP: config.TCPProbe{
- IPProtocol: "ipv4",
- IPProtocolFallback: true,
- TLS: true,
+ IPProtocol: "ipv4",
+ TLS: true,
TLSConfig: pconfig.TLSConfig{
CAFile: tmpCaFile.Name(),
InsecureSkipVerify: false,
// Force IPv4
module := config.Module{
TCP: config.TCPProbe{
- IPProtocol: "ip4",
- IPProtocolFallback: true,
+ IPProtocol: "ip4",
},
}
// Prefer IPv6
module = config.Module{
TCP: config.TCPProbe{
- IPProtocol: "ip6",
- IPProtocolFallback: true,
+ IPProtocol: "ip6",
},
}
ip, err = net.ResolveIPAddr(IPProtocol, target)
if err != nil {
if !fallbackIPProtocol {
- level.Error(logger).Log("msg", "Resolution with IP protocol failed (fallback_ip_protocol is false): err", err)
+ 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 {
+ if IPProtocol == "ip6" {
+ probeIPProtocolGauge.Set(6)
+ } else {
+ probeIPProtocolGauge.Set(4)
+ }
return ip, 0.0, err
}
}