RESTAPI endpoint

Restapi endpoint feature allows users to create new RESTAPI endpoints and execute scripts on behalf of ProxySQL. It is disabled by default.

At the moment there are two examples of scripts that are used for querying memory metrics and exporting users from MySQL database to ProxySQL.

RESTAPI configuration

The RESTAPI is configured with two variables: admin-restapi_enabled and admin-restapi_port. To enable the RESTAPI you need to set the admin variable:

Now the RESTAPI will be enabled and listening on port 6070.

Installing dependencies

The python package mysqlclient must be installed in order for the export_users package to work. This can be accomplished by the pip command:

or, if ProxySQL is running under sudo:

Creating a new endpoint

In order to create a new RESTAPI endpoint, it must be defined in the restapi_routes table.

Calling metrics example using method POST

Parameters to the script are passed using json -d '{"user":"root", "password":"a", "host":"127.0.0.1", "port":"6032”}'

Calling metrics example using method GET

Parameters to the script are passed in the URL

Calling export_user example

The export_users script returns the number of records processed in the json response.