From 2ab8475b84bf2bbe2b864db56d753b534e2c50c4 Mon Sep 17 00:00:00 2001 From: Dhruv Vaishnav Date: Sat, 19 Sep 2026 09:27:10 +0000 Subject: [PATCH] feat: add status label to datanode failed-insert metric (#9191) * feat: label datanode failed inserts by status Signed-off-by: dhruvxvaishnav * fix: rename failed-insert metric label to code Signed-off-by: dhruvxvaishnav --------- Signed-off-by: dhruvxvaishnav Co-authored-by: Weny Xu --- src/datanode/src/metrics.rs | 6 ++++-- src/datanode/src/region_server.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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.