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

add QPS in tidb_dashboard ref:#1209 #1252

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions pkg/keyvisual/input/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type RegionInfo struct {
ReadBytes uint64 `json:"read_bytes"`
WrittenKeys uint64 `json:"written_keys"`
ReadKeys uint64 `json:"read_keys"`
WriteQueryNum uint64 `json:"write_query_num"`
ReadQueryNum uint64 `json:"read_query_num"`
ApproximateSize int64 `json:"approximate_size"`
ApproximateKeys int64 `json:"approximate_keys"`
}
Expand Down Expand Up @@ -72,6 +74,14 @@ func (rs *RegionsInfo) GetValues(tag regionpkg.StatTag) []uint64 {
for i, region := range rs.Regions {
values[i] = region.ReadKeys
}
case regionpkg.WriteQueryNum:
for i, region := range rs.Regions {
values[i] = region.WriteQueryNum
}
case regionpkg.ReadQueryNum:
for i, region := range rs.Regions {
values[i] = region.ReadQueryNum
}
case regionpkg.Integration:
for i, region := range rs.Regions {
values[i] = region.WrittenBytes + region.ReadBytes
Expand Down
14 changes: 13 additions & 1 deletion pkg/keyvisual/region/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const (
WrittenKeys
// ReadKeys is the number of keys read to the data per minute.
ReadKeys
// WriteQueryNum is write query num from this region
WriteQueryNum
// ReadQueryNum is read query num from this region
ReadQueryNum
)

// IntoTag converts a string into a StatTag.
Expand All @@ -33,6 +37,10 @@ func IntoTag(typ string) StatTag {
return WrittenKeys
case "read_keys":
return ReadKeys
case "write_query_num":
return WriteQueryNum
case "read_query_num":
return ReadQueryNum
default:
return WrittenBytes
}
Expand All @@ -50,13 +58,17 @@ func (tag StatTag) String() string {
return "written_keys"
case ReadKeys:
return "read_keys"
case WriteQueryNum:
return "write_query_num"
case ReadQueryNum:
return "read_query_num"
default:
panic("unreachable")
}
}

// StorageTags is the order of tags during storage.
var StorageTags = []StatTag{WrittenBytes, ReadBytes, WrittenKeys, ReadKeys}
var StorageTags = []StatTag{WrittenBytes, ReadBytes, WrittenKeys, ReadKeys, WriteQueryNum, ReadQueryNum}

// ResponseTags is the order of tags when responding.
var ResponseTags = append([]StatTag{Integration}, StorageTags...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/keyvisual/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (s *Service) Stop(ctx context.Context) error {
// @Param endkey query string false "The end of the key range"
// @Param starttime query int false "The start of the time range (Unix)"
// @Param endtime query int false "The end of the time range (Unix)"
// @Param type query string false "Main types of data" Enums(written_bytes, read_bytes, written_keys, read_keys, integration)
// @Param type query string false "Main types of data" Enums(written_bytes, read_bytes, written_keys, read_keys, write_query_num, read_query_num, integration)
// @Success 200 {object} matrix.Matrix
// @Router /keyvisual/heatmaps [get]
// @Security JwtAuth
Expand Down
8 changes: 8 additions & 0 deletions ui/lib/apps/KeyViz/components/KeyVizToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ class KeyVizToolbar extends Component<IKeyVizToolbarProps & WithTranslation> {
},
{ text: t('keyviz.toolbar.view_type.read_keys'), value: 'read_keys' },
{ text: t('keyviz.toolbar.view_type.write_keys'), value: 'written_keys' },
{
text: t('keyviz.toolbar.view_type.read_query_num'),
value: 'read_query_num',
},
{
text: t('keyviz.toolbar.view_type.write_query_num'),
value: 'write_query_num',
},
{ text: t('keyviz.toolbar.view_type.all'), value: 'integration' },
]

Expand Down
2 changes: 2 additions & 0 deletions ui/lib/apps/KeyViz/heatmap/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export type DataTag =
| 'read_bytes'
| 'written_keys'
| 'read_keys'
| `write_query_num`
| `read_query_num`

export type HeatmapRange = {
starttime?: number
Expand Down
4 changes: 4 additions & 0 deletions ui/lib/apps/KeyViz/heatmap/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export function tagUnit(tag: DataTag): string {
return 'keys/min'
case 'written_keys':
return 'keys/min'
case 'read_query_num':
return 'qps/min'
case 'write_query_num':
return 'qps/min'
}
}

Expand Down
2 changes: 2 additions & 0 deletions ui/lib/apps/KeyViz/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ keyviz:
write_bytes: Write (bytes)
read_keys: Read (keys)
write_keys: Write (keys)
read_query_num: Read(qps)
write_query_num: Write(qps)
all: All
settings:
title: Settings
Expand Down
2 changes: 2 additions & 0 deletions ui/lib/apps/KeyViz/translations/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ keyviz:
write_bytes: 写入字节量
read_keys: 读取次数
write_keys: 写入次数
read_query_num: 读查询次数
write_query_num: 写查询次数
all: 所有
settings:
title: 设置
Expand Down