From ec84f4b63ec1136aa2062a7b8fcdb960aa294cbf Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Thu, 21 May 2020 12:43:54 +0300 Subject: [PATCH] Add prometheus config --- .gitignore | 3 +++ Cargo.lock | 6 +++--- Cargo.toml | 5 +---- prometheus.yml | 15 +++++++++++++++ src/exporter/client.rs | 1 + src/exporter/client/global_only.rs | 1 + src/main.rs | 12 ++++++------ 7 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 prometheus.yml diff --git a/.gitignore b/.gitignore index 9eb96d7..ff2ac8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /target **/*.rs.bk .assets/cidrs.csv +data/ +.idea/ +.DS_Store diff --git a/Cargo.lock b/Cargo.lock index 4e62335..64ea45c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2127,16 +2127,16 @@ dependencies = [ [[package]] name = "prometheus" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5567486d5778e2c6455b1b90ff1c558f29e751fc018130fa182e15828e728af1" +checksum = "dd0ced56dee39a6e960c15c74dc48849d614586db2eaada6497477af7c7811cd" dependencies = [ "cfg-if", "fnv", "lazy_static", "protobuf", - "quick-error", "spin", + "thiserror", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f6e4c22..db9bbca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ libp2p = { git = "https://github.com/fluencelabs/rust-libp2p", branch = "trust_g libp2p-kad = { git = "https://github.com/fluencelabs/rust-libp2p", branch = "trust_graph_libp2p_git_fix" } trust-graph = { git = "https://github.com/fluencelabs/fluence", branch = "trust_graph_libp2p_git_fix" } log = "0.4.1" -prometheus = "0.7" +prometheus = "0.9.0" void = "1.0.2" tide = "0.6" exit-future = "0.2" @@ -29,6 +29,3 @@ serde = "1.0.110" # [patch."https://github.com/mxinden/rust-libp2p"] # libp2p = { path = "/home/mxinden/code/github.com/libp2p/rust-libp2p" } # libp2p-kad = { path = "/home/mxinden/code/github.com/libp2p/rust-libp2p/protocols/kad" } - -#[patch.crates-io] -#serde = { version = "1.0.110" } diff --git a/prometheus.yml b/prometheus.yml new file mode 100644 index 0000000..868472c --- /dev/null +++ b/prometheus.yml @@ -0,0 +1,15 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +rule_files: + # - "first.rules" + # - "second.rules" + +scrape_configs: + - job_name: prometheus + static_configs: + - targets: ['localhost:8080'] + +# histogram_quantile(0.95, sum(irate(kademlia_exporter_random_node_lookup_duration_bucket[10s])) by (le)) +# histogram_quantile(0.95, sum(rate(kademlia_exporter_ping_duration_bucket[5m])) by (le)) \ No newline at end of file diff --git a/src/exporter/client.rs b/src/exporter/client.rs index 97151a4..14b0708 100644 --- a/src/exporter/client.rs +++ b/src/exporter/client.rs @@ -239,6 +239,7 @@ pub fn build_transport_tcp( .timeout(socket_timeout) } +#[allow(dead_code)] fn build_transport(keypair: Keypair) -> Boxed<(PeerId, StreamMuxerBox), impl Error> { let tcp = tcp::TcpConfig::new().nodelay(true); // Ignore any non global IP addresses. Given the amount of private IP diff --git a/src/exporter/client/global_only.rs b/src/exporter/client/global_only.rs index 36cb192..a239b83 100644 --- a/src/exporter/client/global_only.rs +++ b/src/exporter/client/global_only.rs @@ -12,6 +12,7 @@ pub struct GlobalIpOnly { inner: T, } +#[allow(dead_code)] impl GlobalIpOnly { pub fn new(transport: T) -> Self { GlobalIpOnly { inner: transport } diff --git a/src/main.rs b/src/main.rs index 62c01da..3f9d758 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,12 +77,12 @@ fn main() -> Result<(), Box> { let mut buffer = vec![]; let encoder = TextEncoder::new(); let metric_families = req.state().gather(); - log::info!( - "Request {}: {} metrics: {:?}", - req.uri(), - metric_families.len(), - metric_families - ); + // log::info!( + // "Request {}: {} metrics: {:?}", + // req.uri(), + // metric_families.len(), + // metric_families + // ); encoder.encode(&metric_families, &mut buffer).unwrap(); String::from_utf8(buffer).unwrap()