Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add some example to http api doc #8785

Merged
merged 3 commits into from
Dec 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 193 additions & 0 deletions docs/tidb_http_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
```shell
curl http://{TiDBIP}:10080/status
```
```shell
$curl http://127.0.0.1:10080/status
{
"connections": 0,
"git_hash": "f572e33854e1c0f942f031e9656d0004f99995c6",
"version": "5.7.10-TiDB-v2.1.0-rc.3-355-gf572e3385-dirty"
}
```

1. Get all metrics of TiDB

Expand All @@ -19,30 +27,131 @@
```shell
curl http://{TiDBIP}:10080/regions/meta
```
```shell
$curl http://127.0.0.1:10080/regions/meta
[
{
"leader": {
"id": 5,
"store_id": 1
},
"peers": [
{
"id": 5,
"store_id": 1
}
],
"region_epoch": {
"conf_ver": 1,
"version": 2
},
"region_id": 4
}
]
```

1. Get the table/index of hot regions

```shell
curl http://{TiDBIP}:10080/regions/hot
```
```shell
$curl http://127.0.0.1:10080/regions/hot
{
"read": [

],
"write": [
{
"db_name": "sbtest1",
"table_name": "sbtest13",
"index_name": "",
"flow_bytes": 220718,
"max_hot_degree": 12,
"region_count": 1
}
]
}
```

1. Get the information of a specific region by ID

```shell
curl http://{TiDBIP}:10080/regions/{regionID}
```
```shell
$curl http://127.0.0.1:10080/regions/4001
{
"end_key": "dIAAAAAAAAEk",
"frames": [
{
"db_name": "test",
"is_record": true,
"table_id": 286,
"table_name": "t1"
}
],
"region_id": 4001,
"start_key": "dIAAAAAAAAEe"
}
```

1. Get regions Information from db.table

```shell
curl http://{TiDBIP}:10080/tables/{db}/{table}/regions
```
```shell
$curl http://127.0.0.1:10080/tables/test/t1/regions
{
"id": 286,
"indices": [],
"name": "t1",
"record_regions": [
{
"leader": {
"id": 4002,
"store_id": 1
},
"peers": [
{
"id": 4002,
"store_id": 1
}
],
"region_epoch": {
"conf_ver": 1,
"version": 83
},
"region_id": 4001
}
]
}
```

1. Get schema Information about all db

```shell
curl http://{TiDBIP}:10080/schema
```
```shell
$curl http://127.0.0.1:10080/schema
[
{
"charset": "utf8mb4",
"collate": "utf8mb4_bin",
"db_name": {
"L": "test",
"O": "test"
},
"id": 266,
"state": 5
},
.
.
.
]
```

1. Get schema Information about db

Expand Down Expand Up @@ -75,12 +184,41 @@
```shell
curl http://{TiDBIP}:10080/mvcc/key/{db}/{table}/{handle}
```
```shell
$curl http://127.0.0.1:10080/mvcc/key/test/t1/1
{
"info": {
"writes": [
{
"commit_ts": 405179368526053380,
"short_value": "CAICAkE=",
"start_ts": 405179368526053377
}
]
}
}
```

1. Get MVCC Information of the first key in the table with a specified start ts

```shell
curl http://{TiDBIP}:10080/mvcc/txn/{startTS}/{db}/{table}
```
```shell
$curl http://127.0.0.1:10080/mvcc/txn/405179368526053377/test/t1
{
"info": {
"writes": [
{
"commit_ts": 405179368526053380,
"short_value": "CAICAkE=",
"start_ts": 405179368526053377
}
]
},
"key": "dIAAAAAAAAEzX3KAAAAAAAAAAQ=="
}
```

1. Get MVCC Information by a hex value

Expand All @@ -95,6 +233,20 @@
```
*Hint: For the index column which column type is timezone dependent, e.g. `timestamp`, convert its value to UTC
timezone.*
```shell
$curl http://127.0.0.1:10080/mvcc/index/test/t1/idx/1\?a\=A
{
"info": {
"writes": [
{
"commit_ts": 405179523374252037,
"short_value": "MA==",
"start_ts": 405179523374252036
}
]
}
}
```

1. Scatter regions of the specified table, add a `scatter-range` scheduler for the PD and the range is same as the table range.

Expand All @@ -121,12 +273,53 @@ timezone.*
```shell
curl http://{TiDBIP}:10080/info
```
```shell
$curl http://127.0.0.1:10080/info
{
"ddl_id": "f7e73ed5-63b4-4cb4-ba7c-42b32dc74e77",
"git_hash": "f572e33854e1c0f942f031e9656d0004f99995c6",
"ip": "",
"is_owner": true,
"lease": "45s",
"listening_port": 4000,
"status_port": 10080,
"version": "5.7.10-TiDB-v2.1.0-rc.3-355-gf572e3385-dirty"
}
```

1. Get TiDB cluster all servers information.

```shell
curl http://{TiDBIP}:10080/info/all
```
```shell
$curl http://127.0.0.1:10080/info/all
{
"all_servers_info": {
"275a19ae-d248-4dc0-b78c-6613a7509423": {
"ddl_id": "275a19ae-d248-4dc0-b78c-6613a7509423",
"git_hash": "f572e33854e1c0f942f031e9656d0004f99995c6",
"ip": "192.168.197.206",
"lease": "45s",
"listening_port": 4001,
"status_port": 10081,
"version": "5.7.10-TiDB-v2.1.0-rc.3-355-gf572e3385-dirty"
},
"f7e73ed5-63b4-4cb4-ba7c-42b32dc74e77": {
"ddl_id": "f7e73ed5-63b4-4cb4-ba7c-42b32dc74e77",
"git_hash": "f572e33854e1c0f942f031e9656d0004f99995c6",
"ip": "192.168.197.206",
"lease": "45s",
"listening_port": 4000,
"status_port": 10080,
"version": "5.7.10-TiDB-v2.1.0-rc.3-355-gf572e3385-dirty"
}
},
"is_all_server_version_consistent": true,
"owner_id": "f7e73ed5-63b4-4cb4-ba7c-42b32dc74e77",
"servers_num": 2
}
```

1. Enable/Disable TiDB server general log

Expand Down