Debian Codegraph @

debian/tests/exporter

raw
1 #!/bin/sh
2
3 set -eux
4
5 pg_virtualenv <<-'EOF'
6 set -eux
7
8 psql <<EOT
9 CREATE TABLE sql_exporter (l text, a int);
10 INSERT INTO sql_exporter (l, a) VALUES ('testlabel', 5432 / 2);
11 EOT
12
13 config=$(mktemp --tmpdir sql_exporter.XXXXXX)
14 trap 'kill $pid || :; rm -f $config' 0 2 3 15
15
16 cat > $config <<EOT
17 jobs:
18 - name: "example"
19 interval: 0
20 connections:
21 - 'postgres://:$PGPORT/postgres?sslmode=disable'
22 queries:
23 - name: "test_table"
24 help: "test query for autopkgtest"
25 labels:
26 - "l"
27 values:
28 - "a"
29 query: "SELECT * FROM sql_exporter"
30 EOT
31 cat $config
32
33 unset PGSYSCONFDIR # exporter gets confused otherwise
34 prometheus-sql-exporter -config.file $config -web.listen-address localhost:9238 &
35 pid="$!"
36 sleep 1
37
38 curl -f http://localhost:9238/metrics | grep 'testlabel.*2716'
39 EOF