Skip to content

Commit 1b166b4

Browse files
authored
create a prometheus exporter on a standard http port (#107)
* create a hyper server and add option to enable it in config * move prometheus stuff to its own file; update format * create metric type and help lookup table * finish the metric help type map * switch to a boolean and a standard port * dont emit unimplemented metrics * fail if curl returns a non 200 * resolve conflicts * move log out of config.show and into main * terminating new line * upgrade curl * include unimplemented stats
1 parent 7592339 commit 1b166b4

File tree

11 files changed

+500
-7
lines changed

11 files changed

+500
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
command: "cargo fmt --check"
3535
- run:
3636
name: "Install dependencies"
37-
command: "sudo apt-get update && sudo apt-get install -y psmisc postgresql-contrib-12 postgresql-client-12 ruby ruby-dev libpq-dev python3 python3-pip lcov llvm-11"
37+
command: "sudo apt-get update && sudo apt-get install -y psmisc postgresql-contrib-12 postgresql-client-12 ruby ruby-dev libpq-dev python3 python3-pip lcov llvm-11 && sudo apt-get upgrade curl"
3838
- run:
3939
name: "Install rust tools"
4040
command: "cargo install cargo-binutils rustfilt && rustup component add llvm-tools-preview"

.circleci/pgcat.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ host = "0.0.0.0"
1111
# Port to run on, same as PgBouncer used in this example.
1212
port = 6432
1313

14+
# enable prometheus exporter on port 9930
15+
enable_prometheus_exporter = true
16+
1417
# How long to wait before aborting a server connection (ms).
1518
connect_timeout = 100
1619

.circleci/run_tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ toxiproxy-cli create -l 127.0.0.1:5433 -u 127.0.0.1:5432 postgres_replica
3131

3232
start_pgcat "info"
3333

34+
# Check that prometheus is running
35+
curl --fail localhost:9930/metrics
36+
3437
export PGPASSWORD=sharding_user
3538
export PGDATABASE=sharded_db
3639

Cargo.lock

Lines changed: 247 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ base64 = "0.13"
3131
stringprep = "0.1"
3232
tokio-rustls = "0.23"
3333
rustls-pemfile = "1"
34+
hyper = { version = "0.14", features = ["full"] }
35+
phf = { version = "0.10", features = ["macros"] }

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ services:
1414
- "${PWD}/examples/docker/pgcat.toml:/etc/pgcat/pgcat.toml"
1515
ports:
1616
- "6432:6432"
17+
- "9090:9090"

examples/docker/pgcat.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ host = "0.0.0.0"
1111
# Port to run on, same as PgBouncer used in this example.
1212
port = 6432
1313

14+
# enable prometheus exporter on port 9930
15+
enable_prometheus_exporter = true
16+
1417
# How long to wait before aborting a server connection (ms).
1518
connect_timeout = 5000
1619

0 commit comments

Comments
 (0)