mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-23 01:16:30 +00:00
Make prometheus port configurable (#121)
* Make prometheus port configurable * Update circleci config
This commit is contained in:
@@ -11,9 +11,12 @@ host = "0.0.0.0"
|
|||||||
# Port to run on, same as PgBouncer used in this example.
|
# Port to run on, same as PgBouncer used in this example.
|
||||||
port = 6432
|
port = 6432
|
||||||
|
|
||||||
# enable prometheus exporter on port 9930
|
# Whether to enable prometheus exporter or not.
|
||||||
enable_prometheus_exporter = true
|
enable_prometheus_exporter = true
|
||||||
|
|
||||||
|
# Port at which prometheus exporter listens on.
|
||||||
|
prometheus_exporter_port = 9930
|
||||||
|
|
||||||
# How long to wait before aborting a server connection (ms).
|
# How long to wait before aborting a server connection (ms).
|
||||||
connect_timeout = 100
|
connect_timeout = 100
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ psql -h 127.0.0.1 -p 6432 -c 'SELECT 1'
|
|||||||
### Config
|
### Config
|
||||||
|
|
||||||
| **Name** | **Description** | **Examples** |
|
| **Name** | **Description** | **Examples** |
|
||||||
|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
|
|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
|
||||||
| **`general`** | | |
|
| **`general`** | | |
|
||||||
| `host` | The pooler will run on this host, 0.0.0.0 means accessible from everywhere. | `0.0.0.0` |
|
| `host` | The pooler will run on this host, 0.0.0.0 means accessible from everywhere. | `0.0.0.0` |
|
||||||
| `port` | The pooler will run on this port. | `6432` |
|
| `port` | The pooler will run on this port. | `6432` |
|
||||||
|
| `enable_prometheus_exporter` | Enable prometheus exporter which will export metrics in prometheus exposition format. | `true` |
|
||||||
|
| `prometheus_exporter_port` | Port at which prometheus exporter listens on. | `9930` |
|
||||||
| `pool_size` | Maximum allowed server connections per pool. Pools are separated for each user/shard/server role. The connections are allocated as needed. | `15` |
|
| `pool_size` | Maximum allowed server connections per pool. Pools are separated for each user/shard/server role. The connections are allocated as needed. | `15` |
|
||||||
| `pool_mode` | The pool mode to use, i.e. `session` or `transaction`. | `transaction` |
|
| `pool_mode` | The pool mode to use, i.e. `session` or `transaction`. | `transaction` |
|
||||||
| `connect_timeout` | Maximum time to establish a connection to a server (milliseconds). If reached, the server is banned and the next target is attempted. | `5000` |
|
| `connect_timeout` | Maximum time to establish a connection to a server (milliseconds). If reached, the server is banned and the next target is attempted. | `5000` |
|
||||||
@@ -50,6 +52,7 @@ psql -h 127.0.0.1 -p 6432 -c 'SELECT 1'
|
|||||||
| `shutdown_timeout` | Maximum time to give clients during shutdown before forcibly killing client connections (ms). | `60000` |
|
| `shutdown_timeout` | Maximum time to give clients during shutdown before forcibly killing client connections (ms). | `60000` |
|
||||||
| `healthcheck_delay` | How long to keep connection available for immediate re-use, without running a healthcheck query on it | `30000` |
|
| `healthcheck_delay` | How long to keep connection available for immediate re-use, without running a healthcheck query on it | `30000` |
|
||||||
| `ban_time` | Ban time for a server (seconds). It won't be allowed to serve transactions until the ban expires; failover targets will be used instead. | `60` |
|
| `ban_time` | Ban time for a server (seconds). It won't be allowed to serve transactions until the ban expires; failover targets will be used instead. | `60` |
|
||||||
|
| `autoreload` | Enable auto-reload of config after fixed time-interval. | `false` |
|
||||||
| | | |
|
| | | |
|
||||||
| **`user`** | | |
|
| **`user`** | | |
|
||||||
| `name` | The user name. | `sharding_user` |
|
| `name` | The user name. | `sharding_user` |
|
||||||
@@ -58,6 +61,7 @@ psql -h 127.0.0.1 -p 6432 -c 'SELECT 1'
|
|||||||
| **`shards`** | Shards are numerically numbered starting from 0; the order in the config is preserved by the pooler to route queries accordingly. | `[shards.0]` |
|
| **`shards`** | Shards are numerically numbered starting from 0; the order in the config is preserved by the pooler to route queries accordingly. | `[shards.0]` |
|
||||||
| `servers` | List of servers to connect to and their roles. A server is: `[host, port, role]`, where `role` is either `primary` or `replica`. | `["127.0.0.1", 5432, "primary"]` |
|
| `servers` | List of servers to connect to and their roles. A server is: `[host, port, role]`, where `role` is either `primary` or `replica`. | `["127.0.0.1", 5432, "primary"]` |
|
||||||
| `database` | The name of the database to connect to. This is the same on all servers that are part of one shard. | |
|
| `database` | The name of the database to connect to. This is the same on all servers that are part of one shard. | |
|
||||||
|
| | | |
|
||||||
| **`query_router`** | | |
|
| **`query_router`** | | |
|
||||||
| `default_role` | Traffic is routed to this role by default (round-robin), unless the client specifies otherwise. Default is `any`, for any role available. | `any`, `primary`, `replica` |
|
| `default_role` | Traffic is routed to this role by default (round-robin), unless the client specifies otherwise. Default is `any`, for any role available. | `any`, `primary`, `replica` |
|
||||||
| `query_parser_enabled` | Enable the query parser which will inspect incoming queries and route them to a primary or replicas. | `false` |
|
| `query_parser_enabled` | Enable the query parser which will inspect incoming queries and route them to a primary or replicas. | `false` |
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:13
|
image: postgres:14
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
POSTGRES_HOST_AUTH_METHOD: md5
|
POSTGRES_HOST_AUTH_METHOD: md5
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ host = "0.0.0.0"
|
|||||||
# Port to run on, same as PgBouncer used in this example.
|
# Port to run on, same as PgBouncer used in this example.
|
||||||
port = 6432
|
port = 6432
|
||||||
|
|
||||||
# enable prometheus exporter on port 9930
|
# Whether to enable prometheus exporter or not.
|
||||||
enable_prometheus_exporter = true
|
enable_prometheus_exporter = true
|
||||||
|
|
||||||
|
# Port at which prometheus exporter listens on.
|
||||||
|
prometheus_exporter_port = 9930
|
||||||
|
|
||||||
# How long to wait before aborting a server connection (ms).
|
# How long to wait before aborting a server connection (ms).
|
||||||
connect_timeout = 5000
|
connect_timeout = 5000
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ host = "0.0.0.0"
|
|||||||
# Port to run on, same as PgBouncer used in this example.
|
# Port to run on, same as PgBouncer used in this example.
|
||||||
port = 6432
|
port = 6432
|
||||||
|
|
||||||
# enable prometheus exporter on port 9930
|
# Whether to enable prometheus exporter or not.
|
||||||
enable_prometheus_exporter = true
|
enable_prometheus_exporter = true
|
||||||
|
|
||||||
|
# Port at which prometheus exporter listens on.
|
||||||
|
prometheus_exporter_port = 9930
|
||||||
|
|
||||||
# How long to wait before aborting a server connection (ms).
|
# How long to wait before aborting a server connection (ms).
|
||||||
connect_timeout = 5000
|
connect_timeout = 5000
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ pub struct General {
|
|||||||
pub host: String,
|
pub host: String,
|
||||||
pub port: i16,
|
pub port: i16,
|
||||||
pub enable_prometheus_exporter: Option<bool>,
|
pub enable_prometheus_exporter: Option<bool>,
|
||||||
|
pub prometheus_exporter_port: i16,
|
||||||
pub connect_timeout: u64,
|
pub connect_timeout: u64,
|
||||||
pub healthcheck_timeout: u64,
|
pub healthcheck_timeout: u64,
|
||||||
pub shutdown_timeout: u64,
|
pub shutdown_timeout: u64,
|
||||||
@@ -136,6 +137,7 @@ impl Default for General {
|
|||||||
host: String::from("localhost"),
|
host: String::from("localhost"),
|
||||||
port: 5432,
|
port: 5432,
|
||||||
enable_prometheus_exporter: Some(false),
|
enable_prometheus_exporter: Some(false),
|
||||||
|
prometheus_exporter_port: 9930,
|
||||||
connect_timeout: 5000,
|
connect_timeout: 5000,
|
||||||
healthcheck_timeout: 1000,
|
healthcheck_timeout: 1000,
|
||||||
shutdown_timeout: 60000,
|
shutdown_timeout: 60000,
|
||||||
@@ -271,6 +273,10 @@ impl From<&Config> for std::collections::HashMap<String, String> {
|
|||||||
let mut static_settings = vec![
|
let mut static_settings = vec![
|
||||||
("host".to_string(), config.general.host.to_string()),
|
("host".to_string(), config.general.host.to_string()),
|
||||||
("port".to_string(), config.general.port.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(),
|
"connect_timeout".to_string(),
|
||||||
config.general.connect_timeout.to_string(),
|
config.general.connect_timeout.to_string(),
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ async fn main() {
|
|||||||
let config = get_config();
|
let config = get_config();
|
||||||
|
|
||||||
if let Some(true) = config.general.enable_prometheus_exporter {
|
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) {
|
let http_addr = match SocketAddr::from_str(&http_addr_str) {
|
||||||
Ok(addr) => addr,
|
Ok(addr) => addr,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ use crate::config::Address;
|
|||||||
use crate::pool::get_all_pools;
|
use crate::pool::get_all_pools;
|
||||||
use crate::stats::get_stats;
|
use crate::stats::get_stats;
|
||||||
|
|
||||||
pub const HTTP_PORT: usize = 9930;
|
|
||||||
|
|
||||||
struct MetricHelpType {
|
struct MetricHelpType {
|
||||||
help: &'static str,
|
help: &'static str,
|
||||||
ty: &'static str,
|
ty: &'static str,
|
||||||
|
|||||||
Reference in New Issue
Block a user