Skip to content

Commit 031fe9b

Browse files
author
Pancake Team
committed
Fix
0 parents  commit 031fe9b

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

.gitignore.gz

37 Bytes
Binary file not shown.

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
instance_id = $(shell curl "http://10.1.9.49:4001/api/instance_id?name=cakecloud-db&project_name=${project}")
2+
hostname = $(shell hostname)
3+
4+
all: prepare_files save_env_vars start_service
5+
6+
prepare_files:
7+
mkdir -p ./vars
8+
cp -r ../postgres_exporter ~ 2>/dev/null || :
9+
sudo cp -r ./cakecloud-postgres-exporter.service /etc/systemd/system/
10+
11+
save_env_vars:
12+
DATA_SOURCE_NAME="postgresql://${database_user}:${database_password}@localhost:${port}/${database_name}"
13+
echo $(DATA_SOURCE_NAME) >> vars/DATA_SOURCE_NAME
14+
PG_EXPORTER_CONSTANT_LABELS="domain=${instance_id}_${hostname}"
15+
echo $(PG_EXPORTER_CONSTANT_LABELS) >> vars/PG_EXPORTER_CONSTANT_LABELS
16+
17+
start:
18+
export DATA_SOURCE_NAME=$(shell cat ./vars/DATA_SOURCE_NAME); \
19+
export PG_EXPORTER_CONSTANT_LABELS=$(shell cat ./vars/PG_EXPORTER_CONSTANT_LABELS); \
20+
./postgres_exporter
21+
22+
start_service:
23+
sudo systemctl enable cakecloud-postgres-exporter.service
24+
sudo systemctl start cakecloud-postgres-exporter.service

cakecloud-postgres-exporter.service

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Custom Postgresql exporter to use with Prometheus
3+
After=network.target
4+
5+
[Service]
6+
Type=simple
7+
User=cc
8+
ExecStart=/usr/bin/make -C ~/postgres_exporter start
9+
Restart=on-failure
10+
# For system level services, use `multi-user.target`
11+
[Install]
12+
WantedBy=multi-user.target

postgres_exporter

13.4 MB
Binary file not shown.

0 commit comments

Comments
 (0)