File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ use crate::{
2222 queries:: { FallibleQueryTasks , PreparedQuery , SizedBatch } ,
2323 session:: CassandraSession ,
2424 } ,
25+ metrics,
2526 settings:: cassandra_db:: EnvVars ,
2627} ;
2728
@@ -145,6 +146,7 @@ impl Rbac509InsertQuery {
145146 }
146147 } ,
147148 Err ( report) => {
149+ metrics:: rbac:: inc_invalid_rbac_reg_count ( ) ;
148150 self . invalid . push ( insert_rbac509_invalid:: Params :: new (
149151 catalyst_id,
150152 txn_hash,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ pub(crate) mod chain_indexer;
88pub ( crate ) mod endpoint;
99pub ( crate ) mod health;
1010pub ( crate ) mod memory;
11+ pub ( crate ) mod rbac;
1112
1213/// Initialize Prometheus metrics.
1314///
Original file line number Diff line number Diff line change 1+ //! Metrics related to RBAC Registration Chain analytics.
2+
3+ use crate :: settings:: Settings ;
4+
5+ /// Increments the `INVALID_RBAC_REGISTRATION_COUNT` metric.
6+ pub ( crate ) fn inc_invalid_rbac_reg_count ( ) {
7+ let api_host_names = Settings :: api_host_names ( ) . join ( "," ) ;
8+ let service_id = Settings :: service_id ( ) ;
9+ let network = Settings :: cardano_network ( ) . to_string ( ) ;
10+
11+ reporter:: INVALID_RBAC_REGISTRATION_COUNT
12+ . with_label_values ( & [ & api_host_names, service_id, & network] )
13+ . inc ( ) ;
14+ }
15+
16+ /// All the related RBAC Registration Chain metrics to the Prometheus
17+ /// service are inside this module.
18+ pub ( crate ) mod reporter {
19+ use std:: sync:: LazyLock ;
20+
21+ use prometheus:: { register_int_counter_vec, IntCounterVec } ;
22+
23+ /// Labels for the metrics.
24+ const METRIC_LABELS : [ & str ; 3 ] = [ "api_host_names" , "service_id" , "network" ] ;
25+
26+ /// This counter increases every when we found invalid RBAC registration during
27+ /// indexing.
28+ pub ( crate ) static INVALID_RBAC_REGISTRATION_COUNT : LazyLock < IntCounterVec > =
29+ LazyLock :: new ( || {
30+ register_int_counter_vec ! (
31+ "invalid_rbac_registration_count" ,
32+ "Number of Invalid RBAC registrations found during indexing" ,
33+ & METRIC_LABELS
34+ )
35+ . unwrap ( )
36+ } ) ;
37+ }
You can’t perform that action at this time.
0 commit comments