diff --git a/src/datanode/src/metrics.rs b/src/datanode/src/metrics.rs index 74da5b153f4..7573490c747 100644 --- a/src/datanode/src/metrics.rs +++ b/src/datanode/src/metrics.rs @@ -17,6 +17,7 @@ use prometheus::*; /// Region request type label. pub const REGION_REQUEST_TYPE: &str = "datanode_region_request_type"; +const REGION_REQUEST_CODE: &str = "code"; pub const REGION_ROLE: &str = "region_role"; pub const REGION_ID: &str = "region_id"; @@ -84,11 +85,12 @@ lazy_static! { ) .unwrap(); - /// Total count of failed insert requests to region server. + /// Total count of failed insert requests to region server, labeled with request + /// type and status code. pub static ref REGION_SERVER_INSERT_FAIL_COUNT: IntCounterVec = register_int_counter_vec!( "greptime_datanode_region_failed_insert_count", "failed region server insert requests count", - &[REGION_REQUEST_TYPE] + &[REGION_REQUEST_TYPE, REGION_REQUEST_CODE] ) .unwrap(); diff --git a/src/datanode/src/region_server.rs b/src/datanode/src/region_server.rs index 10bcf32b13d..527ab0491c0 100644 --- a/src/datanode/src/region_server.rs +++ b/src/datanode/src/region_server.rs @@ -687,7 +687,7 @@ impl RegionServer { } Err(err) => { crate::metrics::REGION_SERVER_INSERT_FAIL_COUNT - .with_label_values(&[request_type]) + .with_label_values(&[request_type, err.status_code().as_ref()]) .inc_by(batch_size as u64); Err(err) } @@ -1640,7 +1640,7 @@ impl RegionServerInner { Err(err) => { if matches!(region_change, RegionChange::Ingest) { crate::metrics::REGION_SERVER_INSERT_FAIL_COUNT - .with_label_values(&[request_type]) + .with_label_values(&[request_type, err.status_code().as_ref()]) .inc(); } // Removes the region status if the operation fails.