Skip to content

Commit

Permalink
statement,slowquery: add network transmission relative information
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <[email protected]>
  • Loading branch information
nolouch committed Feb 14, 2025
1 parent 7742e2e commit 65f17b3
Show file tree
Hide file tree
Showing 15 changed files with 491 additions and 5 deletions.
10 changes: 10 additions & 0 deletions pkg/apiserver/slowquery/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ type Model struct {
RU float64 `gorm:"column:RU" json:"ru" proj:"(Request_unit_write + Request_unit_read)" related:"Request_unit_write,Request_unit_read"`
QueuedTime float64 `gorm:"column:Time_queued_by_rc" json:"time_queued_by_rc"`
ResourceGroup string `gorm:"column:Resource_group" json:"resource_group"`

// Network fields
UnpackedBytesSentTiKVTotal uint `gorm:"column:Unpacked_bytes_sent_tikv_total" json:"unpacked_bytes_sent_tikv_total"`
UnpackedBytesReceivedTiKVTotal uint `gorm:"column:Unpacked_bytes_received_tikv_total" json:"unpacked_bytes_received_tikv_total"`
UnpackedBytesSentTiKVCrossZone uint `gorm:"column:Unpacked_bytes_sent_tikv_cross_zone" json:"unpacked_bytes_sent_tikv_cross_zone"`
UnpackedBytesReceivedTiKVCrossZone uint `gorm:"column:Unpacked_bytes_received_tikv_cross_zone" json:"unpacked_bytes_received_tikv_cross_zone"`
UnpackedBytesSentTiFlashTotal uint `gorm:"column:Unpacked_bytes_sent_tiflash_total" json:"unpacked_bytes_sent_tiflash_total"`
UnpackedBytesReceivedTiFlashTotal uint `gorm:"column:Unpacked_bytes_received_tiflash_total" json:"unpacked_bytes_received_tiflash_total"`
UnpackedBytesSentTiFlashCrossZone uint `gorm:"column:Unpacked_bytes_sent_tiflash_cross_zone" json:"unpacked_bytes_sent_tiflash_cross_zone"`
UnpackedBytesReceivedTiFlashCrossZone uint `gorm:"column:Unpacked_bytes_received_tiflash_cross_zone" json:"unpacked_bytes_received_tiflash_cross_zone"`
}

type Field struct {
Expand Down
11 changes: 10 additions & 1 deletion pkg/apiserver/statement/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ type Model struct {
AggSumRU float64 `json:"sum_ru" agg:"CAST(SUM(exec_count * (avg_request_unit_write + avg_request_unit_read)) AS DECIMAL(64, 2))" related:"avg_request_unit_write,avg_request_unit_read"`
AvgQueuedTime float64 `json:"avg_time_queued_by_rc" agg:"CAST(AVG(AVG_QUEUED_RC_TIME) AS DECIMAL(64, 2))" related:"AVG_QUEUED_RC_TIME"`
MaxQueuedTime float64 `json:"max_time_queued_by_rc" agg:"Max(MAX_QUEUED_RC_TIME)" related:"MAX_QUEUED_RC_TIME"`

// Network Fields
SumUnpackedBytesSentTiKVTotal uint `json:"sum_unpacked_bytes_sent_tikv_total" agg:"SUM(sum_unpacked_bytes_sent_tikv_total)"`
SumUnpackedBytesReceivedTiKVTotal uint `json:"sum_unpacked_bytes_received_tikv_total" agg:"SUM(sum_unpacked_bytes_received_tikv_total)"`
SumUnpackedBytesSentTiKVCrossZone uint `json:"sum_unpacked_bytes_sent_tikv_cross_zone" agg:"SUM(sum_unpacked_bytes_sent_tikv_cross_zone)"`
SumUnpackedBytesReceivedTiKVCrossZone uint `json:"sum_unpacked_bytes_received_tikv_cross_zone" agg:"SUM(sum_unpacked_bytes_received_tikv_cross_zone)"`
SumUnpackedBytesSentTiFlashTotal uint `json:"sum_unpacked_bytes_sent_tiflash_total" agg:"SUM(sum_unpacked_bytes_sent_tiflash_total)"`
SumUnpackedBytesReceivedTiFlashTotal uint `json:"sum_unpacked_bytes_received_tiflash_total" agg:"SUM(sum_unpacked_bytes_received_tiflash_total)"`
SumUnpackedBytesSentTiFlashCrossZone uint `json:"sum_unpacked_bytes_sent_tiflash_cross_zone" agg:"SUM(sum_unpacked_bytes_sent_tiflash_cross_zone)"`
SumUnpackedBytesReceivedTiFlashCrossZone uint `json:"sum_unpacked_bytes_received_tiflash_cross_zone" agg:"SUM(sum_unpacked_bytes_received_tiflash_cross_zone)"`
}

// tableNames example: "d1.a1,d2.a2,d1.a1,d3.a3"
Expand Down Expand Up @@ -195,7 +205,6 @@ func filterFieldsByColumns(fields []Field, columns []string) []Field {
filteredFields = append(filteredFields, f)
}
}

return filteredFields
}

Expand Down
1 change: 0 additions & 1 deletion pkg/apiserver/statement/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (s *Service) queryStatements(
if err != nil {
return nil, err
}

query := db.
Select(selectStmt).
Table(statementsTable).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,54 @@ export interface SlowqueryModel {
* @memberof SlowqueryModel
*/
'txn_start_ts'?: string;
/**
*
* @type {number}
* @memberof SlowqueryModel
*/
'unpacked_bytes_received_tiflash_cross_zone'?: number;
/**
*
* @type {number}
* @memberof SlowqueryModel
*/
'unpacked_bytes_received_tiflash_total'?: number;
/**
*
* @type {number}
* @memberof SlowqueryModel
*/
'unpacked_bytes_received_tikv_cross_zone'?: number;
/**
*
* @type {number}
* @memberof SlowqueryModel
*/
'unpacked_bytes_received_tikv_total'?: number;
/**
*
* @type {number}
* @memberof SlowqueryModel
*/
'unpacked_bytes_sent_tiflash_cross_zone'?: number;
/**
*
* @type {number}
* @memberof SlowqueryModel
*/
'unpacked_bytes_sent_tiflash_total'?: number;
/**
*
* @type {number}
* @memberof SlowqueryModel
*/
'unpacked_bytes_sent_tikv_cross_zone'?: number;
/**
* Network Fields
* @type {number}
* @memberof SlowqueryModel
*/
'unpacked_bytes_sent_tikv_total'?: number;
/**
* Connection
* @type {string}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,54 @@ export interface StatementModel {
* @memberof StatementModel
*/
'sum_ru'?: number;
/**
*
* @type {number}
* @memberof StatementModel
*/
'sum_unpacked_bytes_received_tiflash_cross_zone'?: number;
/**
*
* @type {number}
* @memberof StatementModel
*/
'sum_unpacked_bytes_received_tiflash_total'?: number;
/**
*
* @type {number}
* @memberof StatementModel
*/
'sum_unpacked_bytes_received_tikv_cross_zone'?: number;
/**
*
* @type {number}
* @memberof StatementModel
*/
'sum_unpacked_bytes_received_tikv_total'?: number;
/**
*
* @type {number}
* @memberof StatementModel
*/
'sum_unpacked_bytes_sent_tiflash_cross_zone'?: number;
/**
*
* @type {number}
* @memberof StatementModel
*/
'sum_unpacked_bytes_sent_tiflash_total'?: number;
/**
*
* @type {number}
* @memberof StatementModel
*/
'sum_unpacked_bytes_sent_tikv_cross_zone'?: number;
/**
* Network Fields
* @type {number}
* @memberof StatementModel
*/
'sum_unpacked_bytes_sent_tikv_total'?: number;
/**
*
* @type {number}
Expand Down
50 changes: 50 additions & 0 deletions ui/packages/tidb-dashboard-client/swagger/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -5298,6 +5298,31 @@
"description": "TODO: Switch back to uint64 when modern browser as well as Swagger handles BigInt well.",
"type": "string"
},
"unpacked_bytes_received_tiflash_cross_zone": {
"type": "integer"
},
"unpacked_bytes_received_tiflash_total": {
"type": "integer"
},
"unpacked_bytes_received_tikv_cross_zone": {
"type": "integer"
},
"unpacked_bytes_received_tikv_total": {
"type": "integer"
},
"unpacked_bytes_sent_tiflash_cross_zone": {
"type": "integer"
},
"unpacked_bytes_sent_tiflash_total": {
"type": "integer"
},
"unpacked_bytes_sent_tikv_cross_zone": {
"type": "integer"
},
"unpacked_bytes_sent_tikv_total": {
"description": "Network Fields",
"type": "integer"
},
"user": {
"description": "Connection",
"type": "string"
Expand Down Expand Up @@ -5723,6 +5748,31 @@
"sum_ru": {
"type": "number"
},
"sum_unpacked_bytes_received_tiflash_cross_zone": {
"type": "integer"
},
"sum_unpacked_bytes_received_tiflash_total": {
"type": "integer"
},
"sum_unpacked_bytes_received_tikv_cross_zone": {
"type": "integer"
},
"sum_unpacked_bytes_received_tikv_total": {
"type": "integer"
},
"sum_unpacked_bytes_sent_tiflash_cross_zone": {
"type": "integer"
},
"sum_unpacked_bytes_sent_tiflash_total": {
"type": "integer"
},
"sum_unpacked_bytes_sent_tikv_cross_zone": {
"type": "integer"
},
"sum_unpacked_bytes_sent_tikv_total": {
"description": "Network Fields",
"type": "integer"
},
"sum_warnings": {
"type": "integer"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,69 @@ export const tabCoprItems = (data: SlowqueryModel) => [
{
key: 'rocksdb_key_skipped_count',
value: <ValueWithTooltip.Short value={data.rocksdb_key_skipped_count} />
},
{
key: 'unpacked_bytes_sent_tikv_total',
value: (
<ValueWithTooltip.ScaledBytes
value={data.unpacked_bytes_sent_tikv_total}
/>
)
},
{
key: 'unpacked_bytes_received_tikv_total',
value: (
<ValueWithTooltip.ScaledBytes
value={data.unpacked_bytes_received_tikv_total}
/>
)
},
{
key: 'unpacked_bytes_sent_tikv_cross_zone',
value: (
<ValueWithTooltip.ScaledBytes
value={data.unpacked_bytes_sent_tikv_cross_zone}
/>
)
},
{
key: 'unpacked_bytes_received_tikv_cross_zone',
value: (
<ValueWithTooltip.ScaledBytes
value={data.unpacked_bytes_received_tikv_cross_zone}
/>
)
},
{
key: 'unpacked_bytes_sent_tiflash_total',
value: (
<ValueWithTooltip.ScaledBytes
value={data.unpacked_bytes_sent_tiflash_total}
/>
)
},
{
key: 'unpacked_bytes_received_tiflash_total',
value: (
<ValueWithTooltip.ScaledBytes
value={data.unpacked_bytes_received_tiflash_total}
/>
)
},
{
key: 'unpacked_bytes_sent_tiflash_cross_zone',
value: (
<ValueWithTooltip.ScaledBytes
value={data.unpacked_bytes_sent_tiflash_cross_zone}
/>
)
},
{
key: 'unpacked_bytes_received_tiflash_cross_zone',
value: (
<ValueWithTooltip.ScaledBytes
value={data.unpacked_bytes_received_tiflash_cross_zone}
/>
)
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ slow_query:
time_queued_by_rc: The total time queued by RC
time_queued_by_rc_tooltip: 'The total wait time spent in the resource queue (note: {{distro.tikv}} executes requests in parallel so that this is not a wall time)'

# Network fields
unpacked_bytes_sent_tikv_total: Bytes Sent to TiKV
unpacked_bytes_sent_tikv_total_tooltip: The number of bytes sent to TiKV
unpacked_bytes_received_tikv_total: Bytes Received from TiKV
unpacked_bytes_received_tikv_total_tooltip: The number of bytes received from TiKV
unpacked_bytes_sent_tikv_cross_zone: Cross-Zone Bytes Sent to TiKV
unpacked_bytes_sent_tikv_cross_zone_tooltip: The number of bytes sent to TiKV across zones
unpacked_bytes_received_tikv_cross_zone: Cross-Zone Bytes Received from TiKV
unpacked_bytes_received_tikv_cross_zone_tooltip: The number of bytes received from TiKV across zones
unpacked_bytes_sent_tiflash_total: Bytes Sent to TiFlash
unpacked_bytes_sent_tiflash_total_tooltip: The number of bytes sent to TiFlash
unpacked_bytes_received_tiflash_total: Bytes Received from TiFlash
unpacked_bytes_received_tiflash_total_tooltip: The number of bytes received from TiFlash
unpacked_bytes_sent_tiflash_cross_zone: Cross-Zone Bytes Sent to TiFlash
unpacked_bytes_sent_tiflash_cross_zone_tooltip: The number of bytes sent to TiFlash across zones
unpacked_bytes_received_tiflash_cross_zone: Cross-Zone Bytes Received from TiFlash
unpacked_bytes_received_tiflash_cross_zone_tooltip: The number of bytes received from TiFlash across zones

common:
status:
success: Success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ slow_query:
time_queued_by_rc: RC 等待累积耗时
time_queued_by_rc_tooltip: SQL 语句在资源组队列中等待的累积时间(注:{{distro.tikv}} 会并行等待任务,因此该时间不是自然流逝时间)

# Network fields
unpacked_bytes_sent_tikv_total: 发送至 TiKV 的字节数
unpacked_bytes_sent_tikv_total_tooltip: 发送至 TiKV 的字节数
unpacked_bytes_received_tikv_total: 从 TiKV 接收的字节数
unpacked_bytes_received_tikv_total_tooltip: 从 TiKV 接收的字节数
unpacked_bytes_sent_tikv_cross_zone: 跨可用区发送至 TiKV 的字节数
unpacked_bytes_sent_tikv_cross_zone_tooltip: 跨可用区发送至 TiKV 的字节数
unpacked_bytes_received_tikv_cross_zone: 跨可用区从 TiKV 接收的字节数
unpacked_bytes_received_tikv_cross_zone_tooltip: 跨可用区从 TiKV 接收的字节数
unpacked_bytes_sent_tiflash_total: 发送至 TiFlash 的字节数
unpacked_bytes_sent_tiflash_total_tooltip: 发送至 TiFlash 的字节数
unpacked_bytes_received_tiflash_total: 从 TiFlash 接收的字节数
unpacked_bytes_received_tiflash_total_tooltip: 从 TiFlash 接收的字节数
unpacked_bytes_sent_tiflash_cross_zone: 跨可用区发送至 TiFlash 的字节数
unpacked_bytes_sent_tiflash_cross_zone_tooltip: 跨可用区发送至 TiFlash 的字节数
unpacked_bytes_received_tiflash_cross_zone: 跨可用区从 TiFlash 接收的字节数
unpacked_bytes_received_tiflash_cross_zone_tooltip: 跨可用区从 TiFlash 接收的字节数

common:
status:
success: 成功
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ export function slowQueryColumns(
// resource control
tcf.bar.single('ru', 'none', rows),
tcf.textWithTooltip('resource_group', rows),
tcf.bar.single('time_queued_by_rc', 's', rows)
tcf.bar.single('time_queued_by_rc', 's', rows),

// Network fields
tcf.bar.single('unpacked_bytes_sent_tikv_total', 'bytes', rows),
tcf.bar.single('unpacked_bytes_received_tikv_total', 'bytes', rows),
tcf.bar.single('unpacked_bytes_sent_tikv_cross_zone', 'bytes', rows),
tcf.bar.single('unpacked_bytes_received_tikv_cross_zone', 'bytes', rows),
tcf.bar.single('unpacked_bytes_sent_tiflash_total', 'bytes', rows),
tcf.bar.single('unpacked_bytes_received_tiflash_total', 'bytes', rows),
tcf.bar.single('unpacked_bytes_sent_tiflash_cross_zone', 'bytes', rows),
tcf.bar.single('unpacked_bytes_received_tiflash_cross_zone', 'bytes', rows)
])
}
Loading

0 comments on commit 65f17b3

Please sign in to comment.