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
fixed query service timestamp to string conversion timezone issue
Ankit Nayan1dad2bb791aa
diff --git a/pkg/query-service/app/parser.go b/pkg/query-service/app/parser.goindex ed70e516eb..79e519eafa 100644--- a/pkg/query-service/app/parser.go+++ b/pkg/query-service/app/parser.go@@ -35,8 +35,8 @@ func parseGetTopEndpointsRequest(r *http.Request) (*model.GetTopEndpointsParams,}getTopEndpointsParams := model.GetTopEndpointsParams{- StartTime: startTime.Format("2006-01-02 15:04:05"),- EndTime: endTime.Format("2006-01-02 15:04:05"),+ StartTime: startTime.Format(time.RFC3339Nano),+ EndTime: endTime.Format(time.RFC3339Nano),ServiceName: serviceName,}@@ -66,8 +66,8 @@ func parseGetUsageRequest(r *http.Request) (*model.GetUsageParams, error) {serviceName := r.URL.Query().Get("service")getUsageParams := model.GetUsageParams{- StartTime: startTime.Format("2006-01-02 15:04:05"),- EndTime: endTime.Format("2006-01-02 15:04:05"),+ StartTime: startTime.Format(time.RFC3339Nano),+ EndTime: endTime.Format(time.RFC3339Nano),ServiceName: serviceName,Period: fmt.Sprintf("PT%dH", stepInt/3600),}@@ -101,8 +101,8 @@ func parseGetServiceOverviewRequest(r *http.Request) (*model.GetServiceOverviewP}getServiceOverviewParams := model.GetServiceOverviewParams{- StartTime: startTime.Format("2006-01-02 15:04:05"),- EndTime: endTime.Format("2006-01-02 15:04:05"),+ StartTime: startTime.Format(time.RFC3339Nano),+ EndTime: endTime.Format(time.RFC3339Nano),ServiceName: serviceName,Period: fmt.Sprintf("PT%dM", stepInt/60),StepSeconds: stepInt,@@ -124,8 +124,8 @@ func parseGetServicesRequest(r *http.Request) (*model.GetServicesParams, error)}getServicesParams := model.GetServicesParams{- StartTime: startTime.Format("2006-01-02 15:04:05"),- EndTime: endTime.Format("2006-01-02 15:04:05"),+ StartTime: startTime.Format(time.RFC3339Nano),+ EndTime: endTime.Format(time.RFC3339Nano),Period: int(endTime.Unix() - startTime.Unix()),}return &getServicesParams, nildiff --git a/pkg/query-service/druidQuery/mysql-query.go b/pkg/query-service/druidQuery/mysql-query.goindex dfff5050f5..4444dbd9a7 100644--- a/pkg/query-service/druidQuery/mysql-query.go+++ b/pkg/query-service/druidQuery/mysql-query.go@@ -53,7 +53,7 @@ type TagItem struct {func GetOperations(client *SqlClient, serviceName string) (*[]string, error) {- sqlQuery := fmt.Sprintf(`SELECT DISTINCT(Name) FROM %s WHERE ServiceName='%s' AND __time > CURRENT_TIMESTAMP - INTERVAL '2' DAY`, constants.DruidDatasource, serviceName)+ sqlQuery := fmt.Sprintf(`SELECT DISTINCT(Name) FROM %s WHERE ServiceName='%s' AND __time > CURRENT_TIMESTAMP - INTERVAL '1' DAY`, constants.DruidDatasource, serviceName)// zap.S().Debug(sqlQuery)response, err := client.Query(sqlQuery, "array")@@ -143,7 +143,7 @@ func GetTags(client *SqlClient, serviceName string) (*[]TagItem, error) {func GetTopEndpoints(client *SqlClient, query *model.GetTopEndpointsParams) (*[]TopEnpointsItem, error) {- sqlQuery := fmt.Sprintf(`SELECT APPROX_QUANTILE_DS("QuantileDuration", 0.5) as p50, APPROX_QUANTILE_DS("QuantileDuration", 0.9) as p90, APPROX_QUANTILE_DS("QuantileDuration", 0.99) as p99, COUNT(SpanId) as numCalls, Name FROM "%s" WHERE "__time" >= TIMESTAMP '%s' AND "__time" <= TIMESTAMP '%s' AND "Kind"='2' and "ServiceName"='%s' GROUP BY Name`, constants.DruidDatasource, query.StartTime, query.EndTime, query.ServiceName)+ sqlQuery := fmt.Sprintf(`SELECT APPROX_QUANTILE_DS("QuantileDuration", 0.5) as p50, APPROX_QUANTILE_DS("QuantileDuration", 0.9) as p90, APPROX_QUANTILE_DS("QuantileDuration", 0.99) as p99, COUNT(SpanId) as numCalls, Name FROM "%s" WHERE "__time" >= '%s' AND "__time" <= '%s' AND "Kind"='2' and "ServiceName"='%s' GROUP BY Name`, constants.DruidDatasource, query.StartTime, query.EndTime, query.ServiceName)// zap.S().Debug(sqlQuery)@@ -173,10 +173,10 @@ func GetUsage(client *SqlClient, query *model.GetUsageParams) (*[]UsageItem, errif len(query.ServiceName) != 0 {- sqlQuery = fmt.Sprintf(`SELECT TIME_FLOOR(__time, '%s') as "time", COUNT(SpanId) as "count" FROM "%s" WHERE "__time" >= TIMESTAMP '%s' and "__time" <= TIMESTAMP '%s' and "ServiceName"='%s' GROUP BY TIME_FLOOR(__time, '%s')`, query.Period, constants.DruidDatasource, query.StartTime, query.EndTime, query.ServiceName, query.Period)+ sqlQuery = fmt.Sprintf(`SELECT TIME_FLOOR(__time, '%s') as "time", COUNT(SpanId) as "count" FROM "%s" WHERE "__time" >= '%s' and "__time" <= '%s' and "ServiceName"='%s' GROUP BY TIME_FLOOR(__time, '%s')`, query.Period, constants.DruidDatasource, query.StartTime, query.EndTime, query.ServiceName, query.Period)} else {- sqlQuery = fmt.Sprintf(`SELECT TIME_FLOOR(__time, '%s') as "time", COUNT(SpanId) as "count" FROM "%s" WHERE "__time" >= TIMESTAMP '%s' and "__time" <= TIMESTAMP '%s' GROUP BY TIME_FLOOR(__time, '%s')`, query.Period, constants.DruidDatasource, query.StartTime, query.EndTime, query.Period)+ sqlQuery = fmt.Sprintf(`SELECT TIME_FLOOR(__time, '%s') as "time", COUNT(SpanId) as "count" FROM "%s" WHERE "__time" >= '%s' and "__time" <= '%s' GROUP BY TIME_FLOOR(__time, '%s')`, query.Period, constants.DruidDatasource, query.StartTime, query.EndTime, query.Period)}// zap.S().Debug(sqlQuery)@@ -210,7 +210,7 @@ func GetUsage(client *SqlClient, query *model.GetUsageParams) (*[]UsageItem, errfunc GetServiceOverview(client *SqlClient, query *model.GetServiceOverviewParams) (*[]ServiceOverviewItem, error) {sqlQuery := fmt.Sprintf(`SELECT TIME_FLOOR(__time, '%s') as "time", APPROX_QUANTILE_DS("QuantileDuration", 0.5) as p50, APPROX_QUANTILE_DS("QuantileDuration", 0.9) as p90,- APPROX_QUANTILE_DS("QuantileDuration", 0.99) as p99, COUNT("SpanId") as "numCalls" FROM "%s" WHERE "__time" >= TIMESTAMP '%s' and "__time" <= TIMESTAMP '%s' and "Kind"='2' and "ServiceName"='%s' GROUP BY TIME_FLOOR(__time, '%s') `, query.Period, constants.DruidDatasource, query.StartTime, query.EndTime, query.ServiceName, query.Period)+ APPROX_QUANTILE_DS("QuantileDuration", 0.99) as p99, COUNT("SpanId") as "numCalls" FROM "%s" WHERE "__time" >= '%s' and "__time" <= '%s' and "Kind"='2' and "ServiceName"='%s' GROUP BY TIME_FLOOR(__time, '%s') `, query.Period, constants.DruidDatasource, query.StartTime, query.EndTime, query.ServiceName, query.Period)// zap.S().Debug(sqlQuery)@@ -245,7 +245,7 @@ func GetServiceOverview(client *SqlClient, query *model.GetServiceOverviewParamsfunc GetServices(client *SqlClient, query *model.GetServicesParams) (*[]ServiceItem, error) {- sqlQuery := fmt.Sprintf(`SELECT APPROX_QUANTILE_DS("QuantileDuration", 0.99) as "p99", AVG("DurationNano") as "avgDuration", COUNT(SpanId) as numCalls, "ServiceName" as "serviceName" FROM %s WHERE "__time" >= TIMESTAMP '%s' and "__time" <= TIMESTAMP '%s' and "Kind"='2' GROUP BY "ServiceName" ORDER BY "p99" DESC`, constants.DruidDatasource, query.StartTime, query.EndTime)+ sqlQuery := fmt.Sprintf(`SELECT APPROX_QUANTILE_DS("QuantileDuration", 0.99) as "p99", AVG("DurationNano") as "avgDuration", COUNT(SpanId) as numCalls, "ServiceName" as "serviceName" FROM %s WHERE "__time" >= '%s' and "__time" <= '%s' and "Kind"='2' GROUP BY "ServiceName" ORDER BY "p99" DESC`, constants.DruidDatasource, query.StartTime, query.EndTime)response, err := client.Query(sqlQuery, "object")