Skip to content

Commit 2ec2498

Browse files
feat(exporter): adding pool alert metrics
Signed-off-by: Abhilash Shetty <abhilash.shetty@datacore.com>
1 parent 81f769f commit 2ec2498

4 files changed

Lines changed: 469 additions & 3 deletions

File tree

metrics-exporter/src/bin/io_engine/client/pool.rs

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ pub(crate) struct PoolInfo {
1010
committed: u64,
1111
disk_capacity: u64,
1212
max_expandable_size: u64,
13+
io_error_count: u64,
14+
io_error_threshold: u64,
15+
io_stalled: bool,
16+
io_stall_transition_count: u64,
17+
io_stall_transition_threshold: u64,
18+
alert_status: i32,
19+
notice: Vec<i32>,
20+
attention: Vec<i32>,
21+
warning: Vec<i32>,
22+
critical: Vec<i32>,
1323
}
1424

1525
impl PoolInfo {
@@ -43,10 +53,60 @@ impl PoolInfo {
4353
self.max_expandable_size
4454
}
4555

46-
/// Get pool of the io_engine.
56+
/// Get state of the Pool.
4757
pub(crate) fn state(&self) -> u64 {
4858
self.state
4959
}
60+
61+
/// Get the count of IO errors on the pool.
62+
pub(crate) fn io_error_count(&self) -> u64 {
63+
self.io_error_count
64+
}
65+
66+
/// Get the IO error threshold for the pool.
67+
pub(crate) fn io_error_threshold(&self) -> u64 {
68+
self.io_error_threshold
69+
}
70+
71+
/// Get whether the pool is currently in stalled state.
72+
pub(crate) fn io_stalled(&self) -> bool {
73+
self.io_stalled
74+
}
75+
76+
/// Get the count of IO stall transitions on the pool.
77+
pub(crate) fn io_stall_transition_count(&self) -> u64 {
78+
self.io_stall_transition_count
79+
}
80+
81+
/// Get the IO stall transition threshold for the pool.
82+
pub(crate) fn io_stall_transition_threshold(&self) -> u64 {
83+
self.io_stall_transition_threshold
84+
}
85+
86+
/// Get the alert status for the pool.
87+
pub(crate) fn alert_status(&self) -> i32 {
88+
self.alert_status
89+
}
90+
91+
/// Get the collection of notice alert reasons for the pool.
92+
pub(crate) fn notice(&self) -> &Vec<i32> {
93+
&self.notice
94+
}
95+
96+
/// Get the collection of attention alert reasons for the pool.
97+
pub(crate) fn attention(&self) -> &Vec<i32> {
98+
&self.attention
99+
}
100+
101+
/// Get the collection of warning alert reasons for the pool.
102+
pub(crate) fn warning(&self) -> &Vec<i32> {
103+
&self.warning
104+
}
105+
106+
/// Get the collection of critical alert reasons for the pool.
107+
pub(crate) fn critical(&self) -> &Vec<i32> {
108+
&self.critical
109+
}
50110
}
51111

52112
/// Array of PoolInfo objects.
@@ -57,6 +117,34 @@ pub(crate) struct Pools {
57117

58118
impl From<rpc::v1::pool::Pool> for PoolInfo {
59119
fn from(value: rpc::v1::pool::Pool) -> Self {
120+
let mut io_error_count: u64 = 0;
121+
let mut io_error_threshold: u64 = 0;
122+
let mut io_stalled: bool = false;
123+
let mut io_stall_transition_count: u64 = 0;
124+
let mut io_stall_transition_threshold: u64 = 0;
125+
let mut alert_status: i32 = 0;
126+
let mut notice: Vec<i32> = Vec::new();
127+
let mut attention: Vec<i32> = Vec::new();
128+
let mut warning: Vec<i32> = Vec::new();
129+
let mut critical: Vec<i32> = Vec::new();
130+
if let Some(errors) = value.errors.clone() {
131+
io_error_count = errors.io_error_count;
132+
io_error_threshold = errors.io_error_threshold;
133+
io_stalled = errors.io_stalled;
134+
io_stall_transition_count = errors.io_stall_transition_count;
135+
io_stall_transition_threshold = errors.io_stall_transition_threshold;
136+
if let Some(alerts) = errors.alerts {
137+
alert_status = alerts.status;
138+
139+
notice = alerts.notice;
140+
141+
attention = alerts.attention;
142+
143+
warning = alerts.warning;
144+
145+
critical = alerts.critical;
146+
}
147+
}
60148
Self {
61149
name: value.name,
62150
used: value.used,
@@ -65,6 +153,16 @@ impl From<rpc::v1::pool::Pool> for PoolInfo {
65153
committed: value.committed,
66154
disk_capacity: value.disk_capacity,
67155
max_expandable_size: value.max_expandable_size.unwrap_or_default(),
156+
io_error_count,
157+
io_error_threshold,
158+
io_stalled,
159+
io_stall_transition_count,
160+
io_stall_transition_threshold,
161+
alert_status,
162+
notice,
163+
attention,
164+
warning,
165+
critical,
68166
}
69167
}
70168
}

metrics-exporter/src/bin/io_engine/collector/mod.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,43 @@ fn init_diskpool_gauge_vec(
2424
gauge_vec
2525
}
2626

27+
/// Initializes a GaugeVec metric for diskpool alert reason with the provided metric name, description and
28+
/// descriptors.
29+
fn init_diskpool_alert_reason_gauge_vec(
30+
metric_name: &str,
31+
metric_desc: &str,
32+
descs: &mut Vec<Desc>,
33+
) -> GaugeVec {
34+
let opts = Opts::new(metric_name, metric_desc)
35+
.subsystem("diskpool_alert")
36+
.variable_labels(vec![
37+
"node".to_string(),
38+
"name".to_string(),
39+
"unknown".to_string(),
40+
"io_stalled".to_string(),
41+
"io_stall_intermittent".to_string(),
42+
"io_stall_intermittent_exc".to_string(),
43+
"io_error".to_string(),
44+
"io_error_exc".to_string(),
45+
]);
46+
let gauge_vec = GaugeVec::new(
47+
opts,
48+
&[
49+
"node",
50+
"name",
51+
"unknown",
52+
"io_stalled",
53+
"io_stall_intermittent",
54+
"io_stall_intermittent_exc",
55+
"io_error",
56+
"io_error_exc",
57+
],
58+
)
59+
.unwrap_or_else(|_| panic!("Unable to create gauge metric type for {metric_name}"));
60+
descs.extend(gauge_vec.desc().into_iter().cloned());
61+
gauge_vec
62+
}
63+
2764
/// Initializes a GaugeVec metric for volume with the provided metric name, description and
2865
/// descriptors.
2966
fn init_volume_gauge_vec(metric_name: &str, metric_desc: &str, descs: &mut Vec<Desc>) -> GaugeVec {

0 commit comments

Comments
 (0)