Skip to content

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.

chore: make time macros available for all query types (#5092)

Srikanth Chekuri10b543dff1d2
diff --git a/pkg/query-service/postprocess/formula.go b/pkg/query-service/postprocess/formula.go
index f1dd86eae5..b88677b0be 100644
--- a/pkg/query-service/postprocess/formula.go
+++ b/pkg/query-service/postprocess/formula.go
@@ -108,7 +108,9 @@ func joinAndCalculate(
for _, timestamp := range timestamps {
values := make(map[string]interface{})
for queryName, series := range seriesMap {
- values[queryName] = series[timestamp]
+ if _, ok := series[timestamp]; ok {
+ values[queryName] = series[timestamp]
+ }
}
// If the value is not present in the values map, set it to 0
diff --git a/pkg/query-service/utils/queryTemplate/vars.go b/pkg/query-service/utils/queryTemplate/vars.go
index 677d3aa773..c9d814e004 100644
--- a/pkg/query-service/utils/queryTemplate/vars.go
+++ b/pkg/query-service/utils/queryTemplate/vars.go
@@ -15,6 +15,9 @@ func AssignReservedVarsV3(queryRangeParams *v3.QueryRangeParamsV3) {
queryRangeParams.Variables["start_timestamp_ms"] = queryRangeParams.Start
queryRangeParams.Variables["end_timestamp_ms"] = queryRangeParams.End
+ queryRangeParams.Variables["SIGNOZ_START_TIME"] = queryRangeParams.Start
+ queryRangeParams.Variables["SIGNOZ_END_TIME"] = queryRangeParams.End
+
queryRangeParams.Variables["start_timestamp_nano"] = queryRangeParams.Start * 1e6
queryRangeParams.Variables["end_timestamp_nano"] = queryRangeParams.End * 1e6