-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * Replace deprecated SQL exporter with non-deprecated one per #81 * remove comments to clean up yaml file * default to local cht-couch2pg db values in example * set example yaml file to actually work with default couch2pg settings * set min_interval 60s which means calls happening <60s hit cache instead DB directly * remove config file that shouldn't have been committed * update git ignore, place holder for prom scrape * omg get entry command and file name correct * got prometheus scrape config working \o/ * adding scrape config * finalize dashboard, update example sql, remove comments from scrape, change gauge -> counter * add dev restart script, update detail dashboard json * start to get dev and test environs to work * normalize passwords for sql and couch2pg * feat(na): path to new compose file in CI, update readme how to add new sql * feat(na): fix path to ci test files * feat(na): update git ignore to include test fake file * fix(na): add set -e and fake cht to restart script per feedback
- Loading branch information
1 parent
227a64b
commit 0d4cb13
Showing
23 changed files
with
212 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ postgres_exporter.yml | |
grafana.ini | ||
delete-rules.yml | ||
build | ||
exporters/postgres/sql_servers.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Global settings and defaults. | ||
global: | ||
# Subtracted from Prometheus' scrape_timeout to give us some headroom and prevent Prometheus from | ||
# timing out first. | ||
scrape_timeout_offset: 500ms | ||
# Minimum interval between collector runs: by default (0s) collectors are executed on every scrape. | ||
# Medic recommends setting this to 60s so that the endpoint cant be used as a proxy to DOS the upstream Postgres server | ||
# see https://github.com/burningalchemist/sql_exporter/issues/447#issue-2144289744 for more info | ||
min_interval: 60s | ||
# Maximum number of open connections to any one target. Metric queries will run concurrently on | ||
# multiple connections. | ||
max_connections: 3 | ||
# Maximum number of idle connections to any one target. | ||
max_idle_connections: 3 | ||
# Maximum amount of time a connection may be reused to any one target. Infinite by default. | ||
max_connection_lifetime: 10m | ||
|
||
collector_files: | ||
- "/etc/sql_exporter/couch2pg_collector.yml" | ||
|
||
jobs: | ||
- job_name: db_targets | ||
collectors: [couch2pg] | ||
enable_ping: true | ||
static_configs: | ||
- targets: | ||
# " same as URL in cht-instances.yml ": 'postgres://USERNAME:PASSWORD@DB_SERVER_IP/DATABASE | ||
"fake-cht:8081": 'postgres://cht_couch2pg:cht_couch2pg_password@postgres:5432/cht?sslmode=disable' # //NOSONAR - password is safe to commit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
set -e | ||
echo ' | ||
, /-. | ||
((___/ __> | ||
/ } ---- CHT WATCHDOG RESTART SCRIPT ---- | ||
\ .--.( | ||
\\ \\ | ||
' | ||
|
||
echo;echo "Killing...";echo | ||
docker compose \ | ||
-f docker-compose.yml \ | ||
-f exporters/postgres/compose.yml \ | ||
-f development/fake-cht/docker-compose.fake-cht.yml \ | ||
kill | ||
|
||
echo;echo "Starting...";echo | ||
docker compose \ | ||
-f docker-compose.yml \ | ||
-f exporters/postgres/compose.yml \ | ||
-f development/fake-cht/docker-compose.fake-cht.yml \ | ||
up -d \ | ||
--remove-orphans | ||
|
||
# shellcheck disable=SC2046 | ||
ips=$(docker inspect $(docker ps -q ) \ | ||
--format='{{ printf "%-50s" .Name}} {{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' \ | ||
| tr "\/" " " | tr -s " " ) | ||
|
||
# shellcheck disable=SC2046 | ||
readarray -t ipsArray <<< $(echo -e "${ips}") | ||
|
||
final="" | ||
# loop it | ||
for ipLine in "${ipsArray[@]}"; do | ||
ip=$(echo "$ipLine" | cut -f3 -d" ") | ||
name=$(echo "$ipLine" |cut -f2 -d" ") | ||
case $name in | ||
cht-watchdog-extra_sql_exporter-1) | ||
portPath=":9187/metrics";; | ||
cht-watchdog-grafana-1) | ||
portPath=":3000";; | ||
cht-watchdog-postgres-exporter-1) | ||
portPath=":9187/metrics";; | ||
cht-watchdog-json-exporter-1) | ||
portPath=":7979/metrics";; | ||
cht-watchdog-prometheus-1) | ||
portPath=":9090/targets?search=";; | ||
cht-watchdog-sql_exporter-1) | ||
portPath=":9399/metrics";; | ||
*) | ||
portPath="";; | ||
esac | ||
final+="${name} http://${ip}${portPath}\n" | ||
done | ||
|
||
echo;echo "Services:";echo | ||
echo -e "${final}" | column -t | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
version: "3.9" | ||
|
||
volumes: | ||
prometheus-data: | ||
driver: local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
services: | ||
|
||
# todo: uncomment and get this working | ||
prometheus: | ||
volumes: | ||
- ./exporters/postgres/scrape.yml:/etc/prometheus/scrape_configs/cht-postgres.yml:ro | ||
|
||
sql_exporter: | ||
restart: unless-stopped | ||
image: burningalchemist/sql_exporter:latest | ||
command: --config.file=/etc/sql_exporter/sql_servers.yml | ||
volumes: | ||
- "./exporters/postgres/:/etc/sql_exporter/" | ||
ports: | ||
- "${SQL_EXPORTER_IP:-127.0.0.1}:${SQL_EXPORTER_PORT:-9399}:9399" | ||
networks: | ||
- cht-watchdog-net |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
collector_name: couch2pg | ||
|
||
queries: | ||
- query_name: couch2pg-query | ||
query: | | ||
SELECT | ||
substring(seq for position('-' in seq) - 1) as sequence, | ||
substring(source from position('/' in source) + 1) as db | ||
FROM | ||
couchdb_progress | ||
WHERE | ||
source like '%/%' and | ||
seq like '%-%' | ||
metrics: | ||
- metric_name: couch2pg_progress_sequence | ||
type: counter | ||
help: 'couch2pg backlog.' | ||
key_labels: | ||
- db | ||
values: [sequence] | ||
query_ref: couch2pg-query |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
scrape_configs: | ||
- job_name: sql_exporter | ||
static_configs: | ||
- targets: ['sql_exporter:9399'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Global settings and defaults. | ||
global: | ||
# Subtracted from Prometheus' scrape_timeout to give us some headroom and prevent Prometheus from | ||
# timing out first. | ||
scrape_timeout_offset: 500ms | ||
# Minimum interval between collector runs: by default (0s) collectors are executed on every scrape. | ||
# Medic recommends setting this to 60s so that the endpoint cant be used as a proxy to DOS the upstream Postgres server | ||
# see https://github.com/burningalchemist/sql_exporter/issues/447#issue-2144289744 for more info | ||
min_interval: 60s | ||
# Maximum number of open connections to any one target. Metric queries will run concurrently on | ||
# multiple connections. | ||
max_connections: 3 | ||
# Maximum number of idle connections to any one target. | ||
max_idle_connections: 3 | ||
# Maximum amount of time a connection may be reused to any one target. Infinite by default. | ||
max_connection_lifetime: 10m | ||
|
||
collector_files: | ||
- "/etc/sql_exporter/couch2pg_collector.yml" | ||
|
||
jobs: | ||
- job_name: db_targets | ||
collectors: [couch2pg] | ||
enable_ping: true | ||
static_configs: | ||
- targets: | ||
# " same as URL in cht-instances.yml ": 'postgres://USERNAME:PASSWORD@DB_SERVER_IP/DATABASE | ||
"172-17-0-1.local-ip.medicmobile.org:10464": 'postgres://cht_couch2pg:[email protected]:5432/cht?sslmode=disable' # //NOSONAR - password is safe to commit | ||
|
Oops, something went wrong.