Track IP address as well as domain in a label

This commit is contained in:
Jeremy Wall 2021-01-05 20:37:44 -05:00
parent 41f74fd637
commit 762fdb8bd5
2 changed files with 9 additions and 9 deletions

View File

@ -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));

View File

@ -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()))