Skip to main content

rustfs_obs/metrics/schema/
system_drive.rs

1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::{MetricDescriptor, MetricName, new_counter_md, new_gauge_md, subsystems};
16use std::sync::LazyLock;
17
18/// drive related labels
19pub const DRIVE_LABEL: &str = "drive";
20/// server label
21pub const SERVER_LABEL: &str = "server";
22/// pool index label
23pub const POOL_INDEX_LABEL: &str = "pool_index";
24/// set index label
25pub const SET_INDEX_LABEL: &str = "set_index";
26/// drive index label
27pub const DRIVE_INDEX_LABEL: &str = "drive_index";
28/// API label
29pub const API_LABEL: &str = "api";
30/// Disk id label
31pub const DISK_ID_LABEL: &str = "disk_id";
32/// State label
33pub const STATE_LABEL: &str = "state";
34
35/// All drive-related labels
36pub const ALL_DRIVE_LABELS: [&str; 2] = [SERVER_LABEL, DRIVE_LABEL];
37/// Physical disk identity separates counter resets caused by disk replacement.
38pub const DRIVE_COUNTER_LABELS: [&str; 3] = [SERVER_LABEL, DRIVE_LABEL, DISK_ID_LABEL];
39pub const DRIVE_TOPOLOGY_API_COUNTER_LABELS: [&str; 7] = [
40    SERVER_LABEL,
41    DRIVE_LABEL,
42    POOL_INDEX_LABEL,
43    SET_INDEX_LABEL,
44    DRIVE_INDEX_LABEL,
45    API_LABEL,
46    DISK_ID_LABEL,
47];
48/// Drive labels with erasure-set topology.
49pub const DRIVE_TOPOLOGY_LABELS: [&str; 5] = [
50    SERVER_LABEL,
51    DRIVE_LABEL,
52    POOL_INDEX_LABEL,
53    SET_INDEX_LABEL,
54    DRIVE_INDEX_LABEL,
55];
56/// Drive info labels.
57pub const DRIVE_INFO_LABELS: [&str; 6] = [
58    SERVER_LABEL,
59    DRIVE_LABEL,
60    POOL_INDEX_LABEL,
61    SET_INDEX_LABEL,
62    DRIVE_INDEX_LABEL,
63    DISK_ID_LABEL,
64];
65/// Drive topology labels with a state dimension.
66pub const DRIVE_TOPOLOGY_STATE_LABELS: [&str; 6] = [
67    SERVER_LABEL,
68    DRIVE_LABEL,
69    POOL_INDEX_LABEL,
70    SET_INDEX_LABEL,
71    DRIVE_INDEX_LABEL,
72    STATE_LABEL,
73];
74/// Drive topology labels with an API dimension.
75pub const DRIVE_TOPOLOGY_API_LABELS: [&str; 6] = [
76    SERVER_LABEL,
77    DRIVE_LABEL,
78    POOL_INDEX_LABEL,
79    SET_INDEX_LABEL,
80    DRIVE_INDEX_LABEL,
81    API_LABEL,
82];
83
84pub static DRIVE_PRESENT_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
85    new_gauge_md(
86        MetricName::Custom("present".to_string()),
87        "Configured local drive slot",
88        &ALL_DRIVE_LABELS,
89        subsystems::SYSTEM_DRIVE,
90    )
91});
92
93pub static DRIVE_INFO_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
94    new_gauge_md(
95        MetricName::Custom("info".to_string()),
96        "Drive topology and stable disk identity information",
97        &DRIVE_INFO_LABELS,
98        subsystems::SYSTEM_DRIVE,
99    )
100});
101
102pub static DRIVE_RUNTIME_STATE_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
103    new_gauge_md(
104        MetricName::Custom("runtime_state".to_string()),
105        "Drive runtime state (1 for the active state label, 0 otherwise)",
106        &DRIVE_TOPOLOGY_STATE_LABELS,
107        subsystems::SYSTEM_DRIVE,
108    )
109});
110
111pub static DRIVE_HEALING_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
112    new_gauge_md(
113        MetricName::Custom("healing".to_string()),
114        "Whether the drive is currently healing",
115        &DRIVE_TOPOLOGY_LABELS,
116        subsystems::SYSTEM_DRIVE,
117    )
118});
119
120pub static DRIVE_SCANNING_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
121    new_gauge_md(
122        MetricName::Custom("scanning".to_string()),
123        "Whether the drive is currently being scanned",
124        &DRIVE_TOPOLOGY_LABELS,
125        subsystems::SYSTEM_DRIVE,
126    )
127});
128
129pub static DRIVE_OFFLINE_DURATION_SECONDS_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
130    new_gauge_md(
131        MetricName::Custom("offline_duration_seconds".to_string()),
132        "Duration in seconds the drive has been offline",
133        &DRIVE_TOPOLOGY_LABELS,
134        subsystems::SYSTEM_DRIVE,
135    )
136});
137
138pub static DRIVE_API_CALLS_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
139    new_counter_md(
140        MetricName::Custom("api_calls_total".to_string()),
141        "Total drive API calls by operation",
142        &DRIVE_TOPOLOGY_API_COUNTER_LABELS,
143        subsystems::SYSTEM_DRIVE,
144    )
145});
146
147pub static DRIVE_API_LATENCY_BY_API_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
148    new_gauge_md(
149        MetricName::Custom("api_latency_by_api_micros".to_string()),
150        "Average last minute drive API latency in microseconds by operation",
151        &DRIVE_TOPOLOGY_API_LABELS,
152        subsystems::SYSTEM_DRIVE,
153    )
154});
155
156pub static DRIVE_USED_BYTES_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
157    new_gauge_md(
158        MetricName::DriveUsedBytes,
159        "Total storage used on a drive in bytes",
160        &ALL_DRIVE_LABELS[..],
161        subsystems::SYSTEM_DRIVE,
162    )
163});
164
165pub static DRIVE_FREE_BYTES_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
166    new_gauge_md(
167        MetricName::DriveFreeBytes,
168        "Total storage free on a drive in bytes",
169        &ALL_DRIVE_LABELS[..],
170        subsystems::SYSTEM_DRIVE,
171    )
172});
173
174pub static DRIVE_TOTAL_BYTES_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
175    new_gauge_md(
176        MetricName::DriveTotalBytes,
177        "Total storage available on a drive in bytes",
178        &ALL_DRIVE_LABELS[..],
179        subsystems::SYSTEM_DRIVE,
180    )
181});
182
183pub static DRIVE_CAPACITY_OBSERVATION_STATE_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
184    new_gauge_md(
185        MetricName::Custom("capacity_observation_state".to_string()),
186        "Drive capacity observation state (1 for the active state label, 0 otherwise). States: live, stale, missing",
187        &[&ALL_DRIVE_LABELS[..], &["state"]].concat(),
188        subsystems::SYSTEM_DRIVE,
189    )
190});
191
192pub static DRIVE_CAPACITY_OBSERVATION_AGE_SECONDS_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
193    new_gauge_md(
194        MetricName::Custom("capacity_observation_age_seconds".to_string()),
195        "Age in seconds of the drive capacity observation currently exported",
196        &ALL_DRIVE_LABELS[..],
197        subsystems::SYSTEM_DRIVE,
198    )
199});
200
201pub static DRIVE_USED_INODES_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
202    new_gauge_md(
203        MetricName::DriveUsedInodes,
204        "Total used inodes on a drive",
205        &ALL_DRIVE_LABELS[..],
206        subsystems::SYSTEM_DRIVE,
207    )
208});
209
210pub static DRIVE_FREE_INODES_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
211    new_gauge_md(
212        MetricName::DriveFreeInodes,
213        "Total free inodes on a drive",
214        &ALL_DRIVE_LABELS[..],
215        subsystems::SYSTEM_DRIVE,
216    )
217});
218
219pub static DRIVE_TOTAL_INODES_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
220    new_gauge_md(
221        MetricName::DriveTotalInodes,
222        "Total inodes available on a drive",
223        &ALL_DRIVE_LABELS[..],
224        subsystems::SYSTEM_DRIVE,
225    )
226});
227
228pub static DRIVE_TIMEOUT_ERRORS_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
229    new_counter_md(
230        MetricName::DriveTimeoutErrorsTotal,
231        "Total timeout errors on a drive",
232        &DRIVE_COUNTER_LABELS[..],
233        subsystems::SYSTEM_DRIVE,
234    )
235});
236
237pub static DRIVE_IO_ERRORS_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
238    new_counter_md(
239        MetricName::DriveIOErrorsTotal,
240        "Total I/O errors on a drive",
241        &DRIVE_COUNTER_LABELS[..],
242        subsystems::SYSTEM_DRIVE,
243    )
244});
245
246pub static DRIVE_AVAILABILITY_ERRORS_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
247    new_counter_md(
248        MetricName::DriveAvailabilityErrorsTotal,
249        "Total availability errors (I/O errors, timeouts) on a drive",
250        &DRIVE_COUNTER_LABELS[..],
251        subsystems::SYSTEM_DRIVE,
252    )
253});
254
255pub static DRIVE_WAITING_IO_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
256    new_gauge_md(
257        MetricName::DriveWaitingIO,
258        "Total waiting I/O operations on a drive",
259        &ALL_DRIVE_LABELS[..],
260        subsystems::SYSTEM_DRIVE,
261    )
262});
263
264pub static DRIVE_API_LATENCY_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
265    new_gauge_md(
266        MetricName::DriveAPILatencyMicros,
267        "Average last minute latency in µs for drive API storage operations",
268        &ALL_DRIVE_LABELS[..],
269        subsystems::SYSTEM_DRIVE,
270    )
271});
272
273pub static DRIVE_HEALTH_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
274    new_gauge_md(
275        MetricName::DriveHealth,
276        "Drive health (0 = offline, 1 = healthy, 2 = healing)",
277        &ALL_DRIVE_LABELS[..],
278        subsystems::SYSTEM_DRIVE,
279    )
280});
281
282pub static DRIVE_WRITES_TOTAL_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
283    new_counter_md(
284        MetricName::DriveWritesTotal,
285        "Total successful write operations on a drive",
286        &DRIVE_COUNTER_LABELS[..],
287        subsystems::SYSTEM_DRIVE,
288    )
289});
290
291pub static DRIVE_DELETES_TOTAL_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
292    new_counter_md(
293        MetricName::DriveDeletesTotal,
294        "Total successful delete operations on a drive",
295        &DRIVE_COUNTER_LABELS[..],
296        subsystems::SYSTEM_DRIVE,
297    )
298});
299
300pub static DRIVE_OFFLINE_COUNT_MD: LazyLock<MetricDescriptor> =
301    LazyLock::new(|| new_gauge_md(MetricName::DriveOfflineCount, "Count of offline drives", &[], subsystems::SYSTEM_DRIVE));
302
303pub static DRIVE_ONLINE_COUNT_MD: LazyLock<MetricDescriptor> =
304    LazyLock::new(|| new_gauge_md(MetricName::DriveOnlineCount, "Count of online drives", &[], subsystems::SYSTEM_DRIVE));
305
306pub static DRIVE_COUNT_MD: LazyLock<MetricDescriptor> =
307    LazyLock::new(|| new_gauge_md(MetricName::DriveCount, "Count of all drives", &[], subsystems::SYSTEM_DRIVE));
308
309pub static DRIVE_READS_PER_SEC_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
310    new_gauge_md(
311        MetricName::DriveReadsPerSec,
312        "Reads per second on a drive",
313        &ALL_DRIVE_LABELS[..],
314        subsystems::SYSTEM_DRIVE,
315    )
316});
317
318pub static DRIVE_READS_KB_PER_SEC_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
319    new_gauge_md(
320        MetricName::DriveReadsKBPerSec,
321        "Kilobytes read per second on a drive",
322        &ALL_DRIVE_LABELS[..],
323        subsystems::SYSTEM_DRIVE,
324    )
325});
326
327pub static DRIVE_READS_AWAIT_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
328    new_gauge_md(
329        MetricName::DriveReadsAwait,
330        "Average time for read requests served on a drive",
331        &ALL_DRIVE_LABELS[..],
332        subsystems::SYSTEM_DRIVE,
333    )
334});
335
336pub static DRIVE_WRITES_PER_SEC_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
337    new_gauge_md(
338        MetricName::DriveWritesPerSec,
339        "Writes per second on a drive",
340        &ALL_DRIVE_LABELS[..],
341        subsystems::SYSTEM_DRIVE,
342    )
343});
344
345pub static DRIVE_WRITES_KB_PER_SEC_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
346    new_gauge_md(
347        MetricName::DriveWritesKBPerSec,
348        "Kilobytes written per second on a drive",
349        &ALL_DRIVE_LABELS[..],
350        subsystems::SYSTEM_DRIVE,
351    )
352});
353
354pub static DRIVE_WRITES_AWAIT_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
355    new_gauge_md(
356        MetricName::DriveWritesAwait,
357        "Average time for write requests served on a drive",
358        &ALL_DRIVE_LABELS[..],
359        subsystems::SYSTEM_DRIVE,
360    )
361});
362
363pub static DRIVE_PERC_UTIL_MD: LazyLock<MetricDescriptor> = LazyLock::new(|| {
364    new_gauge_md(
365        MetricName::DrivePercUtil,
366        "Percentage of time the disk was busy",
367        &ALL_DRIVE_LABELS[..],
368        subsystems::SYSTEM_DRIVE,
369    )
370});