Skip to content
Snippets Groups Projects
Unverified Commit 5db31729 authored by RDruon's avatar RDruon Committed by GitHub
Browse files

Various fix (#9)

* Add OST stats

* Add OST/MDT stats

* Append 'lustre_' to stats metrics

* Various fix

* Query lnetctl info
parent 3793d240
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ use prometheus_exporter_base::{prelude::*, Yes};
use crate::{
jobstats::{build_mdt_job_stats, build_ost_job_stats},
stats::build_stats,
Metric, StatsMapExt, ToMetricInst,
LabelProm, Metric, StatsMapExt, ToMetricInst,
};
static DISK_IO_TOTAL: Metric = Metric {
......@@ -64,20 +64,20 @@ static INODES_MAXIMUM: Metric = Metric {
};
static AVAILABLE_BYTES: Metric = Metric {
name: "lustre_available_bytes",
help: "Number of bytes readily available in the pool",
name: "lustre_available_kilobytes",
help: "Number of kilobytes readily available in the pool",
r#type: MetricType::Gauge,
};
static FREE_BYTES: Metric = Metric {
name: "lustre_free_bytes",
help: "Number of bytes allocated to the pool",
name: "lustre_free_kilobytes",
help: "Number of kilobytes allocated to the pool",
r#type: MetricType::Gauge,
};
static CAPACITY_BYTES: Metric = Metric {
name: "lustre_capacity_bytes",
help: "Capacity of the pool in bytes",
name: "lustre_capacity_kilobytes",
help: "Capacity of the pool in kilobytes",
r#type: MetricType::Gauge,
};
......@@ -164,7 +164,7 @@ fn build_brw_stats(
for b in buckets {
let size = b.name.to_string();
let (r, w) = rw_inst(b, kind.deref(), target.deref(), time);
let (r, w) = rw_inst(b, kind.to_prom_label(), target.deref(), time);
metric
.render_and_append_instance(&r.with_label("size", size.as_str()))
......
use std::{collections::BTreeMap, ops::Deref, time::Duration};
use crate::{Metric, StatsMapExt};
use crate::{LabelProm, Metric, StatsMapExt};
use lustre_collector::{JobStatMdt, JobStatOst, TargetStat};
use prometheus_exporter_base::{prelude::*, Yes};
......@@ -134,7 +134,7 @@ pub fn build_ost_job_stats(
for x in xs {
let (rs, rmin, rmax, rb, ws, wmin, wmax, wb) =
jobstatost_inst(&x, kind.deref(), target.deref(), time);
jobstatost_inst(&x, kind.to_prom_label(), target.deref(), time);
stats_map
.get_mut_metric(READ_SAMPLES)
......@@ -345,7 +345,7 @@ pub fn build_mdt_job_stats(
sync,
samedir_rename,
crossdir_rename,
) = jobstatmdt_inst(&x, kind.deref(), target.deref(), time);
) = jobstatmdt_inst(&x, kind.to_prom_label(), target.deref(), time);
stats_map
.get_mut_metric(MDT_JOBSTATS_SAMPLES)
......
......@@ -5,7 +5,7 @@ pub mod stats;
use brw_stats::build_target_stats;
use lnet::build_lnet_stats;
use lustre_collector::{LNetStat, Record, TargetStat};
use lustre_collector::{LNetStat, Record, TargetStat, TargetVariant};
use num_traits::Num;
use prometheus_exporter_base::{prelude::*, Yes};
use std::{collections::BTreeMap, fmt, ops::Deref, time::Duration};
......@@ -17,6 +17,20 @@ struct Metric {
r#type: MetricType,
}
trait LabelProm {
fn to_prom_label(&self) -> &'static str;
}
impl LabelProm for TargetVariant {
fn to_prom_label(&self) -> &'static str {
match self {
TargetVariant::Ost => "ost",
TargetVariant::Mgt => "mgt",
TargetVariant::Mdt => "mdt",
}
}
}
impl From<Metric> for PrometheusMetric<'_> {
fn from(x: Metric) -> Self {
PrometheusMetric::build()
......@@ -40,7 +54,7 @@ where
{
fn to_metric_inst(&self, time: Duration) -> PrometheusInstance<'_, T, Yes> {
PrometheusInstance::new()
.with_label("component", self.kind.deref())
.with_label("component", self.kind.to_prom_label())
.with_label("target", self.target.deref())
.with_value(self.value)
.with_timestamp(time.as_millis())
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use lustre_collector::{parse_lctl_output, parser};
use lustre_collector::{parse_lctl_output, parse_lnetctl_output, parser};
use lustrefs_exporter::build_lustre_stats;
use prometheus_exporter_base::prelude::*;
use std::time::{SystemTime, UNIX_EPOCH};
......@@ -20,18 +20,30 @@ async fn main() {
render_prometheus(addr, Options, |request, options| async move {
println!("in our render_prometheus(request == {request:?}, options == {options:?})");
let output = Command::new("lctl")
let time = SystemTime::now().duration_since(UNIX_EPOCH)?;
let mut output = vec![];
let lctl = Command::new("lctl")
.arg("get_param")
.args(parser::params())
.kill_on_drop(true)
.output()
.await?;
let mut lctl_output = parse_lctl_output(&lctl.stdout)?;
output.append(&mut lctl_output);
let time = SystemTime::now().duration_since(UNIX_EPOCH)?;
let lnetctl = Command::new("lnetctl")
.args(["net", "show", "-v", "4"])
.kill_on_drop(true)
.output()
.await?;
let lctl_output = parse_lctl_output(&output.stdout)?;
let lnetctl_stats = std::str::from_utf8(&lnetctl.stdout)?;
let mut lnetctl_output = parse_lnetctl_output(lnetctl_stats)?;
output.append(&mut lnetctl_output);
Ok(build_lustre_stats(lctl_output, time))
Ok(build_lustre_stats(output, time))
})
.await;
}
......
This diff is collapsed.
This diff is collapsed.
use std::{collections::BTreeMap, ops::Deref, time::Duration};
use crate::{Metric, StatsMapExt};
use crate::{LabelProm, Metric, StatsMapExt};
use lustre_collector::{Stat, Target, TargetStat};
use prometheus_exporter_base::prelude::*;
......@@ -60,7 +60,7 @@ pub fn build_ost_stats(
.get_mut_metric(READ_SAMPLES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", "read")
.with_label("target", target.deref())
.with_value(s.samples)
......@@ -71,7 +71,7 @@ pub fn build_ost_stats(
.get_mut_metric(READ_MIN_SIZE_BYTES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", "read")
.with_label("target", target.deref())
.with_value(v)
......@@ -83,7 +83,7 @@ pub fn build_ost_stats(
.get_mut_metric(READ_MAX_SIZE_BYTES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", "read")
.with_label("target", target.deref())
.with_value(v)
......@@ -95,7 +95,7 @@ pub fn build_ost_stats(
.get_mut_metric(READ_BYTES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", "read")
.with_label("target", target.deref())
.with_value(v)
......@@ -108,7 +108,7 @@ pub fn build_ost_stats(
.get_mut_metric(WRITE_SAMPLES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", "write")
.with_label("target", target.deref())
.with_value(s.samples)
......@@ -119,7 +119,7 @@ pub fn build_ost_stats(
.get_mut_metric(WRITE_MIN_SIZE_BYTES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", "write")
.with_label("target", target.deref())
.with_value(v)
......@@ -131,7 +131,7 @@ pub fn build_ost_stats(
.get_mut_metric(WRITE_MAX_SIZE_BYTES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", "write")
.with_label("target", target.deref())
.with_value(v)
......@@ -143,7 +143,7 @@ pub fn build_ost_stats(
.get_mut_metric(WRITE_BYTES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", "write")
.with_label("target", target.deref())
.with_value(v)
......@@ -176,7 +176,7 @@ pub fn build_mdt_stats(
.get_mut_metric(MDT_STATS_SAMPLES)
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("component", kind.deref())
.with_label("component", kind.to_prom_label())
.with_label("operation", s.name.deref())
.with_label("target", target.deref())
.with_value(s.samples)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment