mirror of
https://github.com/zaphar/durnitisp.git
synced 2025-07-22 18:19:48 -04:00
Track IP address as well as domain in a label
This commit is contained in:
parent
41f74fd637
commit
762fdb8bd5
14
src/icmp.rs
14
src/icmp.rs
@ -68,10 +68,10 @@ pub fn start_echo_loop(
|
||||
r.elapsed.as_millis(),
|
||||
);
|
||||
ping_counter
|
||||
.with(&prometheus::labels! {"result" => "ok", "domain" => domain_name})
|
||||
.with(&prometheus::labels! {"result" => "ok", "domain" => domain_name, "ip" => &resolved})
|
||||
.inc();
|
||||
ping_latency_guage
|
||||
.with(&prometheus::labels! {"domain" => domain_name})
|
||||
.with(&prometheus::labels! {"domain" => domain_name, "ip" => &resolved})
|
||||
.set(r.elapsed.as_millis() as i64);
|
||||
}
|
||||
EkkoResponse::UnreachableResponse((_, ref _code)) => {
|
||||
@ -79,7 +79,7 @@ pub fn start_echo_loop(
|
||||
error!("{:?}", r);
|
||||
info!("Restarting our sender");
|
||||
ping_counter
|
||||
.with(&prometheus::labels! {"result" => "unreachable", "domain" => domain_name})
|
||||
.with(&prometheus::labels! {"result" => "unreachable", "domain" => domain_name, "ip" => &resolved})
|
||||
.inc();
|
||||
let mut new_sender = Ekko::with_target(&resolved).unwrap();
|
||||
std::mem::swap(&mut sender, &mut new_sender);
|
||||
@ -87,21 +87,21 @@ pub fn start_echo_loop(
|
||||
}
|
||||
EkkoResponse::ExceededResponse(_) => {
|
||||
ping_counter
|
||||
.with(&prometheus::labels! {"result" => "timeout", "domain" => domain_name})
|
||||
.with(&prometheus::labels! {"result" => "timeout", "domain" => domain_name, "ip" => &resolved})
|
||||
.inc();
|
||||
}
|
||||
_ => {
|
||||
ping_counter
|
||||
.with(&prometheus::labels! {"result" => "err", "domain" => domain_name})
|
||||
.with(&prometheus::labels! {"result" => "err", "domain" => domain_name, "ip" => &resolved})
|
||||
.inc();
|
||||
error!("{:?}", r);
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
ping_counter
|
||||
.with(&prometheus::labels! {"result" => "err", "domain" => domain_name})
|
||||
.with(&prometheus::labels! {"result" => "err", "domain" => domain_name, "ip" => &resolved})
|
||||
.inc();
|
||||
error!("Ping send to {} failed: {:?}, Trying again later", domain_name, e);
|
||||
error!("Ping send to domain: {} address: {} failed: {:?}, Trying again later", domain_name, &resolved, e);
|
||||
}
|
||||
};
|
||||
std::thread::sleep(Duration::from_secs(3));
|
||||
|
@ -118,10 +118,10 @@ fn main() -> anyhow::Result<()> {
|
||||
)
|
||||
.unwrap();
|
||||
let ping_latency_vec =
|
||||
IntGaugeVec::new(Opts::new("ping_latency", "ICMP Ping latency"), &["domain"]).unwrap();
|
||||
IntGaugeVec::new(Opts::new("ping_latency", "ICMP Ping latency"), &["domain", "ip"]).unwrap();
|
||||
let ping_counter_vec = CounterVec::new(
|
||||
Opts::new("ping_counter", "Ping Request Counter"),
|
||||
&["result", "domain"],
|
||||
&["result", "domain", "ip"],
|
||||
)
|
||||
.unwrap();
|
||||
r.register(Box::new(stun_counter_vec.clone()))
|
||||
|
Loading…
x
Reference in New Issue
Block a user