Hello everyone. In this post I will tell you about pgSCV - a new metrics exporter for PostgreSQL (and not only), why it is so good and what problems it solves.
Surely everyone who uses Prometheus and PostgreSQL has encountered postgres_exporter. This exporter is pretty easy to get up and running. It also has the ability to expand, based on your request, you can describe metrics and take them off. If you have a good knowledge of how post-gres statistics work, you can collect a fairly large number of metrics. But as you know, in addition to the metrics of Postgres itself, it is also desirable to collect system metrics, and if there are auxiliary services in the infrastructure, for example, connection pullers (pgbouncer, odyssey, etc.), then metrics should also be taken from them. It turns out that we need to supply more exporters.
In pgSCV I tried to solve both of these problems.
Solution one. pgSCV can immediately take a very large number of metrics from PostgreSQL without the need for additional configuration. In my opinion, this greatly facilitates the task of the initial launch . Instead of wasting time writing a custom configuration to capture additional metrics, you can get them out of the box right away. The ability to configure custom metrics is also present . A reasonable question arises - what if there are too many metrics and not all of them are needed? In this case, you can disable the collection of metrics or limit the list of databases from which you want to collect metrics .
Second solution. At the moment, pgSCV is able to take metrics from the system, PostgreSQL and Pgbouncer. To do this, he automatically searches for these services and starts collecting metrics from them. Obviously, to collect metrics from network services, you need connection details. Capturing metrics is not limited to local services. If desired, you can specify the collection of metrics from services hosted on other nodes.
A typical use case is to simply run pgSCV. In the example below, it is assumed that the user has already been created.
curl -O -L https://github.com/weaponry/pgscv/releases/download/v0.5.0/pgscv_0.5.0_linux_amd64.tar.gz
tar xvzf pgscv_0.5.0_linux_amd64.tar.gz
cat << EOF > pgscv.yaml
defaults:
postgres_username: "monitoring"
postgres_password: "supersecretpassword"
EOF
./pgscv --config-file pgscv.yaml
After launch, you can open a second console and use curl -s 127.0.0.1:9890/metrics
to get a list of metrics.
I note that pgSCV was created for the needs of Weaponry (a project for monitoring PostgreSQL and everything around it), now pgSCV, in my opinion, has stabilized and I am not ashamed to show it.
That's all, thanks for your attention! If you have any ideas, wishes or bugs, then write to the discussions or issues . Finally, a few links: