title | summary |
---|---|
TiProxy API |
Learn how to use the TiProxy API to access its configuration, health status, and monitoring data. |
TiProxy provides API endpoints for accessing its configuration, health status, and monitoring data.
Note:
TiProxy API is specifically designed for debugging purposes and might not be fully compatible with future capabilities introduced in TiProxy. It's not recommended to include this tool in application or utility development to get information.
The address for accessing the TiProxy API is http://${host}:${port}${path}
, where ${host}:${port}
is specified by the TiProxy configuration item api.addr
, and ${path}
is the specific API endpoint you want to access. For example:
curl http://127.0.0.1:3080/api/admin/config/
GET /api/admin/config/
The query parameter is as follows:
format
: (optional) specifies the format of the returned configuration. Value options arejson
andtoml
. The default value istoml
.
The following example gets the TiProxy configuration in JSON format:
curl "http://127.0.0.1:3080/api/admin/config/?format=json"
Currently, you can only use the TOML format to modify TiProxy configuration. Unspecified configuration items will remain unchanged, so you only need to specify the items that you want to modify.
PUT /api/admin/config/
You need to provide the TiProxy configuration in TOML format. For example:
[log]
level='warning'
The following example sets log.level
as 'warning'
, while leaving other configuration items unchanged.
-
Get the current TiProxy configuration:
curl http://127.0.0.1:3080/api/admin/config/
The output is as follows:
[log] encoder = 'tidb' level = 'info'
-
Specify the value of
log.level
in thetest.toml
file, and then send aPUT /api/admin/config/
request to update the value oflog.level
:$ cat test.toml [log] level='warning' $ curl -X PUT --data-binary @test.toml http://127.0.0.1:3080/api/admin/config/
-
Get the modified TiProxy configuration:
curl http://127.0.0.1:3080/api/admin/config/
The output is as follows:
[log] encoder = 'tidb' level = 'warning'
This endpoint is used to get the health status of TiProxy and the checksum of the configuration. When TiProxy is running normally, this endpoint returns the checksum of the configuration. When TiProxy is shutting down or offline, it returns an error.
GET /api/debug/health
curl http://127.0.0.1:3080/api/debug/health
The output is as follows:
{"config_checksum":3006078629}
GET /metrics/
curl http://127.0.0.1:3080/metrics/