prometheus_manager/
lib.rs

1use std::{
2    collections::HashMap,
3    fs::{self, File},
4    io::{self, BufRead, BufReader, Error, ErrorKind, Write},
5    ops::Deref,
6    path::Path,
7    str::FromStr,
8};
9
10use chrono::{DateTime, TimeZone, Utc};
11use lazy_static::lazy_static;
12use regex::{Regex, RegexSet};
13use serde::{Deserialize, Serialize};
14
15// ref. https://github.com/cmars/prometheus-scrape/blob/master/src/lib.rs
16// ref. https://github.com/ccakes/prometheus-parse-rs/blob/master/src/lib.rs
17lazy_static! {
18    static ref HELP_RE: Regex = Regex::new(r"^#\s+HELP\s+(\w+)\s+(.+)$").unwrap();
19    static ref TYPE_RE: Regex = Regex::new(r"^#\s+TYPE\s+(\w+)\s+(\w+)").unwrap();
20    static ref METRIC_RE: Regex = Regex::new(
21        r"^(?P<name>\w+)(\{(?P<labels>[^}]+)\})?\s+(?P<value>\S+)(\s+(?P<timestamp>\S+))?"
22    )
23    .unwrap();
24}
25
26#[derive(Debug, Eq, PartialEq)]
27pub enum Entry<'a> {
28    Doc {
29        metric_name: &'a str,
30        doc: &'a str,
31    },
32    Type {
33        metric_name: String,
34        sample_type: MetricKind,
35    },
36    Metric {
37        metric_name: &'a str,
38        labels: Option<&'a str>,
39        value: &'a str,
40        timestamp: Option<&'a str>,
41    },
42    Empty,
43    Ignored,
44}
45
46#[derive(Debug, Eq, PartialEq, Clone, Copy)]
47pub enum MetricKind {
48    Counter,
49    Gauge,
50    Histogram,
51    Summary,
52    Untyped,
53}
54
55/// ref. https://doc.rust-lang.org/std/str/trait.FromStr.html
56impl FromStr for MetricKind {
57    type Err = Error;
58    fn from_str(s: &str) -> Result<Self, Self::Err> {
59        let decoded = match s {
60            "counter" => MetricKind::Counter,
61            "gauge" => MetricKind::Gauge,
62            "histogram" => MetricKind::Histogram,
63            "summary" => MetricKind::Summary,
64            _ => MetricKind::Untyped,
65        };
66        Ok(decoded)
67    }
68}
69
70impl<'a> Entry<'a> {
71    pub fn parse_line(line: &'a str) -> Entry<'a> {
72        let line = line.trim();
73        if line.is_empty() {
74            return Entry::Empty;
75        }
76
77        if let Some(ref caps) = HELP_RE.captures(line) {
78            return match (caps.get(1), caps.get(2)) {
79                (Some(ref metric_name), Some(ref doc)) => Entry::Doc {
80                    metric_name: metric_name.as_str(),
81                    doc: doc.as_str(),
82                },
83                _ => Entry::Ignored,
84            };
85        }
86
87        if let Some(ref caps) = TYPE_RE.captures(line) {
88            return match (caps.get(1), caps.get(2)) {
89                (Some(ref metric_name), Some(ref sample_type)) => {
90                    let sample_type = MetricKind::from_str(sample_type.as_str()).unwrap();
91                    Entry::Type {
92                        metric_name: match sample_type {
93                            MetricKind::Histogram => format!("{}_bucket", metric_name.as_str()),
94                            _ => metric_name.as_str().to_string(),
95                        },
96                        sample_type,
97                    }
98                }
99                _ => Entry::Ignored,
100            };
101        }
102
103        if let Some(ref caps) = METRIC_RE.captures(line) {
104            return match (
105                caps.name("name"),
106                caps.name("labels"),
107                caps.name("value"),
108                caps.name("timestamp"),
109            ) {
110                (Some(ref name), labels, Some(ref value), timestamp) => Entry::Metric {
111                    metric_name: name.as_str(),
112                    labels: labels.map(|c| c.as_str()),
113                    value: value.as_str(),
114                    timestamp: timestamp.map(|c| c.as_str()),
115                },
116                _ => Entry::Ignored,
117            };
118        } else {
119            Entry::Ignored
120        }
121    }
122}
123
124/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_lineinfo_parse --exact --show-output
125#[test]
126fn test_lineinfo_parse() {
127    assert_eq!(
128        Entry::parse_line("foo 2"),
129        Entry::Metric {
130            metric_name: "foo",
131            value: "2",
132            labels: None,
133            timestamp: None,
134        }
135    );
136    assert_eq!(
137        Entry::parse_line("foo wtf -1"),
138        Entry::Metric {
139            metric_name: "foo",
140            value: "wtf",
141            labels: None,
142            timestamp: Some("-1"),
143        }
144    );
145    assert_eq!(Entry::parse_line("foo=2"), Entry::Ignored,);
146    assert_eq!(
147        Entry::parse_line("foo 2 1543182234"),
148        Entry::Metric {
149            metric_name: "foo",
150            value: "2",
151            labels: None,
152            timestamp: Some("1543182234"),
153        }
154    );
155    assert_eq!(
156        Entry::parse_line("foo{bar=baz} 2 1543182234"),
157        Entry::Metric {
158            metric_name: "foo",
159            value: "2",
160            labels: Some("bar=baz"),
161            timestamp: Some("1543182234"),
162        }
163    );
164    assert_eq!(
165        Entry::parse_line("foo{bar=baz,quux=nonce} 2 1543182234"),
166        Entry::Metric {
167            metric_name: "foo",
168            value: "2",
169            labels: Some("bar=baz,quux=nonce"),
170            timestamp: Some("1543182234"),
171        }
172    );
173    assert_eq!(
174        Entry::parse_line("# HELP foo this is a docstring"),
175        Entry::Doc {
176            metric_name: "foo",
177            doc: "this is a docstring"
178        },
179    );
180    assert_eq!(
181        Entry::parse_line("# TYPE foobar bazquux"),
182        Entry::Type {
183            metric_name: "foobar".to_string(),
184            sample_type: MetricKind::Untyped,
185        },
186    );
187}
188
189#[derive(Debug, PartialEq, Clone)]
190pub struct Metric {
191    pub metric: String,
192    pub value: Value,
193    pub labels: Option<Labels>,
194    pub timestamp: Option<DateTime<Utc>>,
195}
196
197impl Default for Metric {
198    fn default() -> Self {
199        Self::default()
200    }
201}
202
203impl Metric {
204    pub fn default() -> Self {
205        Self {
206            metric: String::new(),
207            value: Value::Untyped(0.0),
208            labels: None,
209            timestamp: None,
210        }
211    }
212
213    /// Stringify the metric name with labels (if any).
214    pub fn name_with_labels(&self) -> String {
215        if let Some(labels) = &self.labels {
216            let mut pairs: Vec<String> = Vec::with_capacity(labels.len());
217            for (k, v) in labels.iter() {
218                pairs.push(format!("{}_{}", k.replace(' ', ""), v.replace(' ', "")));
219            }
220            // sort in lexicographic increasing order
221            pairs.sort();
222            format!("{}_{}", self.metric, pairs.join("_"))
223        } else {
224            self.metric.clone()
225        }
226    }
227}
228
229/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_metric_name_with_labels --exact --show-output
230#[test]
231fn test_metric_name_with_labels() {
232    assert_eq!(
233        "http_requests_total",
234        &Metric {
235            metric: "http_requests_total".to_string(),
236            ..Default::default()
237        }
238        .name_with_labels(),
239    );
240    assert_eq!(
241        "http_requests_total_code_400_method_post",
242        &Metric {
243            metric: "http_requests_total".to_string(),
244            labels: Some(Labels(
245                [("method", "post"), ("code", "400")]
246                    .iter()
247                    .map(pair_to_string)
248                    .collect()
249            )),
250            ..Default::default()
251        }
252        .name_with_labels(),
253    );
254    assert_eq!(
255        "http_requests_total_code_400_method_postpost",
256        &Metric {
257            metric: "http_requests_total".to_string(),
258            labels: Some(Labels(
259                [("method", "post    post"), ("code", "400")]
260                    .iter()
261                    .map(pair_to_string)
262                    .collect()
263            )),
264            ..Default::default()
265        }
266        .name_with_labels(),
267    );
268}
269
270fn parse_bucket(s: &str, label: &str) -> Option<f64> {
271    if let Some(kv) = s.split(',').next() {
272        let kvpair = kv.split('=').collect::<Vec<_>>();
273        let (k, v) = (kvpair[0], kvpair[1].trim_matches('"'));
274        if k == label {
275            match parse_golang_float(v) {
276                Ok(v) => Some(v),
277                Err(_) => None,
278            }
279        } else {
280            None
281        }
282    } else {
283        None
284    }
285}
286
287#[derive(Debug, PartialEq, Clone)]
288pub struct HistogramCount {
289    pub less_than: f64,
290    pub count: f64,
291}
292
293#[derive(Debug, PartialEq, Clone)]
294pub struct SummaryCount {
295    pub quantile: f64,
296    pub count: f64,
297}
298
299#[derive(Debug, Eq, PartialEq, Clone)]
300pub struct Labels(HashMap<String, String>);
301
302impl Labels {
303    fn from_str(s: &str) -> Labels {
304        let mut l = HashMap::new();
305        for kv in s.split(',') {
306            let kvpair = kv.split('=').collect::<Vec<_>>();
307            if kvpair.len() != 2 || kvpair[0].is_empty() {
308                continue;
309            }
310            l.insert(
311                kvpair[0].to_string(),
312                kvpair[1].trim_matches('"').to_string(),
313            );
314        }
315        Labels(l)
316    }
317
318    pub fn get(&self, name: &str) -> Option<&str> {
319        self.0.get(name).map(|x| x.as_str())
320    }
321}
322
323impl Deref for Labels {
324    type Target = HashMap<String, String>;
325
326    fn deref(&self) -> &Self::Target {
327        &self.0
328    }
329}
330
331/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_labels_parse --exact --show-output
332#[test]
333fn test_labels_parse() {
334    assert_eq!(
335        Labels::from_str("foo=bar"),
336        Labels([("foo", "bar")].iter().map(pair_to_string).collect())
337    );
338    assert_eq!(
339        Labels::from_str("foo=bar,"),
340        Labels([("foo", "bar")].iter().map(pair_to_string).collect())
341    );
342    assert_eq!(
343        Labels::from_str(",foo=bar,"),
344        Labels([("foo", "bar")].iter().map(pair_to_string).collect())
345    );
346    assert_eq!(
347        Labels::from_str("=,foo=bar,"),
348        Labels([("foo", "bar")].iter().map(pair_to_string).collect())
349    );
350    assert_eq!(
351        Labels::from_str(r#"foo="bar""#),
352        Labels([("foo", "bar")].iter().map(pair_to_string).collect())
353    );
354    assert_eq!(
355        Labels::from_str(r#"foo="bar",baz="quux""#),
356        Labels(
357            [("foo", "bar"), ("baz", "quux")]
358                .iter()
359                .map(pair_to_string)
360                .collect()
361        )
362    );
363    assert_eq!(
364        Labels::from_str(r#"foo="foo bar",baz="baz quux""#),
365        Labels(
366            [("foo", "foo bar"), ("baz", "baz quux")]
367                .iter()
368                .map(pair_to_string)
369                .collect()
370        )
371    );
372    assert_eq!(Labels::from_str("==="), Labels(HashMap::new()),);
373}
374
375#[derive(Debug, PartialEq, Clone)]
376pub enum Value {
377    Counter(f64),
378    Gauge(f64),
379    Histogram(Vec<HistogramCount>),
380    Summary(Vec<SummaryCount>),
381    Untyped(f64),
382}
383
384impl Value {
385    pub fn to_f64(&self) -> f64 {
386        match self {
387            Value::Counter(v) => *v,
388            Value::Gauge(v) => *v,
389            Value::Untyped(v) => *v,
390
391            // TODO: fix this
392            Value::Histogram(_) => 0.0,
393            Value::Summary(_) => 0.0,
394        }
395    }
396
397    fn push_histogram(&mut self, h: HistogramCount) {
398        if let &mut Value::Histogram(ref mut hs) = self {
399            hs.push(h)
400        }
401    }
402
403    fn push_summary(&mut self, s: SummaryCount) {
404        if let &mut Value::Summary(ref mut ss) = self {
405            ss.push(s)
406        }
407    }
408}
409
410#[derive(Debug)]
411pub struct Scrape {
412    pub docs: HashMap<String, String>,
413    pub metrics: Vec<Metric>,
414}
415
416impl Scrape {
417    pub fn from_bytes(d: &[u8]) -> io::Result<Self> {
418        log::info!("scraping {} bytes", human_readable::bytes(d.len() as f64));
419        let br = BufReader::new(d);
420        Self::parse(br.lines())
421    }
422
423    pub fn parse(lines: impl Iterator<Item = io::Result<String>>) -> io::Result<Self> {
424        let mut docs: HashMap<String, String> = HashMap::new();
425        let mut types: HashMap<String, MetricKind> = HashMap::new();
426        let mut buckets: HashMap<String, Metric> = HashMap::new();
427        let mut metrics: Vec<Metric> = vec![];
428        for line in lines {
429            let cur = match line {
430                Ok(v) => v,
431                Err(e) => return Err(e),
432            };
433
434            match Entry::parse_line(&cur) {
435                Entry::Doc {
436                    ref metric_name,
437                    ref doc,
438                } => {
439                    docs.insert(metric_name.to_string(), doc.to_string());
440                }
441                Entry::Type {
442                    ref metric_name,
443                    ref sample_type,
444                } => {
445                    types.insert(metric_name.to_string(), *sample_type);
446                }
447                Entry::Metric {
448                    metric_name,
449                    ref labels,
450                    value,
451                    timestamp,
452                } => {
453                    // Parse value or skip
454                    let fvalue = if let Ok(v) = parse_golang_float(value) {
455                        v
456                    } else {
457                        continue;
458                    };
459                    // Parse timestamp or use given sample time
460                    let timestamp = if let Some(Ok(ts_millis)) = timestamp.map(|x| x.parse::<i64>())
461                    {
462                        Some(Utc.timestamp_millis_opt(ts_millis).unwrap())
463                    } else {
464                        None
465                    };
466                    match (types.get(metric_name), labels) {
467                        (Some(MetricKind::Histogram), Some(labels)) => {
468                            if let Some(lt) = parse_bucket(labels, "le") {
469                                let sample =
470                                    buckets.entry(metric_name.to_string()).or_insert(Metric {
471                                        metric: metric_name.to_string(),
472                                        labels: None,
473                                        value: Value::Histogram(vec![]),
474                                        timestamp,
475                                    });
476                                sample.value.push_histogram(HistogramCount {
477                                    less_than: lt,
478                                    count: fvalue,
479                                })
480                            }
481                        }
482                        (Some(MetricKind::Summary), Some(labels)) => {
483                            if let Some(q) = parse_bucket(labels, "quantile") {
484                                let sample =
485                                    buckets.entry(metric_name.to_string()).or_insert(Metric {
486                                        metric: metric_name.to_string(),
487                                        labels: None,
488                                        value: Value::Summary(vec![]),
489                                        timestamp,
490                                    });
491                                sample.value.push_summary(SummaryCount {
492                                    quantile: q,
493                                    count: fvalue,
494                                })
495                            }
496                        }
497                        (ty, labels) => {
498                            let labels = {
499                                if labels.is_some() {
500                                    Some(Labels::from_str(labels.unwrap()))
501                                } else {
502                                    None
503                                }
504                            };
505                            metrics.push(Metric {
506                                metric: metric_name.to_string(),
507                                labels,
508                                value: match ty {
509                                    Some(MetricKind::Counter) => Value::Counter(fvalue),
510                                    Some(MetricKind::Gauge) => Value::Gauge(fvalue),
511                                    _ => Value::Untyped(fvalue),
512                                },
513                                timestamp,
514                            });
515                        }
516                    };
517                }
518                _ => {}
519            }
520        }
521        metrics.extend(buckets.drain().map(|(_k, v)| v).collect::<Vec<_>>());
522        Ok(Scrape { docs, metrics })
523    }
524}
525
526lazy_static! {
527    static ref NOT_FOUND_METRIC: Metric = Metric {
528        metric: "not_found".to_string(),
529        value: Value::Gauge(0.0),
530        ..Default::default()
531    };
532}
533
534/// Returns the first metric that evaluates to "true" for the function.
535pub fn find_first<'a, F>(data: &'a [Metric], f: F) -> &'a Metric
536where
537    for<'r> F: FnMut(&'r &'a Metric) -> bool,
538{
539    let metric = data.iter().find(f);
540    if let Some(v) = metric {
541        return v;
542    }
543    &NOT_FOUND_METRIC
544}
545
546/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_find_first --exact --show-output
547#[test]
548fn test_find_first() {
549    let _ = env_logger::builder()
550        .filter_level(log::LevelFilter::Debug)
551        .is_test(true)
552        .try_init();
553
554    let scrape = r#"
555# HELP http_requests_total The total number of HTTP requests.
556# TYPE http_requests_total counter
557http_requests_total{method="post",code="200"} 1027 1395066363000
558http_requests_total{method="post",code="400"}    3 1395066363000
559
560# Escaping in label values:
561msdos_file_access_time_seconds{path="C:\\DIR\\FILE.TXT",error="Cannot find file:\n\"FILE.TXT\""} 1.458255915e9
562
563# Minimalistic line:
564metric_without_timestamp_and_labels 12.47
565
566# TYPE metric_counter_with_no_label counter
567metric_counter_with_no_label 100.10
568
569# A weird metric from before the epoch:
570something_weird{problem="division by zero"} +Inf -3982045
571
572# A histogram, which has a pretty complex representation in the text format:
573# HELP http_request_duration_seconds A histogram of the request duration.
574# TYPE http_request_duration_seconds histogram
575http_request_duration_seconds_bucket{le="0.05"} 24054
576http_request_duration_seconds_bucket{le="0.1"} 33444
577http_request_duration_seconds_bucket{le="0.2"} 100392
578http_request_duration_seconds_bucket{le="0.5"} 129389
579http_request_duration_seconds_bucket{le="1"} 133988
580http_request_duration_seconds_bucket{le="+Inf"} 144320
581http_request_duration_seconds_sum 53423
582http_request_duration_seconds_count 144320
583
584# Finally a summary, which has a complex representation, too:
585# HELP rpc_duration_seconds A summary of the RPC duration in seconds.
586# TYPE rpc_duration_seconds summary
587rpc_duration_seconds{quantile="0.01"} 3102
588rpc_duration_seconds{quantile="0.05"} 3272
589rpc_duration_seconds{quantile="0.5"} 4773
590rpc_duration_seconds{quantile="0.9"} 9001
591rpc_duration_seconds{quantile="0.99"} 76656
592rpc_duration_seconds_sum 1.7560473e+07
593rpc_duration_seconds_count 2693
594
595# TYPE avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_size_sum gauge
596avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_size_sum 441892
597# HELP avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_sum Sum of time (in ns) of a has
598# TYPE avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_sum gauge
599avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_sum 4.50437507e+08
600"#;
601
602    let s = Scrape::from_bytes(scrape.as_bytes()).unwrap();
603    assert_eq!(s.metrics.len(), 14);
604
605    assert_eq!(
606        find_first(&s.metrics, |s| s.metric
607            == "metric_without_timestamp_and_labels"),
608        &Metric {
609            metric: "metric_without_timestamp_and_labels".to_string(),
610            value: Value::Untyped(12.47),
611            ..Default::default()
612        }
613    );
614
615    assert_eq!(
616        find_first(&s.metrics, |s| s.metric == "metric_counter_with_no_label"),
617        &Metric {
618            metric: "metric_counter_with_no_label".to_string(),
619            value: Value::Counter(100.10),
620            ..Default::default()
621        }
622    );
623
624    assert_eq!(
625        find_first(&s.metrics, |s| s.metric == "http_requests_total"
626            && s.labels.clone().unwrap().get("code") == Some("200")),
627        &Metric {
628            metric: "http_requests_total".to_string(),
629            value: Value::Counter(1027f64),
630            labels: Some(Labels(
631                [("method", "post"), ("code", "200")]
632                    .iter()
633                    .map(pair_to_string)
634                    .collect()
635            )),
636            timestamp: Some(Utc.timestamp_millis_opt(1395066363000).unwrap()),
637        }
638    );
639
640    assert_eq!(
641        find_first(&s.metrics, |s| s.metric == "http_requests_total"
642            && s.labels.clone().unwrap().get("code") == Some("400")),
643        &Metric {
644            metric: "http_requests_total".to_string(),
645            value: Value::Counter(3f64),
646            labels: Some(Labels(
647                [("method", "post"), ("code", "400")]
648                    .iter()
649                    .map(pair_to_string)
650                    .collect()
651            )),
652            timestamp: Some(Utc.timestamp_millis_opt(1395066363000).unwrap()),
653        }
654    );
655
656    assert_eq!(
657        find_first(&s.metrics, |s| {
658            s.metric
659                == "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_size_sum"
660        }),
661        &Metric {
662            metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_size_sum"
663                .to_string(),
664            value: Value::Gauge(441892f64),
665            ..Default::default()
666        }
667    );
668
669    assert_eq!(
670        find_first(&s.metrics, |s| {
671            s.metric == "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_sum"
672        }),
673        &Metric {
674            metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_has_sum"
675                .to_string(),
676            value: Value::Gauge(4.50437507e+08f64),
677            ..Default::default()
678        }
679    );
680}
681
682/// Returns all metrics that evaluate to "true" for the function.
683pub fn find_all<'a, F>(data: &'a [Metric], f: F) -> Vec<&'a Metric>
684where
685    for<'r> F: FnMut(&'r &'a Metric) -> bool,
686{
687    let mut metrics: Vec<&'a Metric> = Vec::new();
688
689    let mut iter = data.iter().filter(f);
690    loop {
691        let metric = iter.next();
692        if let Some(v) = metric {
693            metrics.push(v);
694            continue;
695        }
696        break;
697    }
698
699    metrics
700}
701
702/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_find_all --exact --show-output
703#[test]
704fn test_find_all() {
705    use rust_embed::RustEmbed;
706
707    let _ = env_logger::builder()
708        .filter_level(log::LevelFilter::Debug)
709        .is_test(true)
710        .try_init();
711
712    #[derive(RustEmbed)]
713    #[folder = "artifacts/"]
714    #[prefix = "artifacts/"]
715    struct Asset;
716
717    let metrics_raw = Asset::get("artifacts/avalanchego.metrics").unwrap();
718    let metrics_raw = std::str::from_utf8(metrics_raw.data.as_ref()).unwrap();
719
720    let s = Scrape::from_bytes(metrics_raw.as_bytes()).unwrap();
721    assert_eq!(s.metrics.len(), 2140);
722
723    assert_eq!(
724        find_all(&s.metrics, |s| s.metric.contains(
725            "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_size_",
726        )),
727        vec![
728            &Metric {
729                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_size_count"
730                    .to_string(),
731                value: Value::Counter(7.469948e+06f64),
732                ..Default::default()
733            },
734            &Metric {
735                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_size_sum"
736                    .to_string(),
737                value: Value::Gauge(2.1210190212e+10f64),
738                ..Default::default()
739            },
740        ]
741    );
742}
743
744/// Returns all metrics that evaluate to "true" for the regex on the metrics name, not the label.
745/// If called in a loop, use "lazy_static" to ensure that regular expressions
746/// are compiled exactly once.
747/// ref. https://github.com/rust-lang/regex#usage-avoid-compiling-the-same-regex-in-a-loop
748pub fn match_all_by_regex(data: &[Metric], re: Regex) -> Vec<&Metric> {
749    log::debug!("matching all metrics by regex {} on the name", re);
750    find_all(data, |s| re.is_match(s.metric.as_str()))
751}
752
753/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_match_all_by_regex --exact --show-output
754#[test]
755fn test_match_all_by_regex() {
756    use rust_embed::RustEmbed;
757
758    let _ = env_logger::builder()
759        .filter_level(log::LevelFilter::Debug)
760        .is_test(true)
761        .try_init();
762
763    #[derive(RustEmbed)]
764    #[folder = "artifacts/"]
765    #[prefix = "artifacts/"]
766    struct Asset;
767
768    let metrics_raw = Asset::get("artifacts/avalanchego.metrics").unwrap();
769    let metrics_raw = std::str::from_utf8(metrics_raw.data.as_ref()).unwrap();
770
771    let s = Scrape::from_bytes(metrics_raw.as_bytes()).unwrap();
772    assert_eq!(s.metrics.len(), 2140);
773
774    let re = Regex::new(r"^avalanche_(([0-9a-zA-Z]+)+){3,}_db_batch_put_size[\s\S]*$").unwrap();
775    assert_eq!(
776        match_all_by_regex(&s.metrics, re),
777        vec![
778            &Metric {
779                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_size_count"
780                    .to_string(),
781                value: Value::Counter(7.469948e+06f64),
782                ..Default::default()
783            },
784            &Metric {
785                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_size_sum"
786                    .to_string(),
787                value: Value::Gauge(2.1210190212e+10f64),
788                ..Default::default()
789            },
790        ]
791    );
792}
793
794/// Returns all metrics that evaluate to "true" for the regex set on the metrics name, not the label.
795/// If called in a loop, use "lazy_static" to ensure that regular expressions
796/// are compiled exactly once.
797/// ref. https://github.com/rust-lang/regex#usage-avoid-compiling-the-same-regex-in-a-loop
798pub fn match_all_by_regex_set(data: &[Metric], rset: RegexSet) -> Vec<&Metric> {
799    log::debug!("matching all metrics by regex set {:?} on the name", rset);
800    find_all(data, |s| rset.is_match(s.metric.as_str()))
801}
802
803/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_match_all_by_regex_set --exact --show-output
804#[test]
805fn test_match_all_by_regex_set() {
806    use rust_embed::RustEmbed;
807
808    let _ = env_logger::builder()
809        .filter_level(log::LevelFilter::Debug)
810        .is_test(true)
811        .try_init();
812
813    #[derive(RustEmbed)]
814    #[folder = "artifacts/"]
815    #[prefix = "artifacts/"]
816    struct Asset;
817
818    let metrics_raw = Asset::get("artifacts/avalanchego.metrics").unwrap();
819    let metrics_raw = std::str::from_utf8(metrics_raw.data.as_ref()).unwrap();
820
821    let s = Scrape::from_bytes(metrics_raw.as_bytes()).unwrap();
822    assert_eq!(s.metrics.len(), 2140);
823
824    lazy_static! {
825        static ref REGEXES: Vec<String> = vec![
826            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_blks_accepted[\s\S]*$".to_string(),
827            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_blks_built$".to_string(),
828            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_blks_rejected[\s\S]*$".to_string(),
829            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_db_batch_put_count$".to_string(),
830            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_db_batch_put_sum$".to_string(),
831            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_last_accepted_height$".to_string(),
832            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_vm_eth_rpc_failure$".to_string(),
833            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_vm_eth_rpc_requests$".to_string(),
834            r"^avalanche_(([0-9a-zA-Z]+)+){40,}_vm_eth_rpc_success$".to_string(),
835            r"^avalanche_[C|P|X]_benchlist_benched_num$".to_string(),
836            r"^avalanche_[C|P]_blks_accepted[\s\S]*$".to_string(),
837            r"^avalanche_[C|P]_blks_accepted[\s\S]*$".to_string(),
838            r"^avalanche_[C|P|X]_db_get_count$".to_string(),
839            r"^avalanche_[C|P|X]_db_read_size_sum$".to_string(),
840            r"^avalanche_[C|P|X]_db_write_size_sum$".to_string(),
841            r"^avalanche_[C|P|X]_polls_[\s\S]*$".to_string(),
842            r"^avalanche_X_(avalanche|snowman)_polls_[\s\S]*$".to_string(),
843        ];
844    }
845
846    let rset = RegexSet::new(REGEXES.to_vec()).unwrap();
847    assert_eq!(
848        match_all_by_regex_set(&s.metrics, rset),
849        vec![
850            &Metric {
851                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_accepted_count"
852                    .to_string(),
853                value: Value::Counter(43240f64),
854                ..Default::default()
855            },
856            &Metric {
857                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_accepted_sum"
858                    .to_string(),
859                value: Value::Gauge(9.81317938649e+11f64),
860                ..Default::default()
861            },
862            &Metric {
863                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_built"
864                    .to_string(),
865                value: Value::Counter(4205f64),
866                ..Default::default()
867            },
868            &Metric {
869                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_rejected_count"
870                    .to_string(),
871                value: Value::Counter(3f64),
872                ..Default::default()
873            },
874            &Metric {
875                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_rejected_sum"
876                    .to_string(),
877                value: Value::Gauge(3.8554338e+07f64),
878                ..Default::default()
879            },
880            &Metric {
881                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_count"
882                    .to_string(),
883                value: Value::Counter(7.469948e+06f64),
884                ..Default::default()
885            },
886            &Metric {
887                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_sum"
888                    .to_string(),
889                value: Value::Gauge(5.357270217e+09f64),
890                ..Default::default()
891            },
892            &Metric {
893                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_last_accepted_height"
894                    .to_string(),
895                value: Value::Gauge(43240f64),
896                ..Default::default()
897            },
898            &Metric {
899                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_rpc_failure"
900                    .to_string(),
901                value: Value::Gauge(0f64),
902                ..Default::default()
903            },
904            &Metric {
905                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_rpc_requests"
906                    .to_string(),
907                value: Value::Gauge(4.307051e+06f64),
908                ..Default::default()
909            },
910            &Metric {
911                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_rpc_success"
912                    .to_string(),
913                value: Value::Gauge(4.307051e+06f64),
914                ..Default::default()
915            },
916            &Metric {
917                metric: "avalanche_C_benchlist_benched_num"
918                    .to_string(),
919                value: Value::Gauge(0f64),
920                ..Default::default()
921            },
922            &Metric {
923                metric: "avalanche_C_blks_accepted_count"
924                    .to_string(),
925                value: Value::Counter(27f64),
926                ..Default::default()
927            },
928            &Metric {
929                metric: "avalanche_C_blks_accepted_sum"
930                    .to_string(),
931                value: Value::Gauge(1.62497901e+08f64),
932                ..Default::default()
933            },
934            &Metric {
935                metric: "avalanche_C_db_get_count"
936                    .to_string(),
937                value: Value::Counter(37607f64),
938                ..Default::default()
939            },
940            &Metric {
941                metric: "avalanche_C_db_read_size_sum"
942                    .to_string(),
943                value: Value::Gauge(2.689728e+06f64),
944                ..Default::default()
945            },
946            &Metric {
947                metric: "avalanche_C_db_write_size_sum"
948                    .to_string(),
949                value: Value::Gauge(396119f64),
950                ..Default::default()
951            },
952            &Metric {
953                metric: "avalanche_C_polls_failed"
954                    .to_string(),
955                value: Value::Counter(0f64),
956                ..Default::default()
957            },
958            &Metric {
959                metric: "avalanche_C_polls_successful"
960                    .to_string(),
961                value: Value::Counter(420f64),
962                ..Default::default()
963            },
964            &Metric {
965                metric: "avalanche_P_benchlist_benched_num"
966                    .to_string(),
967                value: Value::Gauge(0f64),
968                ..Default::default()
969            },
970            &Metric {
971                metric: "avalanche_P_blks_accepted_count"
972                    .to_string(),
973                value: Value::Counter(39f64),
974                ..Default::default()
975            },
976            &Metric {
977                metric: "avalanche_P_blks_accepted_sum"
978                    .to_string(),
979                value: Value::Gauge(4.30488494e+08f64),
980                ..Default::default()
981            },
982            &Metric {
983                metric: "avalanche_P_db_get_count"
984                    .to_string(),
985                value: Value::Counter(212f64),
986                ..Default::default()
987            },
988            &Metric {
989                metric: "avalanche_P_db_read_size_sum"
990                    .to_string(),
991                value: Value::Gauge(30726f64),
992                ..Default::default()
993            },
994            &Metric {
995                metric: "avalanche_P_db_write_size_sum"
996                    .to_string(),
997                value: Value::Gauge(78865f64),
998                ..Default::default()
999            },
1000            &Metric {
1001                metric: "avalanche_P_polls_failed"
1002                    .to_string(),
1003                value: Value::Counter(7f64),
1004                ..Default::default()
1005            },
1006            &Metric {
1007                metric: "avalanche_P_polls_successful"
1008                    .to_string(),
1009                value: Value::Counter(403f64),
1010                ..Default::default()
1011            },
1012            &Metric {
1013                metric: "avalanche_X_benchlist_benched_num"
1014                    .to_string(),
1015                value: Value::Gauge(0f64),
1016                ..Default::default()
1017            },
1018            &Metric {
1019                metric: "avalanche_X_db_get_count"
1020                    .to_string(),
1021                value: Value::Counter(7f64),
1022                ..Default::default()
1023            },
1024            &Metric {
1025                metric: "avalanche_X_db_read_size_sum"
1026                    .to_string(),
1027                value: Value::Gauge(507f64),
1028                ..Default::default()
1029            },
1030            &Metric {
1031                metric: "avalanche_X_db_write_size_sum"
1032                    .to_string(),
1033                value: Value::Gauge(0f64),
1034                ..Default::default()
1035            },
1036            &Metric {
1037                metric: "avalanche_X_avalanche_polls_failed"
1038                    .to_string(),
1039                value: Value::Counter(0f64),
1040                ..Default::default()
1041            },
1042            &Metric {
1043                metric: "avalanche_X_avalanche_polls_successful"
1044                    .to_string(),
1045                value: Value::Counter(0f64),
1046                ..Default::default()
1047            },
1048        ]
1049    );
1050}
1051
1052impl Rules {
1053    /// Loads the "Rules" from the file.
1054    pub fn load(file_path: &str) -> io::Result<Rules> {
1055        log::info!("loading Rules from {}", file_path);
1056
1057        if !Path::new(file_path).exists() {
1058            return Err(Error::new(
1059                ErrorKind::NotFound,
1060                format!("file {} does not exists", file_path),
1061            ));
1062        }
1063
1064        let f = File::open(&file_path).map_err(|e| {
1065            Error::new(
1066                ErrorKind::Other,
1067                format!("failed to open {} ({})", file_path, e),
1068            )
1069        })?;
1070        serde_yaml::from_reader(f)
1071            .map_err(|e| Error::new(ErrorKind::InvalidInput, format!("invalid YAML: {e}")))
1072    }
1073
1074    /// Syncs the "Rules" to the file.
1075    pub fn sync(&self, file_path: &str) -> io::Result<()> {
1076        log::info!("syncing rules to '{file_path}'");
1077        let path = Path::new(file_path);
1078        if let Some(parent_dir) = path.parent() {
1079            log::info!("creating parent dir '{}'", parent_dir.display());
1080            fs::create_dir_all(parent_dir)?;
1081        }
1082
1083        let ret = serde_yaml::to_string(self);
1084        let d = match ret {
1085            Ok(d) => d,
1086            Err(e) => {
1087                return Err(Error::new(
1088                    ErrorKind::Other,
1089                    format!("failed to serialize Node to YAML {e}"),
1090                ));
1091            }
1092        };
1093        let mut f = File::create(file_path)?;
1094        f.write_all(d.as_bytes())?;
1095
1096        return Ok(());
1097    }
1098}
1099
1100/// Represents metrics matching rules.
1101#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
1102#[serde(rename_all = "snake_case")]
1103pub struct Rules {
1104    /// The matching rule is "OR", not "AND".
1105    /// Returns all metrics that at least satisfy one rule.
1106    pub filters: Vec<Filter>,
1107    //
1108    // TODO:
1109    // Simple division math rule on the matched metrics.
1110    // Metric name supports regex but expects exact match except the chain name.
1111    // #[serde(skip_serializing_if = "Option::is_none")]
1112    // pub divides: Option<Vec<Divide>>,
1113}
1114
1115/// Represents the metric filter.
1116#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
1117#[serde(rename_all = "snake_case")]
1118pub struct Filter {
1119    pub regex: String,
1120
1121    #[serde(skip_serializing_if = "Option::is_none")]
1122    pub labels: Option<HashMap<String, String>>,
1123}
1124
1125/// Returns all metrics that evaluate to "true" based on the rules.
1126/// If no filter has a label specified, it uses `RegexSet` for all regexes.
1127/// TODO: optimize using more RegexSet without labels...
1128/// TODO: Support delta-based divides.
1129pub fn apply_rules(data: &[Metric], rules: Rules) -> io::Result<Vec<&Metric>> {
1130    // compile regexes in advance
1131    // so we don't compile multiple times for each iteration
1132    let mut regexes: Vec<Regex> = Vec::with_capacity(rules.filters.len());
1133    let mut labels_exist = false;
1134    for r in &rules.filters {
1135        let regex = Regex::new(r.regex.as_str()).map_err(|e| {
1136            Error::new(
1137                ErrorKind::Other,
1138                format!("failed to create regex {} ({})", r.regex, e),
1139            )
1140        })?;
1141        regexes.push(regex);
1142
1143        if r.labels.is_some() {
1144            labels_exist = true;
1145        }
1146    }
1147    log::debug!(
1148        "matching all metrics by {} rules (labels exist {})",
1149        rules.filters.len(),
1150        labels_exist
1151    );
1152
1153    let found = if labels_exist {
1154        find_all(data, |s| {
1155            // iterate every rule in sequence until it finds something that matches
1156            for (idx, r) in rules.filters.iter().enumerate() {
1157                let regex = &regexes[idx];
1158
1159                let regex_matched = regex.is_match(&s.metric);
1160                if !regex_matched {
1161                    // regex does not match, so no need to check further with labels
1162                    // retry with next rule
1163                    continue;
1164                }
1165
1166                let matched = if let Some(label_rules) = &r.labels {
1167                    // regex matches but labels exist, so need more label checks
1168                    let mut label_rules_matched = true;
1169
1170                    // check against the incoming metric labels
1171                    if let Some(current_labels) = &s.labels {
1172                        for (k, v) in label_rules.iter() {
1173                            if let Some(found_value) = current_labels.get(k) {
1174                                if !found_value.eq(v) {
1175                                    // label matches are exact
1176                                    // even one missing label evaluates the whole check to be false
1177                                    label_rules_matched = false;
1178                                    break;
1179                                }
1180                                continue;
1181                            }
1182
1183                            // expected label is not found in this metric, so no match
1184                            // no need to check other labels
1185                            label_rules_matched = false;
1186                            break;
1187                        }
1188                    } else {
1189                        // the current metric has no label
1190                        label_rules_matched = false;
1191                    }
1192
1193                    label_rules_matched
1194                } else {
1195                    // regex matches and this rule does not have any label
1196                    true
1197                };
1198                if matched {
1199                    // this rule matches, so no need to continue on the next rule
1200                    return true;
1201                }
1202            }
1203            false
1204        })
1205    } else {
1206        let regexes: Vec<String> = rules.filters.iter().map(|f| f.regex.clone()).collect();
1207        let reset = RegexSet::new(regexes).map_err(|e| {
1208            Error::new(
1209                ErrorKind::Other,
1210                format!("failed to create regex set for the rules {:?} ({e})", rules),
1211            )
1212        })?;
1213        match_all_by_regex_set(data, reset)
1214    };
1215    return Ok(found);
1216}
1217
1218/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_apply_rules --exact --show-output
1219#[test]
1220fn test_apply_rules() {
1221    use rust_embed::RustEmbed;
1222
1223    let _ = env_logger::builder()
1224        .filter_level(log::LevelFilter::Debug)
1225        .is_test(true)
1226        .try_init();
1227
1228    #[derive(RustEmbed)]
1229    #[folder = "artifacts/"]
1230    #[prefix = "artifacts/"]
1231    struct Asset;
1232
1233    let metrics_raw = Asset::get("artifacts/avalanchego.metrics").unwrap();
1234    let metrics_raw = std::str::from_utf8(metrics_raw.data.as_ref()).unwrap();
1235
1236    let s = Scrape::from_bytes(metrics_raw.as_bytes()).unwrap();
1237    assert_eq!(s.metrics.len(), 2140);
1238
1239    let rules = Rules::load("artifacts/avalanchego.rules.yaml").unwrap();
1240    let matched = apply_rules(&s.metrics, rules).unwrap();
1241
1242    let mut cnt = 0;
1243    for (i, v ) in vec![
1244            &Metric {
1245                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_benchlist_benched_num"
1246                    .to_string(),
1247                value: Value::Gauge(0f64),
1248                ..Default::default()
1249            },
1250            &Metric {
1251                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blk_builds_failed"
1252                    .to_string(),
1253                value: Value::Counter(8410f64),
1254                ..Default::default()
1255            },
1256            &Metric {
1257                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_accepted_count"
1258                    .to_string(),
1259                value: Value::Counter(43240f64),
1260                ..Default::default()
1261            },
1262            &Metric {
1263                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_accepted_sum"
1264                    .to_string(),
1265                value: Value::Gauge(9.81317938649e+11f64),
1266                ..Default::default()
1267            },
1268            &Metric {
1269                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_built"
1270                    .to_string(),
1271                value: Value::Counter(4205f64),
1272                ..Default::default()
1273            },
1274            &Metric {
1275                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_polls_accepted_count"
1276                    .to_string(),
1277                value: Value::Counter(43240f64),
1278                ..Default::default()
1279            },
1280            &Metric {
1281                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_polls_accepted_sum"
1282                    .to_string(),
1283                value: Value::Gauge(654614f64),
1284                ..Default::default()
1285            },
1286            &Metric {
1287                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_polls_rejected_count"
1288                    .to_string(),
1289                value: Value::Counter(3f64),
1290                ..Default::default()
1291            },
1292            &Metric {
1293                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_polls_rejected_sum"
1294                    .to_string(),
1295                value: Value::Gauge(66f64),
1296                ..Default::default()
1297            },
1298            &Metric {
1299                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_processing"
1300                    .to_string(),
1301                value: Value::Gauge(0f64),
1302                ..Default::default()
1303            },
1304            &Metric {
1305                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_rejected_count"
1306                    .to_string(),
1307                value: Value::Counter(3f64),
1308                ..Default::default()
1309            },
1310            &Metric {
1311                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blks_rejected_sum"
1312                    .to_string(),
1313                value: Value::Gauge(3.8554338e+07f64),
1314                ..Default::default()
1315            },
1316            &Metric {
1317                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blocked"
1318                    .to_string(),
1319                value: Value::Gauge(0f64),
1320                ..Default::default()
1321            },
1322            &Metric {
1323                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_blockers"
1324                    .to_string(),
1325                value: Value::Gauge(0f64),
1326                ..Default::default()
1327            },
1328            &Metric {
1329                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_count"
1330                    .to_string(),
1331                value: Value::Counter(7.469948e+06f64),
1332                ..Default::default()
1333            },
1334            &Metric {
1335                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_put_sum"
1336                    .to_string(),
1337                value: Value::Gauge(5.357270217e+09f64),
1338                ..Default::default()
1339            },
1340            &Metric {
1341                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_write_count"
1342                    .to_string(),
1343                value: Value::Counter(259476f64),
1344                ..Default::default()
1345            },
1346            &Metric {
1347                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_batch_write_sum"
1348                    .to_string(),
1349                value: Value::Gauge(2.8494818524e+10f64),
1350                ..Default::default()
1351            },
1352            &Metric {
1353                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_compact_count"
1354                    .to_string(),
1355                value: Value::Counter(0f64),
1356                ..Default::default()
1357            },
1358            &Metric {
1359                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_compact_sum"
1360                    .to_string(),
1361                value: Value::Gauge(0f64),
1362                ..Default::default()
1363            },
1364            &Metric {
1365                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_delete_count"
1366                    .to_string(),
1367                value: Value::Counter(4f64),
1368                ..Default::default()
1369            },
1370            &Metric {
1371                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_delete_sum"
1372                    .to_string(),
1373                value: Value::Gauge(66771f64),
1374                ..Default::default()
1375            },
1376            &Metric {
1377                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_get_count"
1378                    .to_string(),
1379                value: Value::Counter(5.703759e+06f64),
1380                ..Default::default()
1381            },
1382            &Metric {
1383                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_get_sum"
1384                    .to_string(),
1385                value: Value::Gauge(3.5932638264e+11f64),
1386                ..Default::default()
1387            },
1388            &Metric {
1389                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_put_count"
1390                    .to_string(),
1391                value: Value::Counter(1309f64),
1392                ..Default::default()
1393            },
1394            &Metric {
1395                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_put_sum"
1396                    .to_string(),
1397                value: Value::Gauge(5.6261023e+07f64),
1398                ..Default::default()
1399            },
1400            &Metric {
1401                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_read_size_count"
1402                    .to_string(),
1403                value: Value::Counter(5.707976e+06f64),
1404                ..Default::default()
1405            },
1406            &Metric {
1407                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_read_size_sum"
1408                    .to_string(),
1409                value: Value::Gauge(6.7606803461e+10f64),
1410                ..Default::default()
1411            },
1412            &Metric {
1413                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_write_size_count"
1414                    .to_string(),
1415                value: Value::Counter(260789f64),
1416                ..Default::default()
1417            },
1418            &Metric {
1419                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_db_write_size_sum"
1420                    .to_string(),
1421                value: Value::Gauge(2.1270066771e+10f64),
1422                ..Default::default()
1423            },
1424            &Metric {
1425                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_app_gossip_count"
1426                    .to_string(),
1427                value: Value::Counter(2.35194e+06f64),
1428                ..Default::default()
1429            },
1430            &Metric {
1431                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_app_gossip_sum"
1432                    .to_string(),
1433                value: Value::Gauge(1.429600925484e+12f64),
1434                ..Default::default()
1435            },
1436            &Metric {
1437                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_chits_count"
1438                    .to_string(),
1439                value: Value::Counter(6.741289e+06f64),
1440                ..Default::default()
1441            },
1442            &Metric {
1443                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_chits_sum"
1444                    .to_string(),
1445                value: Value::Gauge(2.5285767485e+11f64),
1446                ..Default::default()
1447            },
1448            &Metric {
1449                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_get_accepted_count"
1450                    .to_string(),
1451                value: Value::Counter(10f64),
1452                ..Default::default()
1453            },
1454            &Metric {
1455                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_get_accepted_sum"
1456                    .to_string(),
1457                value: Value::Gauge(132034f64),
1458                ..Default::default()
1459            },
1460            &Metric {
1461                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_get_ancestors_count"
1462                    .to_string(),
1463                value: Value::Counter(0f64),
1464                ..Default::default()
1465            },
1466            &Metric {
1467                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_get_ancestors_sum"
1468                    .to_string(),
1469                value: Value::Gauge(0f64),
1470                ..Default::default()
1471            },
1472            &Metric {
1473                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_get_count"
1474                    .to_string(),
1475                value: Value::Counter(4595f64),
1476                ..Default::default()
1477            },
1478            &Metric {
1479                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_get_sum"
1480                    .to_string(),
1481                value: Value::Gauge(1.0502593836e+10f64),
1482                ..Default::default()
1483            },
1484            &Metric {
1485                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_gossip_request_count"
1486                    .to_string(),
1487                value: Value::Counter(38637f64),
1488                ..Default::default()
1489            },
1490            &Metric {
1491                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_gossip_request_sum"
1492                    .to_string(),
1493                value: Value::Gauge(3.0502987481e+10f64),
1494                ..Default::default()
1495            },
1496            &Metric {
1497                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_query_failed_count"
1498                    .to_string(),
1499                value: Value::Counter(0f64),
1500                ..Default::default()
1501            },
1502            &Metric {
1503                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_query_failed_sum"
1504                    .to_string(),
1505                value: Value::Gauge(0f64),
1506                ..Default::default()
1507            },
1508            &Metric {
1509                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_handler_unprocessed_msgs_len"
1510                    .to_string(),
1511                value: Value::Gauge(0f64),
1512                ..Default::default()
1513            },
1514            &Metric {
1515                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_last_accepted_height"
1516                    .to_string(),
1517                value: Value::Gauge(43240f64),
1518                ..Default::default()
1519            },
1520            &Metric {
1521                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_last_accepted_timestamp"
1522                    .to_string(),
1523                value: Value::Gauge(1000f64),
1524                ..Default::default()
1525            },
1526            &Metric {
1527                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_polls_failed"
1528                    .to_string(),
1529                value: Value::Counter(5280f64),
1530                ..Default::default()
1531            },
1532            &Metric {
1533                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_polls_successful"
1534                    .to_string(),
1535                value: Value::Counter(649334f64),
1536                ..Default::default()
1537            },
1538            &Metric {
1539                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_chain_state_tx_accepted_count"
1540                    .to_string(),
1541                value: Value::Counter(1230f64),
1542                ..Default::default()
1543            },
1544            &Metric {
1545                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_chain_block_gas_used_accepted"
1546                    .to_string(),
1547                value: Value::Counter(1.1928465e+07),
1548                ..Default::default()
1549            },
1550            &Metric {
1551                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_chain_block_gas_used_processed"
1552                    .to_string(),
1553                value: Value::Counter(1.248318e+07),
1554                ..Default::default()
1555            },
1556            &Metric {
1557                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_chain_txs_accepted"
1558                    .to_string(),
1559                value: Value::Counter(1291f64),
1560                ..Default::default()
1561            },
1562            &Metric {
1563                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_chain_txs_processed"
1564                    .to_string(),
1565                value: Value::Counter(1291f64),
1566                ..Default::default()
1567            },
1568            &Metric {
1569                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_rpc_failure"
1570                    .to_string(),
1571                value: Value::Gauge(0f64),
1572                ..Default::default()
1573            },
1574            &Metric {
1575                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_rpc_requests"
1576                    .to_string(),
1577                value: Value::Gauge(4.307051e+06f64),
1578                ..Default::default()
1579            },
1580            &Metric {
1581                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_rpc_success"
1582                    .to_string(),
1583                value: Value::Gauge(4.307051e+06f64),
1584                ..Default::default()
1585            },
1586            &Metric {
1587                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1588                labels: Some(Labels(
1589                    [("grpc_code", "OK"), ("grpc_method", "Delete"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1590                        .iter()
1591                        .map(pair_to_string)
1592                        .collect()
1593                )),
1594                value: Value::Counter(4f64),
1595                ..Default::default()
1596            },
1597            &Metric {
1598                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1599                labels: Some(Labels(
1600                    [("grpc_code", "OK"), ("grpc_method", "Get"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1601                        .iter()
1602                        .map(pair_to_string)
1603                        .collect()
1604                )),
1605                value: Value::Counter(5.578128e+06f64),
1606                ..Default::default()
1607            },
1608            &Metric {
1609                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1610                labels: Some(Labels(
1611                    [("grpc_code", "OK"), ("grpc_method", "Has"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1612                        .iter()
1613                        .map(pair_to_string)
1614                        .collect()
1615                )),
1616                value: Value::Counter(4209f64),
1617                ..Default::default()
1618            },
1619            &Metric {
1620                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1621                labels: Some(Labels(
1622                    [("grpc_code", "OK"), ("grpc_method", "HealthCheck"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1623                        .iter()
1624                        .map(pair_to_string)
1625                        .collect()
1626                )),
1627                value: Value::Counter(12879f64),
1628                ..Default::default()
1629            },
1630            &Metric {
1631                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1632                labels: Some(Labels(
1633                    [("grpc_code", "OK"), ("grpc_method", "IteratorNext"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1634                        .iter()
1635                        .map(pair_to_string)
1636                        .collect()
1637                )),
1638                value: Value::Counter(3f64),
1639                ..Default::default()
1640            },
1641            &Metric {
1642                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1643                labels: Some(Labels(
1644                    [("grpc_code", "OK"), ("grpc_method", "IteratorRelease"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1645                        .iter()
1646                        .map(pair_to_string)
1647                        .collect()
1648                )),
1649                value: Value::Counter(2f64),
1650                ..Default::default()
1651            },
1652            &Metric {
1653                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1654                labels: Some(Labels(
1655                    [("grpc_code", "OK"), ("grpc_method", "NewIteratorWithStartAndPrefix"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1656                        .iter()
1657                        .map(pair_to_string)
1658                        .collect()
1659                )),
1660                value: Value::Counter(2f64),
1661                ..Default::default()
1662            },
1663            &Metric {
1664                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1665                labels: Some(Labels(
1666                    [("grpc_code", "OK"), ("grpc_method", "Notify"), ("grpc_service", "messenger.Messenger"), ("grpc_type", "unary")]
1667                        .iter()
1668                        .map(pair_to_string)
1669                        .collect()
1670                )),
1671                value: Value::Counter(12615f64),
1672                ..Default::default()
1673            },
1674            &Metric {
1675                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1676                labels: Some(Labels(
1677                    [("grpc_code", "OK"), ("grpc_method", "Put"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1678                        .iter()
1679                        .map(pair_to_string)
1680                        .collect()
1681                )),
1682                value: Value::Counter(1309f64),
1683                ..Default::default()
1684            },
1685            &Metric {
1686                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1687                labels: Some(Labels(
1688                    [("grpc_code", "OK"), ("grpc_method", "SendAppGossip"), ("grpc_service", "appsender.AppSender"), ("grpc_type", "unary")]
1689                        .iter()
1690                        .map(pair_to_string)
1691                        .collect()
1692                )),
1693                value: Value::Counter(257127f64),
1694                ..Default::default()
1695            },
1696            &Metric {
1697                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_handled_total".to_string(),
1698                labels: Some(Labels(
1699                    [("grpc_code", "OK"), ("grpc_method", "WriteBatch"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1700                        .iter()
1701                        .map(pair_to_string)
1702                        .collect()
1703                )),
1704                value: Value::Counter(259475f64),
1705                ..Default::default()
1706            },
1707            &Metric {
1708                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1709                labels: Some(Labels(
1710                    [("grpc_method", "Delete"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1711                        .iter()
1712                        .map(pair_to_string)
1713                        .collect()
1714                )),
1715                value: Value::Counter(4f64),
1716                ..Default::default()
1717            },
1718            &Metric {
1719                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1720                labels: Some(Labels(
1721                    [("grpc_method", "Get"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1722                        .iter()
1723                        .map(pair_to_string)
1724                        .collect()
1725                )),
1726                value: Value::Counter(5.578128e+06f64),
1727                ..Default::default()
1728            },
1729            &Metric {
1730                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1731                labels: Some(Labels(
1732                    [("grpc_method", "Has"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1733                        .iter()
1734                        .map(pair_to_string)
1735                        .collect()
1736                )),
1737                value: Value::Counter(4209f64),
1738                ..Default::default()
1739            },
1740            &Metric {
1741                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1742                labels: Some(Labels(
1743                    [("grpc_method", "HealthCheck"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1744                        .iter()
1745                        .map(pair_to_string)
1746                        .collect()
1747                )),
1748                value: Value::Counter(12879f64),
1749                ..Default::default()
1750            },
1751            &Metric {
1752                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1753                labels: Some(Labels(
1754                    [("grpc_method", "IteratorNext"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1755                        .iter()
1756                        .map(pair_to_string)
1757                        .collect()
1758                )),
1759                value: Value::Counter(3f64),
1760                ..Default::default()
1761            },
1762            &Metric {
1763                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1764                labels: Some(Labels(
1765                    [("grpc_method", "IteratorRelease"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1766                        .iter()
1767                        .map(pair_to_string)
1768                        .collect()
1769                )),
1770                value: Value::Counter(2f64),
1771                ..Default::default()
1772            },
1773            &Metric {
1774                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1775                labels: Some(Labels(
1776                    [("grpc_method", "NewIteratorWithStartAndPrefix"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1777                        .iter()
1778                        .map(pair_to_string)
1779                        .collect()
1780                )),
1781                value: Value::Counter(2f64),
1782                ..Default::default()
1783            },
1784            &Metric {
1785                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1786                labels: Some(Labels(
1787                    [("grpc_method", "Notify"), ("grpc_service", "messenger.Messenger"), ("grpc_type", "unary")]
1788                        .iter()
1789                        .map(pair_to_string)
1790                        .collect()
1791                )),
1792                value: Value::Counter(12615f64),
1793                ..Default::default()
1794            },
1795            &Metric {
1796                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1797                labels: Some(Labels(
1798                    [("grpc_method", "Put"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1799                        .iter()
1800                        .map(pair_to_string)
1801                        .collect()
1802                )),
1803                value: Value::Counter(1309f64),
1804                ..Default::default()
1805            },
1806            &Metric {
1807                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1808                labels: Some(Labels(
1809                    [("grpc_method", "SendAppGossip"), ("grpc_service", "appsender.AppSender"), ("grpc_type", "unary")]
1810                        .iter()
1811                        .map(pair_to_string)
1812                        .collect()
1813                )),
1814                value: Value::Counter(257127f64),
1815                ..Default::default()
1816            },
1817            &Metric {
1818                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_grpc_client_started_total".to_string(),
1819                labels: Some(Labels(
1820                    [("grpc_method", "WriteBatch"), ("grpc_service", "rpcdb.Database"), ("grpc_type", "unary")]
1821                        .iter()
1822                        .map(pair_to_string)
1823                        .collect()
1824                )),
1825                value: Value::Counter(259475f64),
1826                ..Default::default()
1827            },
1828            &Metric {
1829                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_metervm_parse_block_count"
1830                    .to_string(),
1831                value: Value::Counter(1.121427e+06f64),
1832                ..Default::default()
1833            },
1834            &Metric {
1835                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_metervm_parse_block_sum"
1836                    .to_string(),
1837                value: Value::Gauge(5.82743213583e+11f64),
1838                ..Default::default()
1839            },
1840            &Metric {
1841                metric: "avalanche_C_benchlist_benched_num"
1842                    .to_string(),
1843                value: Value::Gauge(0f64),
1844                ..Default::default()
1845            },
1846            &Metric {
1847                metric: "avalanche_C_blk_builds_failed"
1848                    .to_string(),
1849                value: Value::Counter(0f64),
1850                ..Default::default()
1851            },
1852            &Metric {
1853                metric: "avalanche_C_blks_accepted_count"
1854                    .to_string(),
1855                value: Value::Counter(27f64),
1856                ..Default::default()
1857            },
1858            &Metric {
1859                metric: "avalanche_C_blks_accepted_sum"
1860                    .to_string(),
1861                value: Value::Gauge(1.62497901e+08f64),
1862                ..Default::default()
1863            },
1864            &Metric {
1865                metric: "avalanche_C_blks_built"
1866                    .to_string(),
1867                value: Value::Counter(0f64),
1868                ..Default::default()
1869            },
1870            &Metric {
1871                metric: "avalanche_C_blks_polls_accepted_count"
1872                    .to_string(),
1873                value: Value::Counter(27f64),
1874                ..Default::default()
1875            },
1876            &Metric {
1877                metric: "avalanche_C_blks_polls_accepted_sum"
1878                    .to_string(),
1879                value: Value::Gauge(420f64),
1880                ..Default::default()
1881            },
1882            &Metric {
1883                metric: "avalanche_C_blks_polls_rejected_count"
1884                    .to_string(),
1885                value: Value::Counter(3f64),
1886                ..Default::default()
1887            },
1888            &Metric {
1889                metric: "avalanche_C_blks_polls_rejected_sum"
1890                    .to_string(),
1891                value: Value::Gauge(59f64),
1892                ..Default::default()
1893            },
1894            &Metric {
1895                metric: "avalanche_C_blks_processing"
1896                    .to_string(),
1897                value: Value::Gauge(0f64),
1898                ..Default::default()
1899            },
1900            &Metric {
1901                metric: "avalanche_C_blks_rejected_count"
1902                    .to_string(),
1903                value: Value::Counter(3f64),
1904                ..Default::default()
1905            },
1906            &Metric {
1907                metric: "avalanche_C_blks_rejected_sum"
1908                    .to_string(),
1909                value: Value::Gauge(1.8306179e+07f64),
1910                ..Default::default()
1911            },
1912            &Metric {
1913                metric: "avalanche_C_blocked"
1914                    .to_string(),
1915                value: Value::Gauge(0f64),
1916                ..Default::default()
1917            },
1918            &Metric {
1919                metric: "avalanche_C_blockers"
1920                    .to_string(),
1921                value: Value::Gauge(0f64),
1922                ..Default::default()
1923            },
1924            &Metric {
1925                metric: "avalanche_C_db_batch_put_count"
1926                    .to_string(),
1927                value: Value::Counter(659f64),
1928                ..Default::default()
1929            },
1930            &Metric {
1931                metric: "avalanche_C_db_batch_put_sum"
1932                    .to_string(),
1933                value: Value::Gauge(450756f64),
1934                ..Default::default()
1935            },
1936            &Metric {
1937                metric: "avalanche_C_db_batch_write_count"
1938                    .to_string(),
1939                value: Value::Counter(176f64),
1940                ..Default::default()
1941            },
1942            &Metric {
1943                metric: "avalanche_C_db_batch_write_sum"
1944                    .to_string(),
1945                value: Value::Gauge(2.894071e+06f64),
1946                ..Default::default()
1947            },
1948            &Metric {
1949                metric: "avalanche_C_db_compact_count"
1950                    .to_string(),
1951                value: Value::Counter(0f64),
1952                ..Default::default()
1953            },
1954            &Metric {
1955                metric: "avalanche_C_db_compact_sum"
1956                    .to_string(),
1957                value: Value::Gauge(0f64),
1958                ..Default::default()
1959            },
1960            &Metric {
1961                metric: "avalanche_C_db_delete_count"
1962                    .to_string(),
1963                value: Value::Counter(2f64),
1964                ..Default::default()
1965            },
1966            &Metric {
1967                metric: "avalanche_C_db_delete_sum"
1968                    .to_string(),
1969                value: Value::Gauge(11070f64),
1970                ..Default::default()
1971            },
1972            &Metric {
1973                metric: "avalanche_C_db_get_count"
1974                    .to_string(),
1975                value: Value::Counter(37607f64),
1976                ..Default::default()
1977            },
1978            &Metric {
1979                metric: "avalanche_C_db_get_sum"
1980                    .to_string(),
1981                value: Value::Gauge(1.22077894e+09f64),
1982                ..Default::default()
1983            },
1984            &Metric {
1985                metric: "avalanche_C_db_put_count"
1986                    .to_string(),
1987                value: Value::Counter(1290f64),
1988                ..Default::default()
1989            },
1990            &Metric {
1991                metric: "avalanche_C_db_put_sum"
1992                    .to_string(),
1993                value: Value::Gauge(3.2048842e+07f64),
1994                ..Default::default()
1995            },
1996            &Metric {
1997                metric: "avalanche_C_db_read_size_count"
1998                    .to_string(),
1999                value: Value::Counter(37650f64),
2000                ..Default::default()
2001            },
2002            &Metric {
2003                metric: "avalanche_C_db_read_size_sum"
2004                    .to_string(),
2005                value: Value::Gauge(2.689728e+06f64),
2006                ..Default::default()
2007            },
2008            &Metric {
2009                metric: "avalanche_C_db_write_size_count"
2010                    .to_string(),
2011                value: Value::Counter(1468f64),
2012                ..Default::default()
2013            },
2014            &Metric {
2015                metric: "avalanche_C_db_write_size_sum"
2016                    .to_string(),
2017                value: Value::Gauge(396119f64),
2018                ..Default::default()
2019            },
2020            &Metric {
2021                metric: "avalanche_C_handler_app_gossip_count"
2022                    .to_string(),
2023                value: Value::Counter(0f64),
2024                ..Default::default()
2025            },
2026            &Metric {
2027                metric: "avalanche_C_handler_app_gossip_sum"
2028                    .to_string(),
2029                value: Value::Gauge(0f64),
2030                ..Default::default()
2031            },
2032            &Metric {
2033                metric: "avalanche_C_handler_chits_count"
2034                    .to_string(),
2035                value: Value::Counter(2444f64),
2036                ..Default::default()
2037            },
2038            &Metric {
2039                metric: "avalanche_C_handler_chits_sum"
2040                    .to_string(),
2041                value: Value::Gauge(3.7045222e+07f64),
2042                ..Default::default()
2043            },
2044            &Metric {
2045                metric: "avalanche_C_handler_get_accepted_count"
2046                    .to_string(),
2047                value: Value::Counter(10f64),
2048                ..Default::default()
2049            },
2050            &Metric {
2051                metric: "avalanche_C_handler_get_accepted_sum"
2052                    .to_string(),
2053                value: Value::Gauge(151780f64),
2054                ..Default::default()
2055            },
2056            &Metric {
2057                metric: "avalanche_C_handler_get_ancestors_count"
2058                    .to_string(),
2059                value: Value::Counter(0f64),
2060                ..Default::default()
2061            },
2062            &Metric {
2063                metric: "avalanche_C_handler_get_ancestors_sum"
2064                    .to_string(),
2065                value: Value::Gauge(0f64),
2066                ..Default::default()
2067            },
2068            &Metric {
2069                metric: "avalanche_C_handler_get_count"
2070                    .to_string(),
2071                value: Value::Counter(1f64),
2072                ..Default::default()
2073            },
2074            &Metric {
2075                metric: "avalanche_C_handler_get_sum"
2076                    .to_string(),
2077                value: Value::Gauge(105902f64),
2078                ..Default::default()
2079            },
2080            &Metric {
2081                metric: "avalanche_C_handler_gossip_request_count"
2082                    .to_string(),
2083                value: Value::Counter(38647f64),
2084                ..Default::default()
2085            },
2086            &Metric {
2087                metric: "avalanche_C_handler_gossip_request_sum"
2088                    .to_string(),
2089                value: Value::Gauge(7.478144226e+09f64),
2090                ..Default::default()
2091            },
2092            &Metric {
2093                metric: "avalanche_C_handler_query_failed_count"
2094                    .to_string(),
2095                value: Value::Counter(0f64),
2096                ..Default::default()
2097            },
2098            &Metric {
2099                metric: "avalanche_C_handler_query_failed_sum"
2100                    .to_string(),
2101                value: Value::Gauge(0f64),
2102                ..Default::default()
2103            },
2104            &Metric {
2105                metric: "avalanche_C_handler_unprocessed_msgs_len"
2106                    .to_string(),
2107                value: Value::Gauge(0f64),
2108                ..Default::default()
2109            },
2110            &Metric {
2111                metric: "avalanche_C_last_accepted_height"
2112                    .to_string(),
2113                value: Value::Gauge(27f64),
2114                ..Default::default()
2115            },
2116            &Metric {
2117                metric: "avalanche_C_last_accepted_timestamp"
2118                    .to_string(),
2119                value: Value::Gauge(10f64),
2120                ..Default::default()
2121            },
2122            &Metric {
2123                metric: "avalanche_C_polls_failed"
2124                    .to_string(),
2125                value: Value::Counter(0f64),
2126                ..Default::default()
2127            },
2128            &Metric {
2129                metric: "avalanche_C_polls_successful"
2130                    .to_string(),
2131                value: Value::Counter(420f64),
2132                ..Default::default()
2133            },
2134            &Metric {
2135                metric: "avalanche_C_vm_eth_rpc_failure"
2136                    .to_string(),
2137                value: Value::Gauge(0f64),
2138                ..Default::default()
2139            },
2140            &Metric {
2141                metric: "avalanche_C_vm_eth_rpc_requests"
2142                    .to_string(),
2143                value: Value::Gauge(32f64),
2144                ..Default::default()
2145            },
2146            &Metric {
2147                metric: "avalanche_C_vm_eth_rpc_success"
2148                    .to_string(),
2149                value: Value::Gauge(32f64),
2150                ..Default::default()
2151            },
2152            &Metric {
2153                metric: "avalanche_C_vm_metervm_parse_block_count"
2154                    .to_string(),
2155                value: Value::Counter(348187f64),
2156                ..Default::default()
2157            },
2158            &Metric {
2159                metric: "avalanche_C_vm_metervm_parse_block_sum"
2160                    .to_string(),
2161                value: Value::Gauge(2.364194114e+09f64),
2162                ..Default::default()
2163            },
2164            &Metric {
2165                metric: "avalanche_P_benchlist_benched_num"
2166                    .to_string(),
2167                value: Value::Gauge(0f64),
2168                ..Default::default()
2169            },
2170            &Metric {
2171                metric: "avalanche_P_blk_builds_failed"
2172                    .to_string(),
2173                value: Value::Counter(0f64),
2174                ..Default::default()
2175            },
2176            &Metric {
2177                metric: "avalanche_P_blks_accepted_count"
2178                    .to_string(),
2179                value: Value::Counter(39f64),
2180                ..Default::default()
2181            },
2182            &Metric {
2183                metric: "avalanche_P_blks_accepted_sum"
2184                    .to_string(),
2185                value: Value::Gauge(4.30488494e+08f64),
2186                ..Default::default()
2187            },
2188            &Metric {
2189                metric: "avalanche_P_blks_built"
2190                    .to_string(),
2191                value: Value::Counter(3f64),
2192                ..Default::default()
2193            },
2194            &Metric {
2195                metric: "avalanche_P_blks_polls_accepted_count"
2196                    .to_string(),
2197                value: Value::Counter(39f64),
2198                ..Default::default()
2199            },
2200            &Metric {
2201                metric: "avalanche_P_blks_polls_accepted_sum"
2202                    .to_string(),
2203                value: Value::Gauge(697f64),
2204                ..Default::default()
2205            },
2206            &Metric {
2207                metric: "avalanche_P_blks_polls_rejected_count"
2208                    .to_string(),
2209                value: Value::Counter(21f64),
2210                ..Default::default()
2211            },
2212            &Metric {
2213                metric: "avalanche_P_blks_polls_rejected_sum"
2214                    .to_string(),
2215                value: Value::Gauge(438f64),
2216                ..Default::default()
2217            },
2218            &Metric {
2219                metric: "avalanche_P_blks_processing"
2220                    .to_string(),
2221                value: Value::Gauge(0f64),
2222                ..Default::default()
2223            },
2224            &Metric {
2225                metric: "avalanche_P_blks_rejected_count"
2226                    .to_string(),
2227                value: Value::Counter(21f64),
2228                ..Default::default()
2229            },
2230            &Metric {
2231                metric: "avalanche_P_blks_rejected_sum"
2232                    .to_string(),
2233                value: Value::Gauge(5.25170283e+08f64),
2234                ..Default::default()
2235            },
2236            &Metric {
2237                metric: "avalanche_P_blocked"
2238                    .to_string(),
2239                value: Value::Gauge(0f64),
2240                ..Default::default()
2241            },
2242            &Metric {
2243                metric: "avalanche_P_blockers"
2244                    .to_string(),
2245                value: Value::Gauge(0f64),
2246                ..Default::default()
2247            },
2248            &Metric {
2249                metric: "avalanche_P_db_batch_put_count"
2250                    .to_string(),
2251                value: Value::Counter(322f64),
2252                ..Default::default()
2253            },
2254            &Metric {
2255                metric: "avalanche_P_db_batch_put_sum"
2256                    .to_string(),
2257                value: Value::Gauge(116272f64),
2258                ..Default::default()
2259            },
2260            &Metric {
2261                metric: "avalanche_P_db_batch_write_count"
2262                    .to_string(),
2263                value: Value::Counter(95f64),
2264                ..Default::default()
2265            },
2266            &Metric {
2267                metric: "avalanche_P_db_batch_write_sum"
2268                    .to_string(),
2269                value: Value::Gauge(1.371173e+06f64),
2270                ..Default::default()
2271            },
2272            &Metric {
2273                metric: "avalanche_P_db_compact_count"
2274                    .to_string(),
2275                value: Value::Counter(0f64),
2276                ..Default::default()
2277            },
2278            &Metric {
2279                metric: "avalanche_P_db_compact_sum"
2280                    .to_string(),
2281                value: Value::Gauge(0f64),
2282                ..Default::default()
2283            },
2284            &Metric {
2285                metric: "avalanche_P_db_delete_count"
2286                    .to_string(),
2287                value: Value::Counter(0f64),
2288                ..Default::default()
2289            },
2290            &Metric {
2291                metric: "avalanche_P_db_delete_sum"
2292                    .to_string(),
2293                value: Value::Gauge(0f64),
2294                ..Default::default()
2295            },
2296            &Metric {
2297                metric: "avalanche_P_db_get_count"
2298                    .to_string(),
2299                value: Value::Counter(212f64),
2300                ..Default::default()
2301            },
2302            &Metric {
2303                metric: "avalanche_P_db_get_sum"
2304                    .to_string(),
2305                value: Value::Gauge(1.139713e+06f64),
2306                ..Default::default()
2307            },
2308            &Metric {
2309                metric: "avalanche_P_db_put_count"
2310                    .to_string(),
2311                value: Value::Counter(0f64),
2312                ..Default::default()
2313            },
2314            &Metric {
2315                metric: "avalanche_P_db_put_sum"
2316                    .to_string(),
2317                value: Value::Gauge(0f64),
2318                ..Default::default()
2319            },
2320            &Metric {
2321                metric: "avalanche_P_db_read_size_count"
2322                    .to_string(),
2323                value: Value::Counter(214f64),
2324                ..Default::default()
2325            },
2326            &Metric {
2327                metric: "avalanche_P_db_read_size_sum"
2328                    .to_string(),
2329                value: Value::Gauge(30726f64),
2330                ..Default::default()
2331            },
2332            &Metric {
2333                metric: "avalanche_P_db_write_size_count"
2334                    .to_string(),
2335                value: Value::Counter(95f64),
2336                ..Default::default()
2337            },
2338            &Metric {
2339                metric: "avalanche_P_db_write_size_sum"
2340                    .to_string(),
2341                value: Value::Gauge(78865f64),
2342                ..Default::default()
2343            },
2344            &Metric {
2345                metric: "avalanche_P_handler_app_gossip_count"
2346                    .to_string(),
2347                value: Value::Counter(99f64),
2348                ..Default::default()
2349            },
2350            &Metric {
2351                metric: "avalanche_P_handler_app_gossip_sum"
2352                    .to_string(),
2353                value: Value::Gauge(4.151146e+07f64),
2354                ..Default::default()
2355            },
2356            &Metric {
2357                metric: "avalanche_P_handler_chits_count"
2358                    .to_string(),
2359                value: Value::Counter(2295f64),
2360                ..Default::default()
2361            },
2362            &Metric {
2363                metric: "avalanche_P_handler_chits_sum"
2364                    .to_string(),
2365                value: Value::Gauge(1.37038802e+08f64),
2366                ..Default::default()
2367            },
2368            &Metric {
2369                metric: "avalanche_P_handler_get_accepted_count"
2370                    .to_string(),
2371                value: Value::Counter(5f64),
2372                ..Default::default()
2373            },
2374            &Metric {
2375                metric: "avalanche_P_handler_get_accepted_sum"
2376                    .to_string(),
2377                value: Value::Gauge(341334f64),
2378                ..Default::default()
2379            },
2380            &Metric {
2381                metric: "avalanche_P_handler_get_ancestors_count"
2382                    .to_string(),
2383                value: Value::Counter(0f64),
2384                ..Default::default()
2385            },
2386            &Metric {
2387                metric: "avalanche_P_handler_get_ancestors_sum"
2388                    .to_string(),
2389                value: Value::Gauge(0f64),
2390                ..Default::default()
2391            },
2392            &Metric {
2393                metric: "avalanche_P_handler_get_count"
2394                    .to_string(),
2395                value: Value::Counter(0f64),
2396                ..Default::default()
2397            },
2398            &Metric {
2399                metric: "avalanche_P_handler_get_sum"
2400                    .to_string(),
2401                value: Value::Gauge(0f64),
2402                ..Default::default()
2403            },
2404            &Metric {
2405                metric: "avalanche_P_handler_gossip_request_count"
2406                    .to_string(),
2407                value: Value::Counter(38647f64),
2408                ..Default::default()
2409            },
2410            &Metric {
2411                metric: "avalanche_P_handler_gossip_request_sum"
2412                    .to_string(),
2413                value: Value::Gauge(1.6374368298e+10f64),
2414                ..Default::default()
2415            },
2416            &Metric {
2417                metric: "avalanche_P_handler_query_failed_count"
2418                    .to_string(),
2419                value: Value::Counter(0f64),
2420                ..Default::default()
2421            },
2422            &Metric {
2423                metric: "avalanche_P_handler_query_failed_sum"
2424                    .to_string(),
2425                value: Value::Gauge(0f64),
2426                ..Default::default()
2427            },
2428            &Metric {
2429                metric: "avalanche_P_handler_unprocessed_msgs_len"
2430                    .to_string(),
2431                value: Value::Gauge(0f64),
2432                ..Default::default()
2433            },
2434            &Metric {
2435                metric: "avalanche_P_last_accepted_height"
2436                    .to_string(),
2437                value: Value::Gauge(60f64),
2438                ..Default::default()
2439            },
2440            &Metric {
2441                metric: "avalanche_P_last_accepted_timestamp"
2442                    .to_string(),
2443                value: Value::Gauge(100f64),
2444                ..Default::default()
2445            },
2446            &Metric {
2447                metric: "avalanche_P_polls_failed"
2448                    .to_string(),
2449                value: Value::Counter(7f64),
2450                ..Default::default()
2451            },
2452            &Metric {
2453                metric: "avalanche_P_polls_successful"
2454                    .to_string(),
2455                value: Value::Counter(403f64),
2456                ..Default::default()
2457            },
2458            &Metric {
2459                metric: "avalanche_P_vm_metervm_parse_block_count"
2460                    .to_string(),
2461                value: Value::Counter(348418f64),
2462                ..Default::default()
2463            },
2464            &Metric {
2465                metric: "avalanche_P_vm_metervm_parse_block_sum"
2466                    .to_string(),
2467                value: Value::Gauge(5.5101287211e+10f64),
2468                ..Default::default()
2469            },
2470            &Metric {
2471                metric: "avalanche_P_vm_percent_connected"
2472                    .to_string(),
2473                value: Value::Gauge(1f64),
2474                ..Default::default()
2475            },
2476            &Metric {
2477                metric: "avalanche_P_vm_percent_connected_subnet"
2478                    .to_string(),
2479                labels: Some(Labels(
2480                        [("subnetID", "2At5uFe2kDiYsHziSqJeebizvF9zQbH4m9mPQbKdMKhEWJj5AW")]
2481                            .iter()
2482                            .map(pair_to_string)
2483                            .collect()
2484                    )),
2485                value: Value::Gauge(1f64),
2486                ..Default::default()
2487            },
2488            &Metric {
2489                metric: "avalanche_X_benchlist_benched_num"
2490                    .to_string(),
2491                value: Value::Gauge(0f64),
2492                ..Default::default()
2493            },
2494            &Metric {
2495                metric: "avalanche_X_db_batch_put_count"
2496                    .to_string(),
2497                value: Value::Counter(0f64),
2498                ..Default::default()
2499            },
2500            &Metric {
2501                metric: "avalanche_X_db_batch_put_sum"
2502                    .to_string(),
2503                value: Value::Gauge(0f64),
2504                ..Default::default()
2505            },
2506            &Metric {
2507                metric: "avalanche_X_db_batch_write_count"
2508                    .to_string(),
2509                value: Value::Counter(4f64),
2510                ..Default::default()
2511            },
2512            &Metric {
2513                metric: "avalanche_X_db_batch_write_sum"
2514                    .to_string(),
2515                value: Value::Gauge(2070f64),
2516                ..Default::default()
2517            },
2518            &Metric {
2519                metric: "avalanche_X_db_compact_count"
2520                    .to_string(),
2521                value: Value::Counter(0f64),
2522                ..Default::default()
2523            },
2524            &Metric {
2525                metric: "avalanche_X_db_compact_sum"
2526                    .to_string(),
2527                value: Value::Gauge(0f64),
2528                ..Default::default()
2529            },
2530            &Metric {
2531                metric: "avalanche_X_db_delete_count"
2532                    .to_string(),
2533                value: Value::Counter(0f64),
2534                ..Default::default()
2535            },
2536            &Metric {
2537                metric: "avalanche_X_db_delete_sum"
2538                    .to_string(),
2539                value: Value::Gauge(0f64),
2540                ..Default::default()
2541            },
2542            &Metric {
2543                metric: "avalanche_X_db_get_count"
2544                    .to_string(),
2545                value: Value::Counter(7f64),
2546                ..Default::default()
2547            },
2548            &Metric {
2549                metric: "avalanche_X_db_get_sum"
2550                    .to_string(),
2551                value: Value::Gauge(38260f64),
2552                ..Default::default()
2553            },
2554            &Metric {
2555                metric: "avalanche_X_db_put_count"
2556                    .to_string(),
2557                value: Value::Counter(0f64),
2558                ..Default::default()
2559            },
2560            &Metric {
2561                metric: "avalanche_X_db_put_sum"
2562                    .to_string(),
2563                value: Value::Gauge(0f64),
2564                ..Default::default()
2565            },
2566            &Metric {
2567                metric: "avalanche_X_db_read_size_count"
2568                    .to_string(),
2569                value: Value::Counter(10f64),
2570                ..Default::default()
2571            },
2572            &Metric {
2573                metric: "avalanche_X_db_read_size_sum"
2574                    .to_string(),
2575                value: Value::Gauge(507f64),
2576                ..Default::default()
2577            },
2578            &Metric {
2579                metric: "avalanche_X_db_write_size_count"
2580                    .to_string(),
2581                value: Value::Counter(4f64),
2582                ..Default::default()
2583            },
2584            &Metric {
2585                metric: "avalanche_X_db_write_size_sum"
2586                    .to_string(),
2587                value: Value::Gauge(0f64),
2588                ..Default::default()
2589            },
2590            &Metric {
2591                metric: "avalanche_X_handler_app_gossip_count"
2592                    .to_string(),
2593                value: Value::Counter(0f64),
2594                ..Default::default()
2595            },
2596            &Metric {
2597                metric: "avalanche_X_handler_app_gossip_sum"
2598                    .to_string(),
2599                value: Value::Gauge(0f64),
2600                ..Default::default()
2601            },
2602            &Metric {
2603                metric: "avalanche_X_handler_chits_count"
2604                    .to_string(),
2605                value: Value::Counter(0f64),
2606                ..Default::default()
2607            },
2608            &Metric {
2609                metric: "avalanche_X_handler_chits_sum"
2610                    .to_string(),
2611                value: Value::Gauge(0f64),
2612                ..Default::default()
2613            },
2614            &Metric {
2615                metric: "avalanche_X_handler_get_accepted_count"
2616                    .to_string(),
2617                value: Value::Counter(10f64),
2618                ..Default::default()
2619            },
2620            &Metric {
2621                metric: "avalanche_X_handler_get_accepted_sum"
2622                    .to_string(),
2623                value: Value::Gauge(87161f64),
2624                ..Default::default()
2625            },
2626            &Metric {
2627                metric: "avalanche_X_handler_get_ancestors_count"
2628                    .to_string(),
2629                value: Value::Counter(0f64),
2630                ..Default::default()
2631            },
2632            &Metric {
2633                metric: "avalanche_X_handler_get_ancestors_sum"
2634                    .to_string(),
2635                value: Value::Gauge(0f64),
2636                ..Default::default()
2637            },
2638            &Metric {
2639                metric: "avalanche_X_handler_get_count"
2640                    .to_string(),
2641                value: Value::Counter(0f64),
2642                ..Default::default()
2643            },
2644            &Metric {
2645                metric: "avalanche_X_handler_get_sum"
2646                    .to_string(),
2647                value: Value::Gauge(0f64),
2648                ..Default::default()
2649            },
2650            &Metric {
2651                metric: "avalanche_X_handler_gossip_request_count"
2652                    .to_string(),
2653                value: Value::Counter(38647f64),
2654                ..Default::default()
2655            },
2656            &Metric {
2657                metric: "avalanche_X_handler_gossip_request_sum"
2658                    .to_string(),
2659                value: Value::Gauge(6.6360031e+07f64),
2660                ..Default::default()
2661            },
2662            &Metric {
2663                metric: "avalanche_X_handler_query_failed_count"
2664                    .to_string(),
2665                value: Value::Counter(0f64),
2666                ..Default::default()
2667            },
2668            &Metric {
2669                metric: "avalanche_X_handler_query_failed_sum"
2670                    .to_string(),
2671                value: Value::Gauge(0f64),
2672                ..Default::default()
2673            },
2674            &Metric {
2675                metric: "avalanche_X_handler_unprocessed_msgs_len"
2676                    .to_string(),
2677                value: Value::Gauge(0f64),
2678                ..Default::default()
2679            },
2680
2681            &Metric {
2682                metric: "avalanche_X_avalanche_polls_failed"
2683                    .to_string(),
2684                value: Value::Counter(0f64),
2685                ..Default::default()
2686            },
2687            &Metric {
2688                metric: "avalanche_X_avalanche_polls_successful"
2689                    .to_string(),
2690                value: Value::Counter(0f64),
2691                ..Default::default()
2692            },
2693
2694            &Metric {
2695                metric: "avalanche_X_avalanche_txs_accepted_count"
2696                    .to_string(),
2697                value: Value::Counter(0f64),
2698                ..Default::default()
2699            },
2700            &Metric {
2701                metric: "avalanche_X_avalanche_txs_accepted_sum"
2702                    .to_string(),
2703                value: Value::Gauge(0f64),
2704                ..Default::default()
2705            },
2706            &Metric {
2707                metric: "avalanche_X_avalanche_txs_polls_accepted_count"
2708                    .to_string(),
2709                value: Value::Counter(0f64),
2710                ..Default::default()
2711            },
2712            &Metric {
2713                metric: "avalanche_X_avalanche_txs_polls_accepted_sum"
2714                    .to_string(),
2715                value: Value::Gauge(0f64),
2716                ..Default::default()
2717            },
2718            &Metric {
2719                metric: "avalanche_X_avalanche_txs_polls_rejected_count"
2720                    .to_string(),
2721                value: Value::Counter(0f64),
2722                ..Default::default()
2723            },
2724            &Metric {
2725                metric: "avalanche_X_avalanche_txs_polls_rejected_sum"
2726                    .to_string(),
2727                value: Value::Gauge(0f64),
2728                ..Default::default()
2729            },
2730            &Metric {
2731                metric: "avalanche_X_avalanche_txs_processing"
2732                    .to_string(),
2733                value: Value::Gauge(0f64),
2734                ..Default::default()
2735            },
2736            &Metric {
2737                metric: "avalanche_X_avalanche_txs_rejected_count"
2738                    .to_string(),
2739                value: Value::Counter(0f64),
2740                ..Default::default()
2741            },
2742            &Metric {
2743                metric: "avalanche_X_avalanche_txs_rejected_sum"
2744                    .to_string(),
2745                value: Value::Gauge(0f64),
2746                ..Default::default()
2747            },
2748
2749            &Metric {
2750                metric: "avalanche_X_vm_avalanche_base_txs_accepted"
2751                    .to_string(),
2752                value: Value::Counter(77777f64),
2753                ..Default::default()
2754            },
2755            &Metric {
2756                metric: "avalanche_X_avalanche_whitelist_tx_accepted_count"
2757                    .to_string(),
2758                value: Value::Counter(0f64),
2759                ..Default::default()
2760            },
2761            &Metric {
2762                metric: "avalanche_X_avalanche_whitelist_tx_accepted_sum"
2763                    .to_string(),
2764                value: Value::Gauge(0f64),
2765                ..Default::default()
2766            },
2767            &Metric {
2768                metric: "avalanche_X_avalanche_whitelist_tx_polls_accepted_count"
2769                    .to_string(),
2770                value: Value::Counter(0f64),
2771                ..Default::default()
2772            },
2773            &Metric {
2774                metric: "avalanche_X_avalanche_whitelist_tx_polls_accepted_sum"
2775                    .to_string(),
2776                value: Value::Gauge(0f64),
2777                ..Default::default()
2778            },
2779            &Metric {
2780                metric: "avalanche_X_avalanche_whitelist_tx_polls_rejected_count"
2781                    .to_string(),
2782                value: Value::Counter(0f64),
2783                ..Default::default()
2784            },
2785            &Metric {
2786                metric: "avalanche_X_avalanche_whitelist_tx_polls_rejected_sum"
2787                    .to_string(),
2788                value: Value::Gauge(0f64),
2789                ..Default::default()
2790            },
2791            &Metric {
2792                metric: "avalanche_X_avalanche_whitelist_tx_processing"
2793                    .to_string(),
2794                value: Value::Gauge(0f64),
2795                ..Default::default()
2796            },
2797            &Metric {
2798                metric: "avalanche_X_avalanche_whitelist_tx_rejected_count"
2799                    .to_string(),
2800                value: Value::Counter(0f64),
2801                ..Default::default()
2802            },
2803            &Metric {
2804                metric: "avalanche_X_avalanche_whitelist_tx_rejected_sum"
2805                    .to_string(),
2806                value: Value::Gauge(0f64),
2807                ..Default::default()
2808            },
2809            &Metric {
2810                metric: "avalanche_X_avalanche_whitelist_vtx_issue_failure"
2811                    .to_string(),
2812                value: Value::Counter(0f64),
2813                ..Default::default()
2814            },
2815            &Metric {
2816                metric: "avalanche_X_avalanche_whitelist_vtx_issue_success"
2817                    .to_string(),
2818                value: Value::Counter(0f64),
2819                ..Default::default()
2820            },
2821
2822            &Metric {
2823                metric: "avalanche_db_batch_put_count"
2824                    .to_string(),
2825                value: Value::Counter(7.470929e+06f64),
2826                ..Default::default()
2827            },
2828            &Metric {
2829                metric: "avalanche_db_batch_put_sum"
2830                    .to_string(),
2831                value: Value::Gauge(4.234592257e+09f64),
2832                ..Default::default()
2833            },
2834            &Metric {
2835                metric: "avalanche_db_batch_write_count"
2836                    .to_string(),
2837                value: Value::Counter(259751f64),
2838                ..Default::default()
2839            },
2840            &Metric {
2841                metric: "avalanche_db_batch_write_sum"
2842                    .to_string(),
2843                value: Value::Gauge(2.8387298672e+10f64),
2844                ..Default::default()
2845            },
2846            &Metric {
2847                metric: "avalanche_db_compact_count"
2848                    .to_string(),
2849                value: Value::Counter(0f64),
2850                ..Default::default()
2851            },
2852            &Metric {
2853                metric: "avalanche_db_compact_sum"
2854                    .to_string(),
2855                value: Value::Gauge(0f64),
2856                ..Default::default()
2857            },
2858            &Metric {
2859                metric: "avalanche_db_delete_count"
2860                    .to_string(),
2861                value: Value::Counter(6f64),
2862                ..Default::default()
2863            },
2864            &Metric {
2865                metric: "avalanche_db_delete_sum"
2866                    .to_string(),
2867                value: Value::Gauge(75452f64),
2868                ..Default::default()
2869            },
2870            &Metric {
2871                metric: "avalanche_db_get_count"
2872                    .to_string(),
2873                value: Value::Counter(5.741585e+06f64),
2874                ..Default::default()
2875            },
2876            &Metric {
2877                metric: "avalanche_db_get_sum"
2878                    .to_string(),
2879                value: Value::Gauge(3.57862202207e+11f64),
2880                ..Default::default()
2881            },
2882            &Metric {
2883                metric: "avalanche_db_put_count"
2884                    .to_string(),
2885                value: Value::Counter(2599f64),
2886                ..Default::default()
2887            },
2888            &Metric {
2889                metric: "avalanche_db_put_sum"
2890                    .to_string(),
2891                value: Value::Gauge(8.6561039e+07f64),
2892                ..Default::default()
2893            },
2894            &Metric {
2895                metric: "avalanche_health_checks_failing"
2896                    .to_string(),
2897                value: Value::Gauge(0f64),
2898                ..Default::default()
2899            },
2900            &Metric {
2901                metric: "avalanche_liveness_checks_failing"
2902                    .to_string(),
2903                value: Value::Gauge(0f64),
2904                ..Default::default()
2905            },
2906            &Metric {
2907                metric: "avalanche_network_codec_accepted_state_summary_compress_time_count".to_string(),
2908                value: Value::Counter(0f64),
2909                ..Default::default()
2910            },
2911            &Metric {
2912                metric: "avalanche_network_codec_accepted_state_summary_compress_time_sum".to_string(),
2913                value: Value::Gauge(0f64),
2914                ..Default::default()
2915            },
2916            &Metric {
2917                metric: "avalanche_network_codec_accepted_state_summary_decompress_time_count".to_string(),
2918                value: Value::Counter(0f64),
2919                ..Default::default()
2920            },
2921            &Metric {
2922                metric: "avalanche_network_codec_accepted_state_summary_decompress_time_sum".to_string(),
2923                value: Value::Gauge(0f64),
2924                ..Default::default()
2925            },
2926            &Metric {
2927                metric: "avalanche_network_codec_ancestors_compress_time_count".to_string(),
2928                value: Value::Counter(0f64),
2929                ..Default::default()
2930            },
2931            &Metric {
2932                metric: "avalanche_network_codec_ancestors_compress_time_sum".to_string(),
2933                value: Value::Gauge(0f64),
2934                ..Default::default()
2935            },
2936            &Metric {
2937                metric: "avalanche_network_codec_ancestors_decompress_time_count".to_string(),
2938                value: Value::Counter(0f64),
2939                ..Default::default()
2940            },
2941            &Metric {
2942                metric: "avalanche_network_codec_ancestors_decompress_time_sum".to_string(),
2943                value: Value::Gauge(0f64),
2944                ..Default::default()
2945            },
2946            &Metric {
2947                metric: "avalanche_network_codec_app_gossip_compress_time_count".to_string(),
2948                value: Value::Counter(257138f64),
2949                ..Default::default()
2950            },
2951            &Metric {
2952                metric: "avalanche_network_codec_app_gossip_compress_time_sum".to_string(), 
2953                value: Value::Gauge(1.33156939569e+11f64),
2954                ..Default::default()
2955            },
2956            &Metric {
2957                metric: "avalanche_network_codec_app_gossip_decompress_time_count".to_string(), 
2958                value: Value::Counter(2.352039e+06f64),
2959                ..Default::default()
2960            },
2961            &Metric {
2962                metric: "avalanche_network_codec_app_gossip_decompress_time_sum".to_string(), 
2963                value: Value::Gauge(2.2997482905e+11f64),
2964                ..Default::default()
2965            },
2966            &Metric {
2967                metric: "avalanche_network_codec_app_request_compress_time_count".to_string(),
2968                value: Value::Counter(0f64),
2969                ..Default::default()
2970            },
2971            &Metric {
2972                metric: "avalanche_network_codec_app_request_compress_time_sum".to_string(),
2973                value: Value::Gauge(0f64),
2974                ..Default::default()
2975            },
2976            &Metric {
2977                metric: "avalanche_network_codec_app_request_decompress_time_count".to_string(),
2978                value: Value::Counter(0f64),
2979                ..Default::default()
2980            },
2981            &Metric {
2982                metric: "avalanche_network_codec_app_request_decompress_time_sum".to_string(),
2983                value: Value::Gauge(0f64),
2984                ..Default::default()
2985            },
2986            &Metric {
2987                metric: "avalanche_network_codec_app_response_compress_time_count".to_string(),
2988                value: Value::Counter(0f64),
2989                ..Default::default()
2990            },
2991            &Metric {
2992                metric: "avalanche_network_codec_app_response_compress_time_sum".to_string(),
2993                value: Value::Gauge(0f64),
2994                ..Default::default()
2995            },
2996            &Metric {
2997                metric: "avalanche_network_codec_app_response_decompress_time_count".to_string(),
2998                value: Value::Counter(0f64),
2999                ..Default::default()
3000            },
3001            &Metric {
3002                metric: "avalanche_network_codec_app_response_decompress_time_sum".to_string(),
3003                value: Value::Gauge(0f64),
3004                ..Default::default()
3005            },
3006            &Metric {
3007                metric: "avalanche_network_codec_get_accepted_state_summary_compress_time_count".to_string(),
3008                value: Value::Counter(0f64),
3009                ..Default::default()
3010            },
3011            &Metric {
3012                metric: "avalanche_network_codec_get_accepted_state_summary_compress_time_sum".to_string(),
3013                value: Value::Gauge(0f64),
3014                ..Default::default()
3015            },
3016            &Metric {
3017                metric: "avalanche_network_codec_get_accepted_state_summary_decompress_time_count".to_string(),
3018                value: Value::Counter(0f64),
3019                ..Default::default()
3020            },
3021            &Metric {
3022                metric: "avalanche_network_codec_get_accepted_state_summary_decompress_time_sum".to_string(),
3023                value: Value::Gauge(0f64),
3024                ..Default::default()
3025            },
3026            &Metric {
3027                metric: "avalanche_network_codec_peerlist_compress_time_count".to_string(), 
3028                value: Value::Counter(6463f64),
3029                ..Default::default()
3030            },
3031            &Metric {
3032                metric: "avalanche_network_codec_peerlist_compress_time_sum".to_string(), 
3033                value: Value::Gauge(1.601674227e+09f64),
3034                ..Default::default()
3035            },
3036            &Metric {
3037                metric: "avalanche_network_codec_peerlist_decompress_time_count".to_string(), 
3038                value: Value::Counter(57968f64),
3039                ..Default::default()
3040            },
3041            &Metric {
3042                metric: "avalanche_network_codec_peerlist_decompress_time_sum".to_string(), 
3043                value: Value::Gauge(4.688250786e+09f64),
3044                ..Default::default()
3045            },
3046            &Metric {
3047                metric: "avalanche_network_codec_push_query_compress_time_count".to_string(), 
3048                value: Value::Counter(43306f64),
3049                ..Default::default()
3050            },
3051            &Metric {
3052                metric: "avalanche_network_codec_push_query_compress_time_sum".to_string(), 
3053                value: Value::Gauge(1.03463977378e+11f64),
3054                ..Default::default()
3055            },
3056            &Metric {
3057                metric: "avalanche_network_codec_push_query_decompress_time_count".to_string(), 
3058                value: Value::Counter(342488f64),
3059                ..Default::default()
3060            },
3061            &Metric {
3062                metric: "avalanche_network_codec_push_query_decompress_time_sum".to_string(), 
3063                value: Value::Gauge(4.00810717995e+11f64),
3064                ..Default::default()
3065            },
3066            &Metric {
3067                metric: "avalanche_network_codec_put_compress_time_count".to_string(), 
3068                value: Value::Counter(163833f64),
3069                ..Default::default()
3070            },
3071            &Metric {
3072                metric: "avalanche_network_codec_put_compress_time_sum".to_string(), 
3073                value: Value::Gauge(1.54368659176e+11f64),
3074                ..Default::default()
3075            },
3076            &Metric {
3077                metric: "avalanche_network_codec_put_decompress_time_count".to_string(), 
3078                value: Value::Counter(1.437452e+06f64),
3079                ..Default::default()
3080            },
3081            &Metric {
3082                metric: "avalanche_network_codec_put_decompress_time_sum".to_string(), 
3083                value: Value::Gauge(3.63660179076e+11f64),
3084                ..Default::default()
3085            },
3086            &Metric {
3087                metric: "avalanche_network_codec_state_summary_frontier_compress_time_count".to_string(),
3088                value: Value::Counter(0f64),
3089                ..Default::default()
3090            },
3091            &Metric {
3092                metric: "avalanche_network_codec_state_summary_frontier_compress_time_sum".to_string(),
3093                value: Value::Gauge(0f64),
3094                ..Default::default()
3095            },
3096            &Metric {
3097                metric: "avalanche_network_codec_state_summary_frontier_decompress_time_count".to_string(),
3098                value: Value::Counter(0f64),
3099                ..Default::default()
3100            },
3101            &Metric {
3102                    metric: "avalanche_network_codec_state_summary_frontier_decompress_time_sum".to_string(),
3103                    value: Value::Gauge(0f64),
3104                ..Default::default()
3105            },
3106            &Metric {
3107                metric: "avalanche_network_get_ancestors_failed"
3108                    .to_string(),
3109                value: Value::Counter(0f64),
3110                ..Default::default()
3111            },
3112            &Metric {
3113                metric: "avalanche_network_get_ancestors_received"
3114                    .to_string(),
3115                value: Value::Counter(0f64),
3116                ..Default::default()
3117            },
3118            &Metric {
3119                metric: "avalanche_network_get_ancestors_received_bytes"
3120                    .to_string(),
3121                value: Value::Counter(0f64),
3122                ..Default::default()
3123            },
3124            &Metric {
3125                metric: "avalanche_network_get_ancestors_sent"
3126                    .to_string(),
3127                value: Value::Counter(0f64),
3128                ..Default::default()
3129            },
3130            &Metric {
3131                metric: "avalanche_network_get_ancestors_sent_bytes"
3132                    .to_string(),
3133                value: Value::Counter(0f64),
3134                ..Default::default()
3135            },
3136            &Metric {
3137                metric: "avalanche_network_get_failed"
3138                    .to_string(),
3139                value: Value::Counter(0f64),
3140                ..Default::default()
3141            },
3142            &Metric {
3143                metric: "avalanche_network_get_received"
3144                    .to_string(),
3145                value: Value::Counter(4596f64),
3146                ..Default::default()
3147            },
3148            &Metric {
3149                metric: "avalanche_network_get_received_bytes"
3150                    .to_string(),
3151                value: Value::Counter(353892f64),
3152                ..Default::default()
3153            },
3154            &Metric {
3155                metric: "avalanche_network_get_sent"
3156                    .to_string(),
3157                value: Value::Counter(4734f64),
3158                ..Default::default()
3159            },
3160            &Metric {
3161                metric: "avalanche_network_get_sent_bytes"
3162                    .to_string(),
3163                value: Value::Counter(364518f64),
3164                ..Default::default()
3165            },
3166            &Metric {
3167                metric: "avalanche_network_inbound_conn_throttler_allowed"
3168                    .to_string(),
3169                value: Value::Counter(19f64),
3170                ..Default::default()
3171            },
3172            &Metric {
3173                metric: "avalanche_network_inbound_conn_throttler_rate_limited"
3174                    .to_string(),
3175                value: Value::Counter(11f64),
3176                ..Default::default()
3177            },
3178            &Metric {
3179                metric: "avalanche_network_node_uptime_rewarding_stake"
3180                    .to_string(),
3181                value: Value::Gauge(100f64),
3182                ..Default::default()
3183            },
3184            &Metric {
3185                metric: "avalanche_network_node_uptime_weighted_average"
3186                    .to_string(),
3187                value: Value::Gauge(99.19999000049998f64),
3188                ..Default::default()
3189            },
3190            &Metric {
3191                metric: "avalanche_network_peerlist_failed"
3192                    .to_string(),
3193                value: Value::Counter(0f64),
3194                ..Default::default()
3195            },
3196            &Metric {
3197                metric: "avalanche_network_peerlist_received"
3198                    .to_string(),
3199                value: Value::Counter(57968f64),
3200                ..Default::default()
3201            },
3202            &Metric {
3203                metric: "avalanche_network_peerlist_received_bytes"
3204                    .to_string(),
3205                value: Value::Counter(1.34188214e+08f64),
3206                ..Default::default()
3207            },
3208            &Metric {
3209                metric: "avalanche_network_peerlist_sent"
3210                    .to_string(),
3211                value: Value::Counter(57975f64),
3212                ..Default::default()
3213            },
3214            &Metric {
3215                metric: "avalanche_network_peerlist_sent_bytes"
3216                    .to_string(),
3217                value: Value::Counter(1.34280004e+08f64),
3218                ..Default::default()
3219            },
3220            &Metric {
3221                metric: "avalanche_network_peers"
3222                    .to_string(),
3223                value: Value::Gauge(9f64),
3224                ..Default::default()
3225            },
3226            &Metric {
3227                metric: "avalanche_network_peers_subnet"
3228                    .to_string(),
3229                labels: Some(Labels(
3230                        [("subnetID", "2At5uFe2kDiYsHziSqJeebizvF9zQbH4m9mPQbKdMKhEWJj5AW")]
3231                            .iter()
3232                            .map(pair_to_string)
3233                            .collect()
3234                    )),
3235                value: Value::Gauge(9f64),
3236                ..Default::default()
3237            },
3238            &Metric {
3239                metric: "avalanche_network_ping_failed"
3240                    .to_string(),
3241                value: Value::Counter(0f64),
3242                ..Default::default()
3243            },
3244            &Metric {
3245                metric: "avalanche_network_ping_received"
3246                    .to_string(),
3247                value: Value::Counter(154521f64),
3248                ..Default::default()
3249            },
3250            &Metric {
3251                metric: "avalanche_network_ping_received_bytes"
3252                    .to_string(),
3253                value: Value::Counter(154521f64),
3254                ..Default::default()
3255            },
3256            &Metric {
3257                metric: "avalanche_network_ping_sent"
3258                    .to_string(),
3259                value: Value::Counter(154530f64),
3260                ..Default::default()
3261            },
3262            &Metric {
3263                metric: "avalanche_network_ping_sent_bytes"
3264                    .to_string(),
3265                value: Value::Counter(154530f64),
3266                ..Default::default()
3267            },
3268            &Metric {
3269                metric: "avalanche_network_pong_failed"
3270                    .to_string(),
3271                value: Value::Counter(0f64),
3272                ..Default::default()
3273            },
3274            &Metric {
3275                metric: "avalanche_network_pong_received"
3276                    .to_string(),
3277                value: Value::Counter(154521f64),
3278                ..Default::default()
3279            },
3280            &Metric {
3281                metric: "avalanche_network_pong_received_bytes"
3282                    .to_string(),
3283                value: Value::Counter(309042f64),
3284                ..Default::default()
3285            },
3286            &Metric {
3287                metric: "avalanche_network_pong_sent"
3288                    .to_string(),
3289                value: Value::Counter(154521f64),
3290                ..Default::default()
3291            },
3292            &Metric {
3293                metric: "avalanche_network_pong_sent_bytes"
3294                    .to_string(),
3295                value: Value::Counter(309042f64),
3296                ..Default::default()
3297            },
3298            &Metric {
3299                metric: "avalanche_network_pull_query_failed"
3300                    .to_string(),
3301                value: Value::Counter(0f64),
3302                ..Default::default()
3303            },
3304            &Metric {
3305                metric: "avalanche_network_pull_query_received"
3306                    .to_string(),
3307                value: Value::Counter(5.740569e+06f64),
3308                ..Default::default()
3309            },
3310            &Metric {
3311                metric: "avalanche_network_pull_query_received_bytes"
3312                    .to_string(),
3313                value: Value::Counter(4.42023813e+08f64),
3314                ..Default::default()
3315            },
3316            &Metric {
3317                metric: "avalanche_network_pull_query_sent"
3318                    .to_string(),
3319                value: Value::Counter(5.72831e+06f64),
3320                ..Default::default()
3321            },
3322            &Metric {
3323                metric: "avalanche_network_pull_query_sent_bytes"
3324                    .to_string(),
3325                value: Value::Counter(4.4107987e+08f64),
3326                ..Default::default()
3327            },
3328            &Metric {
3329                metric: "avalanche_network_push_query_failed"
3330                    .to_string(),
3331                value: Value::Counter(0f64),
3332                ..Default::default()
3333            },
3334            &Metric {
3335                metric: "avalanche_network_push_query_received"
3336                    .to_string(),
3337                value: Value::Counter(342488f64),
3338                ..Default::default()
3339            },
3340            &Metric {
3341                metric: "avalanche_network_push_query_received_bytes"
3342                    .to_string(),
3343                value: Value::Counter(2.384757172e+09f64),
3344                ..Default::default()
3345            },
3346            &Metric {
3347                metric: "avalanche_network_push_query_sent"
3348                    .to_string(),
3349                value: Value::Counter(342523f64),
3350                ..Default::default()
3351            },
3352            &Metric {
3353                metric: "avalanche_network_push_query_sent_bytes"
3354                    .to_string(),
3355                value: Value::Counter(2.386930255e+09f64),
3356                ..Default::default()
3357            },
3358            &Metric {
3359                metric: "avalanche_network_put_failed"
3360                    .to_string(),
3361                value: Value::Counter(0f64),
3362                ..Default::default()
3363            },
3364            &Metric {
3365                metric: "avalanche_network_put_received"
3366                    .to_string(),
3367                value: Value::Counter(1.437452e+06f64),
3368                ..Default::default()
3369            },
3370            &Metric {
3371                metric: "avalanche_network_put_received_bytes"
3372                    .to_string(),
3373                value: Value::Counter(4.42895033e+09f64),
3374                ..Default::default()
3375            },
3376            &Metric {
3377                metric: "avalanche_network_put_sent"
3378                    .to_string(),
3379                value: Value::Counter(1.437383e+06f64),
3380                ..Default::default()
3381            },
3382            &Metric {
3383                metric: "avalanche_network_put_sent_bytes"
3384                    .to_string(),
3385                value: Value::Counter(4.428109922e+09f64),
3386                ..Default::default()
3387            },
3388            &Metric {
3389                metric: "avalanche_network_throttler_outbound_acquire_failures"
3390                    .to_string(),
3391                value: Value::Counter(0f64),
3392                ..Default::default()
3393            },
3394            &Metric {
3395                metric: "avalanche_network_throttler_outbound_acquire_successes"
3396                    .to_string(),
3397                value: Value::Counter(1.627736e+07f64),
3398                ..Default::default()
3399            },
3400            &Metric {
3401                metric: "avalanche_network_times_connected"
3402                    .to_string(),
3403                value: Value::Counter(24f64),
3404                ..Default::default()
3405            },
3406            &Metric {
3407                metric: "avalanche_network_times_disconnected"
3408                    .to_string(),
3409                value: Value::Counter(15f64),
3410                ..Default::default()
3411            },
3412            &Metric {
3413                metric: "avalanche_network_version_failed"
3414                    .to_string(),
3415                value: Value::Counter(0f64),
3416                ..Default::default()
3417            },
3418            &Metric {
3419                metric: "avalanche_network_version_received"
3420                    .to_string(),
3421                value: Value::Counter(24f64),
3422                ..Default::default()
3423            },
3424            &Metric {
3425                metric: "avalanche_network_version_received_bytes"
3426                    .to_string(),
3427                value: Value::Counter(4126f64),
3428                ..Default::default()
3429            },
3430            &Metric {
3431                metric: "avalanche_network_version_sent"
3432                    .to_string(),
3433                value: Value::Counter(24f64),
3434                ..Default::default()
3435            },
3436            &Metric {
3437                metric: "avalanche_network_version_sent_bytes"
3438                    .to_string(),
3439                value: Value::Counter(4104f64),
3440                ..Default::default()
3441            },
3442            &Metric {
3443                metric: "avalanche_process_max_fds"
3444                    .to_string(),
3445                value: Value::Gauge(32768f64),
3446                ..Default::default()
3447            },
3448            &Metric {
3449                metric: "avalanche_process_open_fds"
3450                    .to_string(),
3451                value: Value::Gauge(463f64),
3452                ..Default::default()
3453            },
3454            &Metric {
3455                metric: "avalanche_process_resident_memory_bytes"
3456                    .to_string(),
3457                value: Value::Gauge(3.33867008e+09f64),
3458                ..Default::default()
3459            },
3460            &Metric {
3461                metric: "avalanche_process_virtual_memory_bytes"
3462                    .to_string(),
3463                value: Value::Gauge(6.609301504e+09f64),
3464                ..Default::default()
3465            },
3466            &Metric {
3467                metric: "avalanche_readiness_checks_failing"
3468                    .to_string(),
3469                value: Value::Gauge(0f64),
3470                ..Default::default()
3471            },
3472            &Metric {
3473                metric: "avalanche_requests_average_latency"
3474                    .to_string(),
3475                value: Value::Gauge(754948.8775182138f64),
3476                ..Default::default()
3477            },
3478            &Metric {
3479                metric: "avalanche_network_accept_failed".to_string(),
3480                labels: Some(Labels(
3481                    [("error", "temporary")]
3482                        .iter()
3483                        .map(pair_to_string)
3484                        .collect()
3485                )),
3486                value: Value::Counter(0f64),
3487                ..Default::default()
3488            },
3489            &Metric {
3490                metric: "avalanche_network_accept_failed".to_string(),
3491                labels: Some(Labels(
3492                    [("error", "timeout")]
3493                        .iter()
3494                        .map(pair_to_string)
3495                        .collect()
3496                )),
3497                value: Value::Counter(0f64),
3498                ..Default::default()
3499            },
3500            &Metric {
3501                metric: "avalanche_network_proto_codec_push_query_compress_time_count".to_string(),
3502                value: Value::Counter(2012f64),
3503                ..Default::default()
3504            },
3505            &Metric {
3506                metric: "avalanche_network_proto_codec_push_query_compress_time_sum".to_string(),
3507                value: Value::Gauge(9.8401986e+07f64),
3508                ..Default::default()
3509            },
3510            &Metric {
3511                metric: "avalanche_network_proto_codec_push_query_decompress_time_count".to_string(),
3512                value: Value::Counter(2012f64),
3513                ..Default::default()
3514            },
3515            &Metric {
3516                metric: "avalanche_network_proto_codec_push_query_decompress_time_sum".to_string(),
3517                value: Value::Gauge(9.8401986e+07f64),
3518                ..Default::default()
3519            },
3520            &Metric {
3521                metric: "avalanche_7y7zwo7XatqnX4dtTakLo32o7jkMX4XuDa26WaxbCXoCT1qKK_vm_eth_rpc_duration_all"
3522                    .to_string(),
3523                value: Value::Summary(vec![
3524                    SummaryCount{quantile: 0.5, count: 327057.0f64},
3525                    SummaryCount{quantile: 0.75, count: 382043.0f64},
3526                    SummaryCount{quantile: 0.95, count: 2659645.649999993f64},
3527                    SummaryCount{quantile: 0.99, count: 198345217.87000003f64},
3528                    SummaryCount{quantile: 0.999, count: 200404035.783f64},
3529                    SummaryCount{quantile: 0.9999, count: 200408762.0f64},
3530                    ]),
3531                ..Default::default()
3532            },
3533        ].iter().enumerate() {
3534        assert_eq!(matched[i], v.clone(), "mismatched at {}", i);
3535
3536        cnt = i + 1;
3537    };
3538    assert_eq!(cnt, matched.len());
3539
3540    log::info!("matched total {} metrics", cnt);
3541}
3542
3543#[must_use]
3544pub fn pair_to_string(pair: &(&str, &str)) -> (String, String) {
3545    return (pair.0.to_owned(), pair.1.to_owned());
3546}
3547
3548fn parse_golang_float(s: &str) -> Result<f64, <f64 as std::str::FromStr>::Err> {
3549    match s.to_lowercase().as_str() {
3550        "nan" => return Ok(std::f64::NAN), // f64::parse doesn't recognize 'nan'
3551        s => return s.parse::<f64>(),      // f64::parse expects lowercase [+-]inf
3552    }
3553}
3554
3555/// RUST_LOG=debug cargo test --all-features --package prometheus-manager --lib -- test_golang_float --exact --show-output
3556#[test]
3557fn test_golang_float() {
3558    assert_eq!(parse_golang_float("1.0"), Ok(1.0f64));
3559    assert_eq!(parse_golang_float("-1.0"), Ok(-1.0f64));
3560    assert!(parse_golang_float("NaN").unwrap().is_nan());
3561    assert_eq!(parse_golang_float("Inf"), Ok(std::f64::INFINITY));
3562    assert_eq!(parse_golang_float("+Inf"), Ok(std::f64::INFINITY));
3563    assert_eq!(parse_golang_float("-Inf"), Ok(std::f64::NEG_INFINITY));
3564}