Add custom queries (DATA_VERSION 4)

This commit adds support for gathering statistics on custom queries.
The custom queries can be specified in the `conf.json` file under the
key `queries`.