Skip to content

Commit

Permalink
server: report cpu cores quota to Prometheus (tikv#8414)
Browse files Browse the repository at this point in the history
Signed-off-by: Howard Lau <[email protected]>
  • Loading branch information
howardlau1999 authored Aug 13, 2020
1 parent df2fab4 commit f024776
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use tikv::{
resolve,
service::{DebugService, DiagnosticsService},
status_server::StatusServer,
Node, RaftKv, Server, DEFAULT_CLUSTER_ID,
Node, RaftKv, Server, CPU_CORES_QUOTA_GAUGE, DEFAULT_CLUSTER_ID,
},
storage::{self, concurrency_manager::ConcurrencyManager, config::StorageConfigManger},
};
Expand All @@ -81,6 +81,7 @@ pub fn run_tikv(config: TiKvConfig) {

// Print resource quota.
SysQuota::new().log_quota();
CPU_CORES_QUOTA_GAUGE.set(SysQuota::new().cpu_cores_quota());

// Do some prepare works before start.
pre_start();
Expand Down
5 changes: 5 additions & 0 deletions src/server/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ lazy_static! {
exponential_buckets(1f64, 5f64, 10).unwrap()
)
.unwrap();
pub static ref CPU_CORES_QUOTA_GAUGE: Gauge = register_gauge!(
"tikv_server_cpu_cores_quota",
"Total CPU cores quota for TiKV server"
)
.unwrap();
}

make_auto_flush_static_metric! {
Expand Down
1 change: 1 addition & 0 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod transport;
pub use self::config::{Config, DEFAULT_CLUSTER_ID, DEFAULT_LISTENING_ADDR};
pub use self::errors::{Error, Result};
pub use self::metrics::CONFIG_ROCKSDB_GAUGE;
pub use self::metrics::CPU_CORES_QUOTA_GAUGE;
pub use self::node::{create_raft_storage, Node};
pub use self::raft_client::RaftClient;
pub use self::raftkv::RaftKv;
Expand Down

0 comments on commit f024776

Please sign in to comment.