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 Value Label to TS.RANGE command similar to TS.MRANGE #110

Merged
merged 2 commits into from
Dec 20, 2020
Merged
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
6 changes: 3 additions & 3 deletions pkg/redis-time-series.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func (ds *redisDatasource) queryTsRange(from int64, to int64, qm queryModel, cli
}

// Create data frame response
frame := data.NewFrame(qm.Key,
frame := data.NewFrame(legend,
data.NewField("time", nil, []time.Time{}),
data.NewField(legend, nil, []float64{}))
data.NewField(qm.Value, nil, []float64{}))

// Previous time to fill missing intervals
var prevTime time.Time
Expand Down Expand Up @@ -140,7 +140,7 @@ func (ds *redisDatasource) queryTsMRange(from int64, to int64, qm queryModel, cl
}

// Use value's label if specified
value := "value"
value := ""
if qm.Value != "" {
value = labels[qm.Value]
}
Expand Down
12 changes: 11 additions & 1 deletion src/components/query-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,24 @@ export class QueryEditor extends PureComponent<Props> {
/>
)}

{CommandParameters.value.includes(command) && (
<FormField
labelWidth={8}
inputWidth={10}
value={value}
onChange={this.onValueChange}
label="Value"
tooltip="Value override"
/>
)}

{CommandParameters.legendLabel.includes(command) && (
<FormField
labelWidth={8}
inputWidth={10}
value={legend}
onChange={this.onLegendChange}
label="Legend Label"
tooltip="Legend Label"
/>
)}

Expand Down
2 changes: 2 additions & 0 deletions src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export class DataSource extends DataSourceWithBackend<RedisQuery, RedisDataSourc
query: query.query ? templateSrv.replace(query.query, scopedVars) : '',
field: query.field ? templateSrv.replace(query.field, scopedVars) : '',
filter: query.filter ? templateSrv.replace(query.filter, scopedVars) : '',
legend: query.legend ? templateSrv.replace(query.legend, scopedVars) : '',
value: query.value ? templateSrv.replace(query.value, scopedVars) : '',
};
}

Expand Down
1 change: 1 addition & 0 deletions src/redis/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const CommandParameters = {
legend: ['ts.range'],
legendLabel: ['ts.mrange'],
section: ['info'],
value: ['ts.range'],
valueLabel: ['ts.mrange'],
fill: ['ts.range', 'ts.mrange'],
size: ['slowlogGet']
Expand Down
2 changes: 1 addition & 1 deletion src/redis/time-series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export const Aggregations: Array<SelectableValue<AggregationValue>> = [
{ label: 'Max', description: 'Maximum', value: AggregationValue.MAX },
{ label: 'Min', description: 'Minimum', value: AggregationValue.MIN },
{ label: 'Range', description: 'Diff between maximum and minimum in the bucket', value: AggregationValue.RANGE },
{ label: 'Sum', description: 'Sum', value: AggregationValue.SUM },
{ label: 'Sum', description: 'Summation', value: AggregationValue.SUM },
];