-
Notifications
You must be signed in to change notification settings - Fork 1
Custom Metrics
It's nice to think of pgsampler as a more generic tool for limited character data out of Postgresql on a periodic basis.
It may or may not be a good idea, but there is no reason different metrics, or even aggregated data, could not be exported.
The functions all exist in /lib/commands/
Take a look at other commands for example. Generally there are two types of commands, functions that execute an SQL statement and functions that collect data from an internal function or the filesystem.
Functions which use SPI are designed to be trivial to implement. Consider <a href="https://github.com/no0p/pgsampler/blob/master/lib/commands/heartbeat.c>heartbeat.c which instantiates a string for an sql statement and passes it to the function exec_to_command. Then return the result.
Note that different groups of commands are run at different frequencies depending on the block they are in. Frequencies are keyed on the cycle variable and controlled by sampling rate GUCs.
Take a look at other calls to commands. Depending on the output mode, the result is passed directly to write_to_csv or appended to a commands string buffer. When it is in output mode, this commands string will be written to a socket.
Add a reference to the new command file similar to other commands.
If you have any issues please get in touch. robert@relsys.io