diff --git a/metrics-exporter/src/bin/io_engine/client/grpc_client.rs b/metrics-exporter/src/bin/io_engine/client/grpc_client.rs index 0ac661b9e..a030c99b4 100644 --- a/metrics-exporter/src/bin/io_engine/client/grpc_client.rs +++ b/metrics-exporter/src/bin/io_engine/client/grpc_client.rs @@ -7,7 +7,7 @@ use crate::client::{ replica_stat::{ReplicaIoStat, ReplicaIoStats}, }; use actix_web::http::Uri; -use std::time::Duration; +use std::{net::SocketAddr, time::Duration}; use tokio::time::sleep; use tonic::transport::Channel; use tracing::error; @@ -112,7 +112,7 @@ pub(crate) async fn init_client() -> Result { let _ = get_node_name()?; let endpoint = Uri::builder() .scheme("https") - .authority(format!("{pod_ip}:10124")) + .authority(SocketAddr::new(pod_ip, 10124).to_string()) .path_and_query("") .build() .map_err(|error| ExporterError::InvalidURI(error.to_string()))?; diff --git a/metrics-exporter/src/bin/io_engine/main.rs b/metrics-exporter/src/bin/io_engine/main.rs index 13bf2e4f8..c618b8ccf 100644 --- a/metrics-exporter/src/bin/io_engine/main.rs +++ b/metrics-exporter/src/bin/io_engine/main.rs @@ -6,7 +6,10 @@ use crate::{ use actix_web::{middleware, HttpServer}; use clap::Parser; use once_cell::sync::OnceCell; -use std::{env, net::SocketAddr}; +use std::{ + env, + net::{IpAddr, SocketAddr}, +}; use utils::tracing_telemetry::{FmtLayer, FmtStyle}; /// Cache module for exporter. @@ -26,8 +29,11 @@ async fn initialize_cache() { } /// Get pod ip from env. -fn get_pod_ip() -> Result { - env::var("MY_POD_IP").map_err(|_| ExporterError::PodIPError("Unable to get pod ip".to_string())) +fn get_pod_ip() -> Result { + let ip = env::var("MY_POD_IP") + .map_err(|_| ExporterError::PodIPError("Unable to get pod ip".to_string()))?; + ip.parse::() + .map_err(|_| ExporterError::PodIPError("Invalid pod ip".to_string())) } /// Get node name from env.