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
feat: collect telemetry for ch log queries in alerts and dashboards (#5967)
Nityananda Gohainf854cdd9d303
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex a3d2536aa8..84ddf3ac32 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -3373,6 +3373,7 @@ func (r *ClickHouseReader) GetDashboardsInfo(ctx context.Context) (*model.DashbototalDashboardsWithPanelAndName := 0var dashboardNames []stringcount := 0+ logChQueriesCount := 0for _, dashboard := range dashboardsData {if isDashboardWithPanelAndName(dashboard.Data) {totalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName + 1@@ -3388,12 +3389,16 @@ func (r *ClickHouseReader) GetDashboardsInfo(ctx context.Context) (*model.Dashboif isDashboardWithTSV2(dashboard.Data) {count = count + 1}+ if isDashboardWithLogsClickhouseQuery(dashboard.Data) {+ logChQueriesCount = logChQueriesCount + 1+ }}dashboardsInfo.DashboardNames = dashboardNamesdashboardsInfo.TotalDashboards = len(dashboardsData)dashboardsInfo.TotalDashboardsWithPanelAndName = totalDashboardsWithPanelAndNamedashboardsInfo.QueriesWithTSV2 = count+ dashboardsInfo.DashboardsWithLogsChQuery = logChQueriesCountreturn &dashboardsInfo, nil}@@ -3405,6 +3410,16 @@ func isDashboardWithTSV2(data map[string]interface{}) bool {return strings.Contains(string(jsonData), "time_series_v2")}+func isDashboardWithLogsClickhouseQuery(data map[string]interface{}) bool {+ jsonData, err := json.Marshal(data)+ if err != nil {+ return false+ }+ result := strings.Contains(string(jsonData), "signoz_logs.distributed_logs") ||+ strings.Contains(string(jsonData), "signoz_logs.logs")+ return result+}+func isDashboardWithPanelAndName(data map[string]interface{}) bool {isDashboardName := falseisDashboardWithPanelAndName := falsediff --git a/pkg/query-service/model/response.go b/pkg/query-service/model/response.goindex 5144dade47..4add34071e 100644--- a/pkg/query-service/model/response.go+++ b/pkg/query-service/model/response.go@@ -665,6 +665,7 @@ type AlertsInfo struct {SpanMetricsPrometheusQueries int `json:"spanMetricsPrometheusQueries"`AlertNames []string `json:"alertNames"`AlertsWithTSV2 int `json:"alertsWithTSv2"`+ AlertsWithLogsChQuery int `json:"alertsWithLogsChQuery"`}type SavedViewsInfo struct {@@ -681,6 +682,7 @@ type DashboardsInfo struct {TracesBasedPanels int `json:"tracesBasedPanels"`DashboardNames []string `json:"dashboardNames"`QueriesWithTSV2 int `json:"queriesWithTSV2"`+ DashboardsWithLogsChQuery int `json:"dashboardsWithLogsChQuery"`}type TagTelemetryData struct {diff --git a/pkg/query-service/rules/db.go b/pkg/query-service/rules/db.goindex d9a9be195c..f3a9de1c62 100644--- a/pkg/query-service/rules/db.go+++ b/pkg/query-service/rules/db.go@@ -319,6 +319,10 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {if strings.Contains(alert, "time_series_v2") {alertsInfo.AlertsWithTSV2 = alertsInfo.AlertsWithTSV2 + 1}+ if strings.Contains(alert, "signoz_logs.distributed_logs") ||+ strings.Contains(alert, "signoz_logs.logs") {+ alertsInfo.AlertsWithLogsChQuery = alertsInfo.AlertsWithLogsChQuery + 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.goindex 7f282ea3f9..048d23498f 100644--- a/pkg/query-service/telemetry/telemetry.go+++ b/pkg/query-service/telemetry/telemetry.go@@ -339,6 +339,7 @@ func createTelemetry() {"metricBasedPanels": dashboardsInfo.MetricBasedPanels,"tracesBasedPanels": dashboardsInfo.TracesBasedPanels,"dashboardsWithTSV2": dashboardsInfo.QueriesWithTSV2,+ "dashboardWithLogsChQuery": dashboardsInfo.DashboardsWithLogsChQuery,"totalAlerts": alertsInfo.TotalAlerts,"alertsWithTSV2": alertsInfo.AlertsWithTSV2,"logsBasedAlerts": alertsInfo.LogsBasedAlerts,@@ -358,6 +359,7 @@ func createTelemetry() {"metricsClickHouseQueries": alertsInfo.MetricsClickHouseQueries,"metricsPrometheusQueries": alertsInfo.MetricsPrometheusQueries,"spanMetricsPrometheusQueries": alertsInfo.SpanMetricsPrometheusQueries,+ "alertsWithLogsChQuery": alertsInfo.AlertsWithLogsChQuery,}// send event only if there are dashboards or alerts or channelsif (dashboardsInfo.TotalDashboards > 0 || alertsInfo.TotalAlerts > 0 || len(*channels) > 0 || savedViewsInfo.TotalSavedViews > 0) && apiErr == nil {