Skip to content

Commit b326b84

Browse files
ryantxuMikhail
andauthored
Add Field config units to the response (#26)
* add unit when known * Update slowlog command * Update fieldConfig for commandstats * Remove duration's unit * No need to set seconds for time.Time type Co-authored-by: Mikhail <mikhail@redislabs.com>
1 parent aa380d3 commit b326b84

File tree

2 files changed

+14
-35
lines changed

2 files changed

+14
-35
lines changed

pkg/commands.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ func (ds *redisDatasource) queryInfo(qm queryModel, client *radix.Pool) backend.
569569
data.NewField("Usec", nil, []float64{}),
570570
data.NewField("Usec_per_call", nil, []float64{}))
571571

572+
// Set Field Config
573+
frame.Fields[2].Config = &data.FieldConfig{Unit: "µs"}
574+
frame.Fields[3].Config = &data.FieldConfig{Unit: "µs"}
575+
572576
// Parse lines
573577
for _, line := range lines {
574578
fields := strings.Split(line, ":")
@@ -733,10 +737,13 @@ func (ds *redisDatasource) querySlowlogGet(qm queryModel, client *radix.Pool) ba
733737
// New Frame
734738
frame := data.NewFrame(qm.Command,
735739
data.NewField("Id", nil, []int64{}),
736-
data.NewField("Timestamp", nil, []int64{}),
740+
data.NewField("Timestamp", nil, []time.Time{}),
737741
data.NewField("Duration", nil, []int64{}),
738742
data.NewField("Command", nil, []string{}))
739743

744+
// Set Field Config
745+
frame.Fields[2].Config = &data.FieldConfig{Unit: "µs"}
746+
740747
// Parse Time-Series data
741748
for _, innerArray := range result.([]interface{}) {
742749
query := innerArray.([]interface{})
@@ -777,7 +784,7 @@ func (ds *redisDatasource) querySlowlogGet(qm queryModel, client *radix.Pool) ba
777784
}
778785

779786
// Add Query
780-
frame.AppendRow(query[0].(int64), query[1].(int64), query[2].(int64), command)
787+
frame.AppendRow(query[0].(int64), time.Unix(query[1].(int64), 0), query[2].(int64), command)
781788
}
782789

783790
// Add the frame to the response

src/dashboards/redis.json

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"gnetId": null,
6666
"graphTooltip": 0,
6767
"id": null,
68-
"iteration": 1595543647399,
6968
"links": [
7069
{
7170
"icon": "external link",
@@ -96,7 +95,7 @@
9695
"value": "Redis"
9796
}
9897
},
99-
"title": "Main: $redis",
98+
"title": "Main",
10099
"type": "row"
101100
},
102101
{
@@ -956,7 +955,7 @@
956955
"value": "Redis"
957956
}
958957
},
959-
"title": "Other: $redis",
958+
"title": "Other",
960959
"type": "row"
961960
},
962961
{
@@ -1156,10 +1155,6 @@
11561155
"options": "Total Duration"
11571156
},
11581157
"properties": [
1159-
{
1160-
"id": "unit",
1161-
"value": "µs"
1162-
},
11631158
{
11641159
"id": "custom.width",
11651160
"value": 127
@@ -1176,10 +1171,6 @@
11761171
"options": "Duration per call"
11771172
},
11781173
"properties": [
1179-
{
1180-
"id": "unit",
1181-
"value": "µs"
1182-
},
11831174
{
11841175
"id": "decimals",
11851176
"value": 1
@@ -1319,10 +1310,6 @@
13191310
{
13201311
"id": "custom.width",
13211312
"value": 92
1322-
},
1323-
{
1324-
"id": "unit",
1325-
"value": "µs"
13261313
}
13271314
]
13281315
},
@@ -1371,27 +1358,12 @@
13711358
"timeShift": null,
13721359
"title": "Slow queries log",
13731360
"transformations": [
1374-
{
1375-
"id": "calculateField",
1376-
"options": {
1377-
"binary": {
1378-
"left": "Timestamp",
1379-
"operator": "*",
1380-
"reducer": "sum",
1381-
"right": "1000"
1382-
},
1383-
"mode": "binary",
1384-
"reduce": {
1385-
"reducer": "sum"
1386-
}
1387-
}
1388-
},
13891361
{
13901362
"id": "organize",
13911363
"options": {
13921364
"excludeByName": {
13931365
"Id": true,
1394-
"Timestamp": true
1366+
"Timestamp": false
13951367
},
13961368
"indexByName": {
13971369
"Command": 4,
@@ -1401,7 +1373,7 @@
14011373
"Timestamp * 1000": 2
14021374
},
14031375
"renameByName": {
1404-
"Duration": "Duration",
1376+
"Duration": "",
14051377
"Id": "Id",
14061378
"Timestamp * 1000": "Timestamp"
14071379
}
@@ -1428,5 +1400,5 @@
14281400
"timezone": "",
14291401
"title": "Redis",
14301402
"uid": "RpSjVqWMz",
1431-
"version": 4
1403+
"version": 2
14321404
}

0 commit comments

Comments
 (0)