mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
This commit is contained in:
@@ -91,7 +91,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "gauge_rustfs_process_uptime_seconds{job=~\"$job\"}",
|
"expr": "rustfs_system_process_uptime_seconds{job=~\"$job\"}",
|
||||||
"legendFormat": "__auto",
|
"legendFormat": "__auto",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -223,7 +223,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum(gauge_rustfs_cluster_buckets_total{job=~\"$job\"})",
|
"expr": "sum(rustfs_cluster_buckets_total{job=~\"$job\"})",
|
||||||
"legendFormat": "__auto",
|
"legendFormat": "__auto",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -289,7 +289,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum(gauge_rustfs_cluster_objects_total{job=~\"$job\"})",
|
"expr": "sum(rustfs_cluster_objects_total{job=~\"$job\"})",
|
||||||
"legendFormat": "__auto",
|
"legendFormat": "__auto",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -427,7 +427,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum(gauge_rustfs_cluster_capacity_used_bytes{job=~\"$job\"})",
|
"expr": "sum(rustfs_cluster_capacity_used_bytes{job=~\"$job\"})",
|
||||||
"legendFormat": "Used",
|
"legendFormat": "Used",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -438,7 +438,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum(gauge_rustfs_cluster_capacity_raw_total_bytes{job=~\"$job\"})",
|
"expr": "sum(rustfs_cluster_capacity_raw_total_bytes{job=~\"$job\"})",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
"legendFormat": "Total",
|
"legendFormat": "Total",
|
||||||
"range": true,
|
"range": true,
|
||||||
@@ -450,7 +450,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum(gauge_rustfs_cluster_capacity_used_bytes{job=~\"$job\"}) / sum(gauge_rustfs_cluster_capacity_raw_total_bytes{job=~\"$job\"})",
|
"expr": "sum(rustfs_cluster_capacity_used_bytes{job=~\"$job\"}) / sum(rustfs_cluster_capacity_raw_total_bytes{job=~\"$job\"})",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
"instant": false,
|
"instant": false,
|
||||||
"legendFormat": "Percent",
|
"legendFormat": "Percent",
|
||||||
@@ -1971,7 +1971,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum by (drive) (gauge_rustfs_node_disk_used_bytes{job=~\"$job\", drive=~\"$drive\"})",
|
"expr": "sum by (drive) (rustfs_node_disk_used_bytes{job=~\"$job\", drive=~\"$drive\"})",
|
||||||
"legendFormat": "{{drive}} (bytes)",
|
"legendFormat": "{{drive}} (bytes)",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -1982,7 +1982,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum by (drive) (gauge_rustfs_node_disk_used_bytes{job=~\"$job\", drive=~\"$drive\"}) / sum by (drive)(gauge_rustfs_node_disk_total_bytes{job=~\"$job\", drive=~\"$drive\"})",
|
"expr": "sum by (drive) (rustfs_node_disk_used_bytes{job=~\"$job\", drive=~\"$drive\"}) / sum by (drive)(rustfs_node_disk_total_bytes{job=~\"$job\", drive=~\"$drive\"})",
|
||||||
"hide": false,
|
"hide": false,
|
||||||
"instant": false,
|
"instant": false,
|
||||||
"legendFormat": "{{drive}} (percent)",
|
"legendFormat": "{{drive}} (percent)",
|
||||||
@@ -2473,7 +2473,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum by (job) (gauge_rustfs_process_cpu_usage{job=~\"$job\"})",
|
"expr": "sum by (job) (rustfs_system_process_cpu_usage{job=~\"$job\"})",
|
||||||
"legendFormat": "{{job}}",
|
"legendFormat": "{{job}}",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
@@ -2572,7 +2572,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum by (job) (gauge_rustfs_process_resident_memory_bytes{job=~\"$job\"})",
|
"expr": "sum by (job) (rustfs_system_process_resident_memory_bytes{job=~\"$job\"})",
|
||||||
"legendFormat": "{{job}}",
|
"legendFormat": "{{job}}",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "B"
|
"refId": "B"
|
||||||
@@ -2670,7 +2670,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum by (job) (rate(gauge_rustfs_process_network_io{job=~\"$job\", direction=\"received\"}[5m]))",
|
"expr": "sum by (job) (rate(rustfs_system_process_network_io{job=~\"$job\", direction=\"received\"}[5m]))",
|
||||||
"legendFormat": "RX - {{job}}",
|
"legendFormat": "RX - {{job}}",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "C"
|
"refId": "C"
|
||||||
@@ -2681,7 +2681,7 @@
|
|||||||
"uid": "${datasource}"
|
"uid": "${datasource}"
|
||||||
},
|
},
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"expr": "sum by (job) (rate(gauge_rustfs_process_network_io{job=~\"$job\", direction=\"transmitted\"}[5m]))",
|
"expr": "sum by (job) (rate(rustfs_system_process_network_io{job=~\"$job\", direction=\"transmitted\"}[5m]))",
|
||||||
"legendFormat": "TX - {{job}}",
|
"legendFormat": "TX - {{job}}",
|
||||||
"range": true,
|
"range": true,
|
||||||
"refId": "D"
|
"refId": "D"
|
||||||
@@ -4922,4 +4922,4 @@
|
|||||||
"title": "RustFS",
|
"title": "RustFS",
|
||||||
"uid": "rustfs-s3",
|
"uid": "rustfs-s3",
|
||||||
"version": 12
|
"version": 12
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ mod tests {
|
|||||||
assert_eq!(metrics.len(), 8);
|
assert_eq!(metrics.len(), 8);
|
||||||
|
|
||||||
// Verify that metric names are properly generated from descriptors
|
// Verify that metric names are properly generated from descriptors
|
||||||
assert!(metrics.iter().all(|m| m.name.starts_with("gauge.rustfs_system_cpu_")));
|
assert!(metrics.iter().all(|m| m.name.starts_with("rustfs_system_cpu_")));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ mod tests {
|
|||||||
report_metrics(&metrics);
|
report_metrics(&metrics);
|
||||||
|
|
||||||
assert_eq!(metrics.len(), 8);
|
assert_eq!(metrics.len(), 8);
|
||||||
assert!(metrics.iter().all(|m| m.name.starts_with("gauge.rustfs_system_memory_")));
|
assert!(metrics.iter().all(|m| m.name.starts_with("rustfs_system_memory_")));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -51,14 +51,13 @@ impl MetricDescriptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the full metric name, including the prefix and formatting path
|
/// Get the full metric name in Prometheus style: <namespace>_<subsystem>_<name>
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn get_full_metric_name(&self) -> String {
|
pub fn get_full_metric_name(&self) -> String {
|
||||||
let prefix = self.metric_type.as_prom();
|
|
||||||
let namespace = self.namespace.as_str();
|
let namespace = self.namespace.as_str();
|
||||||
let formatted_subsystem = self.subsystem.as_str();
|
let formatted_subsystem = self.subsystem.as_str();
|
||||||
|
|
||||||
format!("{}{}_{}_{}", prefix, namespace, formatted_subsystem, self.name.as_str())
|
format!("{}_{}_{}", namespace, formatted_subsystem, self.name.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// check whether the label is in the label set
|
/// check whether the label is in the label set
|
||||||
@@ -79,3 +78,36 @@ impl MetricDescriptor {
|
|||||||
self.label_set.as_ref().unwrap()
|
self.label_set.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn full_metric_name_uses_prometheus_convention_without_type_prefix() {
|
||||||
|
let descriptor = MetricDescriptor::new(
|
||||||
|
MetricName::ApiRequestsTotal,
|
||||||
|
MetricType::Counter,
|
||||||
|
"test help".to_string(),
|
||||||
|
vec![],
|
||||||
|
MetricNamespace::RustFS,
|
||||||
|
MetricSubsystem::ApiRequests,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(descriptor.get_full_metric_name(), "rustfs_api_requests_total");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn full_metric_name_formats_custom_subsystems_without_type_prefix() {
|
||||||
|
let descriptor = MetricDescriptor::new(
|
||||||
|
MetricName::Custom("latency_seconds".to_string()),
|
||||||
|
MetricType::Histogram,
|
||||||
|
"test help".to_string(),
|
||||||
|
vec![],
|
||||||
|
MetricNamespace::RustFS,
|
||||||
|
MetricSubsystem::new("/custom/path-metrics"),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(descriptor.get_full_metric_name(), "rustfs_custom_path_metrics_latency_seconds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ mod tests {
|
|||||||
assert_eq!(histogram_md.subsystem, MetricSubsystem::ApiRequests);
|
assert_eq!(histogram_md.subsystem, MetricSubsystem::ApiRequests);
|
||||||
|
|
||||||
// Verify that the full metric name generated is formatted correctly
|
// Verify that the full metric name generated is formatted correctly
|
||||||
assert_eq!(histogram_md.get_full_metric_name(), "histogram.rustfs_api_requests_seconds_distribution");
|
assert_eq!(histogram_md.get_full_metric_name(), "rustfs_api_requests_seconds_distribution");
|
||||||
|
|
||||||
// Tests use custom subsystems
|
// Tests use custom subsystems
|
||||||
let custom_histogram_md = new_histogram_md(
|
let custom_histogram_md = new_histogram_md(
|
||||||
@@ -123,7 +123,7 @@ mod tests {
|
|||||||
// Verify the custom name and subsystem
|
// Verify the custom name and subsystem
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
custom_histogram_md.get_full_metric_name(),
|
custom_histogram_md.get_full_metric_name(),
|
||||||
"histogram.rustfs_custom_path_metrics_custom_latency_distribution"
|
"rustfs_custom_path_metrics_custom_latency_distribution"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ mod tests {
|
|||||||
MetricSubsystem::ApiRequests,
|
MetricSubsystem::ApiRequests,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(md.get_full_metric_name(), "counter.rustfs_api_requests_total");
|
assert_eq!(md.get_full_metric_name(), "rustfs_api_requests_total");
|
||||||
|
|
||||||
let custom_md = MetricDescriptor::new(
|
let custom_md = MetricDescriptor::new(
|
||||||
MetricName::Custom("test_metric".to_string()),
|
MetricName::Custom("test_metric".to_string()),
|
||||||
@@ -244,6 +244,6 @@ mod tests {
|
|||||||
MetricSubsystem::new("/custom/path-with-dash"),
|
MetricSubsystem::new("/custom/path-with-dash"),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(custom_md.get_full_metric_name(), "gauge.rustfs_custom_path_with_dash_test_metric");
|
assert_eq!(custom_md.get_full_metric_name(), "rustfs_custom_path_with_dash_test_metric");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user