Add prometheus config

This commit is contained in:
folex 2020-05-21 12:43:54 +03:00
parent df687fccc0
commit ec84f4b63e
7 changed files with 30 additions and 13 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
/target
**/*.rs.bk
.assets/cidrs.csv
data/
.idea/
.DS_Store

6
Cargo.lock generated
View File

@ -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]]

View File

@ -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" }

15
prometheus.yml Normal file
View File

@ -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))

View File

@ -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

View File

@ -12,6 +12,7 @@ pub struct GlobalIpOnly<T> {
inner: T,
}
#[allow(dead_code)]
impl<T> GlobalIpOnly<T> {
pub fn new(transport: T) -> Self {
GlobalIpOnly { inner: transport }

View File

@ -77,12 +77,12 @@ fn main() -> Result<(), Box<dyn Error>> {
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()