I am helplessly trying to get my postgres exporter running but in vain. After running my postgres container and then running my postgres exporter container as the following :
terminal1%docker network create --subnet=192.168.1.0/24 --gateway=192.168.1.1 prometheus-net
terminal1%docker run --network=prometheus-net -p 5432:5432 -e POSTGRES_PASSWORD=password postgres
terminal2%docker run \
--net=prometheus-net \
-p 9187:9187 \
-v /Users/johndoe/queries.yaml:/etc/postgres-exporter/queries.yaml \
-e DATA_SOURCE_NAME="postgresql://postgres:[email protected]:5432/postgres?sslmode=disable" \
quay.io/prometheuscommunity/postgres-exporter \
--extend.query-path=/etc/postgres-exporter/queries.yaml
terminal3%cat /Users/johndoe/queries.yaml
custom_queries:
- name: user_count
help: "Total number of users"
query: "SELECT COUNT(*) FROM users"
metrics:
- user_count:
usage: "GAUGE"
description: "Total number of users"
So when I : terminal3%curl http://localhost:9187/metrics
I get this error right here in terminal2 : caller=postgres_exporter.go:674 level=error msg="Failed to reload user queries" path=/etc/postgres-exporter/queries.yaml err="yaml: unmarshal errors:\n line 2: cannot unmarshal !!seq into main.UserQuery"
I double checked whether the table users exists in the schema postgres and yes it does. Also there seems no problem with the connection between the exporter and postgres server. I just have no idea why my .yaml file cannot be parsed.
There was a problem with the syntax of my queries.yaml. The right syntax should look like :