This recipe is almost entirely based on the PostgreSQL collectd plugin. The large block of code that we inserted into the local.conf file will configure that module with a single query that it will execute and transmit to the monitor server. The monitor system will automatically accept these results and integrate them into any data that it's already storing.
The <Query> block deserves some explanation. Every custom query that we define must have a name. In this case, TPS stands for Transactions Per Second, and it is a common database metric. The first thing we add is the statement being executed. The statement we included gathers basic data from the pg_stat_database table for every database in this particular PostgreSQL instance. ...