Make prometheus port configurable (#121)

* Make prometheus port configurable

* Update circleci config
This commit is contained in:
Pradeep Chhetri
2022-08-14 01:25:14 +08:00
committed by GitHub
parent be254cedd9
commit 52303cc808
8 changed files with 51 additions and 31 deletions

View File

@@ -118,6 +118,7 @@ pub struct General {
pub host: String,
pub port: i16,
pub enable_prometheus_exporter: Option<bool>,
pub prometheus_exporter_port: i16,
pub connect_timeout: u64,
pub healthcheck_timeout: u64,
pub shutdown_timeout: u64,
@@ -136,6 +137,7 @@ impl Default for General {
host: String::from("localhost"),
port: 5432,
enable_prometheus_exporter: Some(false),
prometheus_exporter_port: 9930,
connect_timeout: 5000,
healthcheck_timeout: 1000,
shutdown_timeout: 60000,
@@ -271,6 +273,10 @@ impl From<&Config> for std::collections::HashMap<String, String> {
let mut static_settings = vec![
("host".to_string(), config.general.host.to_string()),
("port".to_string(), config.general.port.to_string()),
(
"prometheus_exporter_port".to_string(),
config.general.prometheus_exporter_port.to_string(),
),
(
"connect_timeout".to_string(),
config.general.connect_timeout.to_string(),

View File

@@ -99,7 +99,10 @@ async fn main() {
let config = get_config();
if let Some(true) = config.general.enable_prometheus_exporter {
let http_addr_str = format!("{}:{}", config.general.host, crate::prometheus::HTTP_PORT);
let http_addr_str = format!(
"{}:{}",
config.general.host, config.general.prometheus_exporter_port
);
let http_addr = match SocketAddr::from_str(&http_addr_str) {
Ok(addr) => addr,
Err(err) => {

View File

@@ -10,8 +10,6 @@ use crate::config::Address;
use crate::pool::get_all_pools;
use crate::stats::get_stats;
pub const HTTP_PORT: usize = 9930;
struct MetricHelpType {
help: &'static str,
ty: &'static str,