mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-14 23:11:32 +08:00
fix: rate in table panel (#4916)
* fix: rate in table panel * test: added test cases for rate operation in table panel
This commit is contained in:
parent
6cf7cc9f4f
commit
71b3e6d522
@ -252,6 +252,8 @@ func buildLogsQuery(panelType v3.PanelType, start, end, step int64, mq *v3.Build
|
|||||||
} else if panelType == v3.PanelTypeTable {
|
} else if panelType == v3.PanelTypeTable {
|
||||||
queryTmpl =
|
queryTmpl =
|
||||||
"SELECT now() as ts,"
|
"SELECT now() as ts,"
|
||||||
|
// step or aggregate interval is whole time period in case of table panel
|
||||||
|
step = (utils.GetEpochNanoSecs(end) - utils.GetEpochNanoSecs(start)) / 1000000000
|
||||||
} else if panelType == v3.PanelTypeGraph || panelType == v3.PanelTypeValue {
|
} else if panelType == v3.PanelTypeGraph || panelType == v3.PanelTypeValue {
|
||||||
// Select the aggregate value for interval
|
// Select the aggregate value for interval
|
||||||
queryTmpl =
|
queryTmpl =
|
||||||
|
@ -906,6 +906,23 @@ var testBuildLogsQueryData = []struct {
|
|||||||
TableName: "logs",
|
TableName: "logs",
|
||||||
ExpectedQuery: "SELECT now() as ts, attributes_string_value[indexOf(attributes_string_key, 'name')] as `name`, toFloat64(count(*)) as value from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) AND has(attributes_string_key, 'name') group by `name` order by value DESC",
|
ExpectedQuery: "SELECT now() as ts, attributes_string_value[indexOf(attributes_string_key, 'name')] as `name`, toFloat64(count(*)) as value from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) AND has(attributes_string_key, 'name') group by `name` order by value DESC",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "TABLE: Test rate with groupBy",
|
||||||
|
PanelType: v3.PanelTypeTable,
|
||||||
|
Start: 1680066360726210000,
|
||||||
|
End: 1680066458000000000,
|
||||||
|
BuilderQuery: &v3.BuilderQuery{
|
||||||
|
QueryName: "A",
|
||||||
|
StepInterval: 60,
|
||||||
|
AggregateOperator: v3.AggregateOperatorRate,
|
||||||
|
Expression: "A",
|
||||||
|
GroupBy: []v3.AttributeKey{
|
||||||
|
{Key: "name", DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeTag},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TableName: "logs",
|
||||||
|
ExpectedQuery: "SELECT now() as ts, attributes_string_value[indexOf(attributes_string_key, 'name')] as `name`, count()/97.000000 as value from signoz_logs.distributed_logs where (timestamp >= 1680066360726210000 AND timestamp <= 1680066458000000000) AND has(attributes_string_key, 'name') group by `name` order by value DESC",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "TABLE: Test count with groupBy, orderBy",
|
Name: "TABLE: Test count with groupBy, orderBy",
|
||||||
PanelType: v3.PanelTypeTable,
|
PanelType: v3.PanelTypeTable,
|
||||||
|
@ -262,6 +262,8 @@ func buildTracesQuery(start, end, step int64, mq *v3.BuilderQuery, tableName str
|
|||||||
} else if panelType == v3.PanelTypeTable {
|
} else if panelType == v3.PanelTypeTable {
|
||||||
queryTmpl =
|
queryTmpl =
|
||||||
"SELECT now() as ts,"
|
"SELECT now() as ts,"
|
||||||
|
// step or aggregate interval is whole time period in case of table panel
|
||||||
|
step = (end*getZerosForEpochNano(end) - start*getZerosForEpochNano(start))/1000000000
|
||||||
} else if panelType == v3.PanelTypeGraph || panelType == v3.PanelTypeValue {
|
} else if panelType == v3.PanelTypeGraph || panelType == v3.PanelTypeValue {
|
||||||
// Select the aggregate value for interval
|
// Select the aggregate value for interval
|
||||||
queryTmpl =
|
queryTmpl =
|
||||||
|
@ -1017,7 +1017,7 @@ var testBuildTracesQueryData = []struct {
|
|||||||
PanelType: v3.PanelTypeValue,
|
PanelType: v3.PanelTypeValue,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Test aggregate PXX",
|
Name: "Test aggregate PXX with groupby",
|
||||||
Start: 1680066360726210000,
|
Start: 1680066360726210000,
|
||||||
End: 1680066458000000000,
|
End: 1680066458000000000,
|
||||||
BuilderQuery: &v3.BuilderQuery{
|
BuilderQuery: &v3.BuilderQuery{
|
||||||
@ -1059,6 +1059,26 @@ var testBuildTracesQueryData = []struct {
|
|||||||
"where (timestamp >= '1680066360726210000' AND timestamp <= '1680066458000000000')",
|
"where (timestamp >= '1680066360726210000' AND timestamp <= '1680066458000000000')",
|
||||||
PanelType: v3.PanelTypeTable,
|
PanelType: v3.PanelTypeTable,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "Test aggregate rate table panel",
|
||||||
|
Start: 1680066360726210000,
|
||||||
|
End: 1680066458000000000,
|
||||||
|
BuilderQuery: &v3.BuilderQuery{
|
||||||
|
QueryName: "A",
|
||||||
|
StepInterval: 60,
|
||||||
|
AggregateAttribute: v3.AttributeKey{Key: "durationNano", IsColumn: true, DataType: v3.AttributeKeyDataTypeFloat64, Type: v3.AttributeKeyTypeTag},
|
||||||
|
AggregateOperator: v3.AggregateOperatorRate,
|
||||||
|
Expression: "A",
|
||||||
|
Filters: &v3.FilterSet{Operator: "AND", Items: []v3.FilterItem{}},
|
||||||
|
GroupBy: []v3.AttributeKey{},
|
||||||
|
OrderBy: []v3.OrderBy{},
|
||||||
|
},
|
||||||
|
TableName: "signoz_traces.distributed_signoz_index_v2",
|
||||||
|
ExpectedQuery: "SELECT now() as ts, count(durationNano)/97.000000 as value " +
|
||||||
|
"from signoz_traces.distributed_signoz_index_v2 " +
|
||||||
|
"where (timestamp >= '1680066360726210000' AND timestamp <= '1680066458000000000')",
|
||||||
|
PanelType: v3.PanelTypeTable,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "Test Noop list view",
|
Name: "Test Noop list view",
|
||||||
Start: 1680066360726210000,
|
Start: 1680066360726210000,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user