102 lines
3.0 KiB
Rust
102 lines
3.0 KiB
Rust
use metrics::{
|
|
Counter, Gauge, Histogram, Unit, describe_counter, describe_gauge, describe_histogram,
|
|
};
|
|
|
|
pub fn init() {
|
|
describe_gauge!(
|
|
"aggregator_targets_total",
|
|
Unit::Count,
|
|
"Total number of scrape targets known to the aggregator"
|
|
);
|
|
describe_gauge!(
|
|
"aggregator_targets_healthy",
|
|
Unit::Count,
|
|
"Number of scrape targets that responded last scrape"
|
|
);
|
|
describe_counter!(
|
|
"aggregator_scrape_total",
|
|
Unit::Count,
|
|
"Total number of scrape attempts"
|
|
);
|
|
describe_counter!(
|
|
"aggregator_scrape_success",
|
|
Unit::Count,
|
|
"Successful scrapes"
|
|
);
|
|
describe_counter!(
|
|
"aggregator_scrape_failures",
|
|
Unit::Count,
|
|
"Failed scrape attempts"
|
|
);
|
|
describe_counter!(
|
|
"aggregator_scrape_errors_parse",
|
|
Unit::Count,
|
|
"Scrape failures due to parse errors"
|
|
);
|
|
describe_counter!(
|
|
"aggregator_scrape_errors_timeout",
|
|
Unit::Count,
|
|
"Scrape failures due to timeout"
|
|
);
|
|
describe_counter!(
|
|
"aggregator_scrape_errors_connection",
|
|
Unit::Count,
|
|
"Scrape failures due to connection errors"
|
|
);
|
|
describe_counter!(
|
|
"aggregator_targets_discovered",
|
|
Unit::Count,
|
|
"Total targets discovered"
|
|
);
|
|
describe_counter!(
|
|
"aggregator_targets_lost",
|
|
Unit::Count,
|
|
"Total targets that disappeared"
|
|
);
|
|
describe_histogram!(
|
|
"aggregator_scrape_duration_ms",
|
|
Unit::Milliseconds,
|
|
"Scrape duration in milliseconds"
|
|
);
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
#[allow(dead_code)]
|
|
pub struct AggMetrics {
|
|
pub targets_total: Gauge,
|
|
pub targets_healthy: Gauge,
|
|
pub scrape_total: Counter,
|
|
pub scrape_success: Counter,
|
|
pub scrape_failures: Counter,
|
|
pub scrape_errors_parse: Counter,
|
|
pub scrape_errors_timeout: Counter,
|
|
pub scrape_errors_connection: Counter,
|
|
pub targets_discovered: Counter,
|
|
pub targets_lost: Counter,
|
|
pub scrape_duration: Histogram,
|
|
}
|
|
|
|
impl Default for AggMetrics {
|
|
fn default() -> Self {
|
|
Self {
|
|
targets_total: metrics::gauge!("aggregator_targets_total"),
|
|
targets_healthy: metrics::gauge!("aggregator_targets_healthy"),
|
|
scrape_total: metrics::counter!("aggregator_scrape_total"),
|
|
scrape_success: metrics::counter!("aggregator_scrape_success"),
|
|
scrape_failures: metrics::counter!("aggregator_scrape_failures"),
|
|
scrape_errors_parse: metrics::counter!("aggregator_scrape_errors_parse"),
|
|
scrape_errors_timeout: metrics::counter!("aggregator_scrape_errors_timeout"),
|
|
scrape_errors_connection: metrics::counter!("aggregator_scrape_errors_connection"),
|
|
targets_discovered: metrics::counter!("aggregator_targets_discovered"),
|
|
targets_lost: metrics::counter!("aggregator_targets_lost"),
|
|
scrape_duration: metrics::histogram!("aggregator_scrape_duration_ms"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl AggMetrics {
|
|
pub fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
}
|