From 762fdb8bd5b2aa651e3b67899749bf3ebb5164a8 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 5 Jan 2021 20:37:44 -0500 Subject: [PATCH] Track IP address as well as domain in a label --- src/icmp.rs | 14 +++++++------- src/main.rs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/icmp.rs b/src/icmp.rs index 88d1256..6b3bfe6 100644 --- a/src/icmp.rs +++ b/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)); diff --git a/src/main.rs b/src/main.rs index a5fecc3..ac174ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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()))