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

server:return qps data to tidbdashborad #4921

Open
wants to merge 1 commit 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
8 changes: 8 additions & 0 deletions pkg/dashboard/keyvisual/input/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ func (rs RegionsInfo) GetValues(tag regionpkg.StatTag) []uint64 {
for i, region := range rs {
values[i] = region.GetKeysRead()
}
case regionpkg.WriteQueryNum:
for i, region := range rs {
values[i] = region.GetWriteQueryNum()
}
case regionpkg.ReadQueryNum:
for i, region := range rs {
values[i] = region.GetReadQueryNum()
}
case regionpkg.Integration:
for i, region := range rs {
values[i] = region.GetBytesWritten() + region.GetBytesRead()
Expand Down
4 changes: 4 additions & 0 deletions server/api/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,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"`
Buckets []string `json:"buckets,omitempty"`
Expand Down Expand Up @@ -158,8 +160,10 @@ func InitRegion(r *core.RegionInfo, s *RegionInfo) *RegionInfo {
s.PendingPeers = fromPeerSlice(r.GetPendingPeers())
s.WrittenBytes = r.GetBytesWritten()
s.WrittenKeys = r.GetKeysWritten()
s.WriteQueryNum = r.GetWriteQueryNum()
s.ReadBytes = r.GetBytesRead()
s.ReadKeys = r.GetKeysRead()
s.ReadQueryNum = r.GetReadQueryNum()
s.ApproximateSize = r.GetApproximateSize()
s.ApproximateKeys = r.GetApproximateKeys()
s.ReplicationStatus = fromPBReplicationStatus(r.GetReplicationStatus())
Expand Down
13 changes: 13 additions & 0 deletions server/api/region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ func newTestRegionInfo(regionID, storeID uint64, start, end []byte, opts ...core
core.SetWrittenKeys(1 * 1024 * 1024),
core.SetReadBytes(200 * 1024 * 1024),
core.SetReadKeys(2 * 1024 * 1024),
core.SetQueryStats(&pdpb.QueryStats{
GC: 10,
Get: 10,
Scan: 10,
Coprocessor: 10,
Delete: 10,
DeleteRange: 10,
Put: 10,
Prewrite: 10,
AcquirePessimisticLock: 10,
}),
}
newOpts = append(newOpts, opts...)
region := core.NewRegionInfo(metaRegion, leader, newOpts...)
Expand All @@ -146,8 +157,10 @@ func (s *testRegionSuite) TestRegion(c *C) {
c.Assert(readJSON(testDialClient, url, &r1m), IsNil)
c.Assert(r1m["written_bytes"].(float64), Equals, float64(r.GetBytesWritten()))
c.Assert(r1m["written_keys"].(float64), Equals, float64(r.GetKeysWritten()))
c.Assert(r1m["write_query_num"].(float64), Equals, float64(r.GetWriteQueryNum()))
c.Assert(r1m["read_bytes"].(float64), Equals, float64(r.GetBytesRead()))
c.Assert(r1m["read_keys"].(float64), Equals, float64(r.GetKeysRead()))
c.Assert(r1m["read_query_num"].(float64), Equals, float64(r.GetReadQueryNum()))
keys := r1m["buckets"].([]interface{})
c.Assert(keys, HasLen, 2)
c.Assert(keys[0].(string), Equals, core.HexRegionKeyStr([]byte("a")))
Expand Down