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: use local table for innery query (#1816)

Srikanth Chekuri1b52edb05624
diff --git a/pkg/query-service/app/metrics/query_builder.go b/pkg/query-service/app/metrics/query_builder.go
index 454482a60b..ef8fb78797 100644
--- a/pkg/query-service/app/metrics/query_builder.go
+++ b/pkg/query-service/app/metrics/query_builder.go
@@ -142,7 +142,7 @@ func BuildMetricsTimeSeriesFilterQuery(fs *model.FilterSet, groupTags []string,
}
}
- filterSubQuery := fmt.Sprintf("SELECT %s fingerprint FROM %s.%s WHERE %s", selectLabels, constants.SIGNOZ_METRIC_DBNAME, constants.SIGNOZ_TIMESERIES_TABLENAME, queryString)
+ filterSubQuery := fmt.Sprintf("SELECT %s fingerprint FROM %s.%s WHERE %s", selectLabels, constants.SIGNOZ_METRIC_DBNAME, constants.SIGNOZ_TIMESERIES_LOCAL_TABLENAME, queryString)
return filterSubQuery, nil
}
@@ -166,7 +166,7 @@ func BuildMetricQuery(qp *model.QueryRangeParamsV2, mq *model.MetricQuery, table
" toStartOfInterval(toDateTime(intDiv(timestamp_ms, 1000)), INTERVAL %d SECOND) as ts," +
" %s as value" +
" FROM " + constants.SIGNOZ_METRIC_DBNAME + "." + constants.SIGNOZ_SAMPLES_TABLENAME +
- " GLOBAL INNER JOIN" +
+ " INNER JOIN" +
" (%s) as filtered_time_series" +
" USING fingerprint" +
" WHERE " + samplesTableTimeFilter +
@@ -228,7 +228,7 @@ func BuildMetricQuery(qp *model.QueryRangeParamsV2, mq *model.MetricQuery, table
" toStartOfInterval(toDateTime(intDiv(timestamp_ms, 1000)), INTERVAL %d SECOND) as ts," +
" any(value) as value" +
" FROM " + constants.SIGNOZ_METRIC_DBNAME + "." + constants.SIGNOZ_SAMPLES_TABLENAME +
- " GLOBAL INNER JOIN" +
+ " INNER JOIN" +
" (%s) as filtered_time_series" +
" USING fingerprint" +
" WHERE " + samplesTableTimeFilter +
@@ -371,7 +371,7 @@ func expressionToQuery(qp *model.QueryRangeParamsV2, varToQuery map[string]strin
joinUsing = strings.Join(groupTags, ",")
formulaSubQuery += fmt.Sprintf("(%s) as %s ", query, var_)
if idx < len(vars)-1 {
- formulaSubQuery += "GLOBAL INNER JOIN"
+ formulaSubQuery += "INNER JOIN"
} else if len(vars) > 1 {
formulaSubQuery += fmt.Sprintf("USING (%s)", joinUsing)
}
diff --git a/pkg/query-service/config/prometheus.yml b/pkg/query-service/config/prometheus.yml
index 0d5024bdc4..88ee92961b 100644
--- a/pkg/query-service/config/prometheus.yml
+++ b/pkg/query-service/config/prometheus.yml
@@ -22,4 +22,4 @@ rule_files:
scrape_configs: []
remote_read:
- - url: tcp://stagingapp.signoz.io:9000/?database=signoz_metrics
+ - url: tcp://localhost:9000/?database=signoz_metrics
diff --git a/pkg/query-service/constants/constants.go b/pkg/query-service/constants/constants.go
index 7a266cb2fc..d117b194ed 100644
--- a/pkg/query-service/constants/constants.go
+++ b/pkg/query-service/constants/constants.go
@@ -110,9 +110,10 @@ const (
DefaultLogSkipIndexGranularity = 64
)
const (
- SIGNOZ_METRIC_DBNAME = "signoz_metrics"
- SIGNOZ_SAMPLES_TABLENAME = "distributed_samples_v2"
- SIGNOZ_TIMESERIES_TABLENAME = "distributed_time_series_v2"
+ SIGNOZ_METRIC_DBNAME = "signoz_metrics"
+ SIGNOZ_SAMPLES_TABLENAME = "distributed_samples_v2"
+ SIGNOZ_TIMESERIES_TABLENAME = "distributed_time_series_v2"
+ SIGNOZ_TIMESERIES_LOCAL_TABLENAME = "time_series_v2"
)
var TimeoutExcludedRoutes = map[string]bool{