File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments