@@ -46,9 +46,18 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b
4646 Name : "probe_ip_addr_hash" ,
4747 Help : "Specifies the hash of IP address. It's useful to detect if the IP address changes." ,
4848 })
49+
50+ probeIPAddr := prometheus .NewGaugeVec (prometheus.GaugeOpts {
51+ Name : "probe_ip_addr" ,
52+ Help : "IP address. It's useful." ,
53+ },
54+ []string {"ip" },
55+ )
56+
4957 registry .MustRegister (probeIPProtocolGauge )
5058 registry .MustRegister (probeDNSLookupTimeSeconds )
5159 registry .MustRegister (probeIPAddrHash )
60+ registry .MustRegister (probeIPAddr )
5261
5362 if IPProtocol == "ip6" || IPProtocol == "" {
5463 IPProtocol = "ip6"
@@ -74,6 +83,7 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b
7483 logger .Debug ("Resolved target address" , "target" , target , "ip" , ip .String ())
7584 probeIPProtocolGauge .Set (protocolToGauge [IPProtocol ])
7685 probeIPAddrHash .Set (ipHash (ip ))
86+ probeIPAddr .WithLabelValues (ip .String ()).Set (1 )
7787 return & net.IPAddr {IP : ip }, lookupTime , nil
7888 }
7989 }
@@ -96,6 +106,7 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b
96106 logger .Debug ("Resolved target address" , "target" , target , "ip" , ip .String ())
97107 probeIPProtocolGauge .Set (4 )
98108 probeIPAddrHash .Set (ipHash (ip .IP ))
109+ probeIPAddr .WithLabelValues (ip .IP .String ()).Set (1 )
99110 return & ip , lookupTime , nil
100111 }
101112
@@ -107,6 +118,7 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b
107118 logger .Debug ("Resolved target address" , "target" , target , "ip" , ip .String ())
108119 probeIPProtocolGauge .Set (6 )
109120 probeIPAddrHash .Set (ipHash (ip .IP ))
121+ probeIPAddr .WithLabelValues (ip .IP .String ()).Set (1 )
110122 return & ip , lookupTime , nil
111123 }
112124
@@ -127,6 +139,7 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b
127139 probeIPProtocolGauge .Set (6 )
128140 }
129141 probeIPAddrHash .Set (ipHash (fallback .IP ))
142+ probeIPAddr .WithLabelValues (fallback .IP .String ()).Set (1 )
130143 logger .Debug ("Resolved target address" , "target" , target , "ip" , fallback .String ())
131144 return fallback , lookupTime , nil
132145}
0 commit comments