SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: rate in table panel (#4916)
Vishal Sharma71b3e6d52274
diff --git a/pkg/query-service/app/logs/v3/query_builder.go b/pkg/query-service/app/logs/v3/query_builder.goindex e01cb95d74..75cacaa2ed 100644--- a/pkg/query-service/app/logs/v3/query_builder.go+++ b/pkg/query-service/app/logs/v3/query_builder.go@@ -252,6 +252,8 @@ func buildLogsQuery(panelType v3.PanelType, start, end, step int64, mq *v3.Build} else if panelType == v3.PanelTypeTable {queryTmpl ="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 {// Select the aggregate value for intervalqueryTmpl =diff --git a/pkg/query-service/app/logs/v3/query_builder_test.go b/pkg/query-service/app/logs/v3/query_builder_test.goindex 58a120cd44..7a8a997be4 100644--- a/pkg/query-service/app/logs/v3/query_builder_test.go+++ b/pkg/query-service/app/logs/v3/query_builder_test.go@@ -906,6 +906,23 @@ var testBuildLogsQueryData = []struct {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",},+ {+ 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",PanelType: v3.PanelTypeTable,diff --git a/pkg/query-service/app/traces/v3/query_builder.go b/pkg/query-service/app/traces/v3/query_builder.goindex 8f781b7824..efbc4d8872 100644--- a/pkg/query-service/app/traces/v3/query_builder.go+++ b/pkg/query-service/app/traces/v3/query_builder.go@@ -262,6 +262,8 @@ func buildTracesQuery(start, end, step int64, mq *v3.BuilderQuery, tableName str} else if panelType == v3.PanelTypeTable {queryTmpl ="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 {// Select the aggregate value for intervalqueryTmpl =diff --git a/pkg/query-service/app/traces/v3/query_builder_test.go b/pkg/query-service/app/traces/v3/query_builder_test.goindex fd798c1530..b4b1a2574c 100644--- a/pkg/query-service/app/traces/v3/query_builder_test.go+++ b/pkg/query-service/app/traces/v3/query_builder_test.go@@ -1017,7 +1017,7 @@ var testBuildTracesQueryData = []struct {PanelType: v3.PanelTypeValue,},{- Name: "Test aggregate PXX",+ Name: "Test aggregate PXX with groupby",Start: 1680066360726210000,End: 1680066458000000000,BuilderQuery: &v3.BuilderQuery{@@ -1059,6 +1059,26 @@ var testBuildTracesQueryData = []struct {"where (timestamp >= '1680066360726210000' AND timestamp <= '1680066458000000000')",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",Start: 1680066360726210000,