Crates.io | prometheus-edge-detector |
lib.rs | prometheus-edge-detector |
version | 0.3.0 |
source | src |
created_at | 2021-01-06 23:46:50.380898 |
updated_at | 2024-02-12 18:56:24.261632 |
description | Find the most recent rising or dropping edge from a prometheus query |
homepage | |
repository | https://github.com/icewind1991/prometheus-edge-detector |
max_upload_size | |
id | 333462 |
size | 55,526 |
Find the most recent rising or dropping edge from a prometheus query
use main_error::MainError;
use prometheus_edge_detector::EdgeDetector;
use tokio::time::Duration;
#[tokio::main]
async fn main() -> Result<(), MainError> {
let edge_detector = EdgeDetector::new("http://example.com");
let edge = edge_detector
.get_last_edge("prometheus_value", 1, 0, Duration::from_secs(60 * 60))
.await?;
if let Some(edge_time) = edge {
print!("Last dropping edge: {}", edge_time);
} else {
println!("Query doesn't end with dropping edge");
}
Ok(())
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.