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: add telemetry for dashboards/alerts with tsv2 table (#5677)

Srikanth Chekuri29f1883eddcb
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go
index b34780c37d..5f33bfe2a9 100644
--- a/pkg/query-service/app/clickhouseReader/reader.go
+++ b/pkg/query-service/app/clickhouseReader/reader.go
@@ -3346,17 +3346,30 @@ func (r *ClickHouseReader) GetDashboardsInfo(ctx context.Context) (*model.Dashbo
return &dashboardsInfo, err
}
totalDashboardsWithPanelAndName := 0
+ count := 0
for _, dashboard := range dashboardsData {
if isDashboardWithPanelAndName(dashboard.Data) {
totalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName + 1
}
dashboardsInfo = countPanelsInDashboard(dashboard.Data)
+ if isDashboardWithTSV2(dashboard.Data) {
+ count = count + 1
+ }
}
dashboardsInfo.TotalDashboards = len(dashboardsData)
dashboardsInfo.TotalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName
+ dashboardsInfo.QueriesWithTSV2 = count
return &dashboardsInfo, nil
}
+func isDashboardWithTSV2(data map[string]interface{}) bool {
+ jsonData, err := json.Marshal(data)
+ if err != nil {
+ return false
+ }
+ return strings.Contains(string(jsonData), "time_series_v2")
+}
+
func isDashboardWithPanelAndName(data map[string]interface{}) bool {
isDashboardName := false
isDashboardWithPanelAndName := false
diff --git a/pkg/query-service/model/response.go b/pkg/query-service/model/response.go
index eb979642da..b8250bd1d3 100644
--- a/pkg/query-service/model/response.go
+++ b/pkg/query-service/model/response.go
@@ -648,6 +648,7 @@ type AlertsInfo struct {
MetricsClickHouseQueries int `json:"metricsClickHouseQueries"`
MetricsPrometheusQueries int `json:"metricsPrometheusQueries"`
SpanMetricsPrometheusQueries int `json:"spanMetricsPrometheusQueries"`
+ AlertsWithTSV2 int `json:"alertsWithTSv2"`
}
type SavedViewsInfo struct {
@@ -661,6 +662,7 @@ type DashboardsInfo struct {
TotalDashboardsWithPanelAndName int `json:"totalDashboardsWithPanelAndName"` // dashboards with panel and name without sample title
LogsBasedPanels int `json:"logsBasedPanels"`
MetricBasedPanels int `json:"metricBasedPanels"`
+ QueriesWithTSV2 int `json:"queriesWithTSV2"`
TracesBasedPanels int `json:"tracesBasedPanels"`
}
diff --git a/pkg/query-service/rules/db.go b/pkg/query-service/rules/db.go
index 64a35e3eb9..c49a8dd391 100644
--- a/pkg/query-service/rules/db.go
+++ b/pkg/query-service/rules/db.go
@@ -315,6 +315,9 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
}
for _, alert := range alertsData {
var rule GettableRule
+ if strings.Contains(alert, "time_series_v2") {
+ alertsInfo.AlertsWithTSV2 = alertsInfo.AlertsWithTSV2 + 1
+ }
err = json.Unmarshal([]byte(alert), &rule)
if err != nil {
zap.L().Error("invalid rule data", zap.Error(err))
diff --git a/pkg/query-service/telemetry/telemetry.go b/pkg/query-service/telemetry/telemetry.go
index 2c9dceb910..ecfa86298e 100644
--- a/pkg/query-service/telemetry/telemetry.go
+++ b/pkg/query-service/telemetry/telemetry.go
@@ -317,7 +317,9 @@ func createTelemetry() {
"logsBasedPanels": dashboardsInfo.LogsBasedPanels,
"metricBasedPanels": dashboardsInfo.MetricBasedPanels,
"tracesBasedPanels": dashboardsInfo.TracesBasedPanels,
+ "dashboardsWithTSV2": dashboardsInfo.QueriesWithTSV2,
"totalAlerts": alertsInfo.TotalAlerts,
+ "alertsWithTSV2": alertsInfo.AlertsWithTSV2,
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,
"metricBasedAlerts": alertsInfo.MetricBasedAlerts,
"tracesBasedAlerts": alertsInfo.TracesBasedAlerts,