cat_gateway/metrics/
chain_indexer.rs

1//! Metrics related to Chain Indexer analytics.
2
3/// All the related Chain Indexer reporting metrics to the Prometheus service are inside
4/// this module.
5pub(crate) mod reporter {
6    use std::sync::LazyLock;
7
8    use prometheus::{register_counter_vec, register_int_gauge_vec, CounterVec, IntGaugeVec};
9
10    /// Labels for the metrics.
11    const METRIC_LABELS: [&str; 3] = ["api_host_names", "service_id", "network"];
12
13    /// Chain Indexer current live tip slot#.
14    pub(crate) static CURRENT_LIVE_TIP_SLOT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
15        register_int_gauge_vec!(
16            "indexer_current_live_tip_slot",
17            "Chain Indexer current live tip slot#",
18            &METRIC_LABELS
19        )
20        .unwrap()
21    });
22
23    /// Chain Indexer current immutable tip slot#.
24    pub(crate) static CURRENT_IMMUTABLE_TIP_SLOT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
25        register_int_gauge_vec!(
26            "indexer_current_immutable_tip_slot",
27            "Chain Indexer current immutable tip slot#",
28            &METRIC_LABELS
29        )
30        .unwrap()
31    });
32
33    /// Chain Indexer highest complete indexed slot#.
34    pub(crate) static HIGHEST_COMPLETE_INDEXED_SLOT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
35        register_int_gauge_vec!(
36            "indexer_highest_complete_indexed_slot",
37            "Chain Indexer highest complete indexed slot#",
38            &METRIC_LABELS
39        )
40        .unwrap()
41    });
42
43    /// Chain Indexer number of current running indexer tasks.
44    pub(crate) static RUNNING_INDEXER_TASKS_COUNT: LazyLock<IntGaugeVec> = LazyLock::new(|| {
45        register_int_gauge_vec!(
46            "indexer_running_indexer_tasks_count",
47            "Chain Indexer number of current running indexer tasks",
48            &METRIC_LABELS
49        )
50        .unwrap()
51    });
52
53    /// Chain Indexer number of times triggering backward data purge.
54    pub(crate) static TRIGGERED_BACKWARD_PURGES_COUNT: LazyLock<CounterVec> = LazyLock::new(|| {
55        register_counter_vec!(
56            "indexer_triggered_backward_purges_count",
57            "Chain Indexer number of times triggering backward data purge",
58            &METRIC_LABELS
59        )
60        .unwrap()
61    });
62
63    /// Chain Indexer number of times triggering forward data purge.
64    pub(crate) static TRIGGERED_FORWARD_PURGES_COUNT: LazyLock<CounterVec> = LazyLock::new(|| {
65        register_counter_vec!(
66            "indexer_triggered_forward_purges_count",
67            "Chain Indexer number of times triggering forward data purge",
68            &METRIC_LABELS
69        )
70        .unwrap()
71    });
72
73    /// Chain Indexer number of purged slots.
74    pub(crate) static PURGED_SLOTS: LazyLock<IntGaugeVec> = LazyLock::new(|| {
75        register_int_gauge_vec!(
76            "indexer_triggered_purged_slots",
77            "Chain Indexer total number of slots that have already been purged",
78            &METRIC_LABELS
79        )
80        .unwrap()
81    });
82
83    /// Chain Indexer indicator whether tip is reached or in progress.
84    pub(crate) static REACHED_TIP: LazyLock<IntGaugeVec> = LazyLock::new(|| {
85        register_int_gauge_vec!(
86            "indexer_reached_tip_indicator",
87            "Chain Indexer indicator whether tip is reached or in progress",
88            &METRIC_LABELS
89        )
90        .unwrap()
91    });
92}