diff --git a/pkg/query-service/app/dashboards/model.go b/pkg/query-service/app/dashboards/model.go index 21d39fcbe4..d4b11d8502 100644 --- a/pkg/query-service/app/dashboards/model.go +++ b/pkg/query-service/app/dashboards/model.go @@ -468,6 +468,7 @@ func GetDashboardsInfo(ctx context.Context) (*model.DashboardsInfo, error) { dashboardsInfo.MetricBasedPanels += dashboardsInfo.MetricBasedPanels dashboardsInfo.LogsPanelsWithAttrContainsOp += dashboardInfo.LogsPanelsWithAttrContainsOp dashboardsInfo.DashboardsWithLogsChQuery += dashboardInfo.DashboardsWithLogsChQuery + dashboardsInfo.DashboardsWithTraceChQuery += dashboardInfo.DashboardsWithTraceChQuery if isDashboardWithTSV2(dashboard.Data) { count = count + 1 } @@ -499,6 +500,18 @@ func isDashboardWithLogsClickhouseQuery(data map[string]interface{}) bool { return result } +func isDashboardWithTracesClickhouseQuery(data map[string]interface{}) bool { + jsonData, err := json.Marshal(data) + if err != nil { + return false + } + str := string(jsonData) + result := strings.Contains(str, "signoz_traces.distributed_signoz_index_v2") || + strings.Contains(str, "signoz_traces.distributed_signoz_spans") || + strings.Contains(str, "signoz_traces.distributed_signoz_error_index_v2") + return result +} + func isDashboardWithPanelAndName(data map[string]interface{}) bool { isDashboardName := false isDashboardWithPanelAndName := false @@ -559,7 +572,9 @@ func checkLogPanelAttrContains(data map[string]interface{}) int { func countPanelsInDashboard(inputData map[string]interface{}) model.DashboardsInfo { var logsPanelCount, tracesPanelCount, metricsPanelCount, logsPanelsWithAttrContains int - var logChQuery bool + traceChQueryCount := 0 + logChQueryCount := 0 + // totalPanels := 0 if inputData != nil && inputData["widgets"] != nil { widgets, ok := inputData["widgets"] @@ -593,7 +608,10 @@ func countPanelsInDashboard(inputData map[string]interface{}) model.DashboardsIn } } else if ok && query["queryType"] == "clickhouse_sql" && query["clickhouse_sql"] != nil { if isDashboardWithLogsClickhouseQuery(inputData) { - logChQuery = true + logChQueryCount = 1 + } + if isDashboardWithTracesClickhouseQuery(inputData) { + traceChQueryCount = 1 } } } @@ -602,16 +620,13 @@ func countPanelsInDashboard(inputData map[string]interface{}) model.DashboardsIn } } - logChQueryCount := 0 - if logChQuery { - logChQueryCount = 1 - } return model.DashboardsInfo{ LogsBasedPanels: logsPanelCount, TracesBasedPanels: tracesPanelCount, MetricBasedPanels: metricsPanelCount, DashboardsWithLogsChQuery: logChQueryCount, + DashboardsWithTraceChQuery: traceChQueryCount, LogsPanelsWithAttrContainsOp: logsPanelsWithAttrContains, } } diff --git a/pkg/query-service/model/response.go b/pkg/query-service/model/response.go index 4d7fb9d230..d0d4a51b60 100644 --- a/pkg/query-service/model/response.go +++ b/pkg/query-service/model/response.go @@ -636,6 +636,7 @@ type AlertsInfo struct { AlertNames []string `json:"alertNames"` AlertsWithTSV2 int `json:"alertsWithTSv2"` AlertsWithLogsChQuery int `json:"alertsWithLogsChQuery"` + AlertsWithTraceChQuery int `json:"alertsWithTraceChQuery"` AlertsWithLogsContainsOp int `json:"alertsWithLogsContainsOp"` } @@ -656,6 +657,7 @@ type DashboardsInfo struct { DashboardNames []string `json:"dashboardNames"` QueriesWithTSV2 int `json:"queriesWithTSV2"` DashboardsWithLogsChQuery int `json:"dashboardsWithLogsChQuery"` + DashboardsWithTraceChQuery int `json:"dashboardsWithTraceChQuery"` LogsPanelsWithAttrContainsOp int `json:"logsPanelsWithAttrContainsOp"` } diff --git a/pkg/query-service/rules/db.go b/pkg/query-service/rules/db.go index c9db38201b..3fe8c5cc95 100644 --- a/pkg/query-service/rules/db.go +++ b/pkg/query-service/rules/db.go @@ -604,6 +604,16 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) { } } else if rule.AlertType == AlertTypeTraces { alertsInfo.TracesBasedAlerts = alertsInfo.TracesBasedAlerts + 1 + + if rule.RuleCondition != nil && rule.RuleCondition.CompositeQuery != nil { + if rule.RuleCondition.CompositeQuery.QueryType == v3.QueryTypeClickHouseSQL { + if strings.Contains(alert, "signoz_traces.distributed_signoz_index_v2") || + strings.Contains(alert, "signoz_traces.distributed_signoz_spans") || + strings.Contains(alert, "signoz_traces.distributed_signoz_error_index_v2") { + alertsInfo.AlertsWithTraceChQuery = alertsInfo.AlertsWithTraceChQuery + 1 + } + } + } } alertsInfo.TotalAlerts = alertsInfo.TotalAlerts + 1 } diff --git a/pkg/query-service/telemetry/telemetry.go b/pkg/query-service/telemetry/telemetry.go index 1e2a1a1998..0de96a0f69 100644 --- a/pkg/query-service/telemetry/telemetry.go +++ b/pkg/query-service/telemetry/telemetry.go @@ -307,8 +307,11 @@ func createTelemetry() { "getLogsInfoInLastHeartBeatInterval": getLogsInfoInLastHeartBeatInterval, "countUsers": userCount, "metricsTTLStatus": metricsTTL.Status, + "metricsTTLValue": metricsTTL.MetricsMoveTime, "tracesTTLStatus": traceTTL.Status, + "traceTTLValue": traceTTL.TracesTime, "logsTTLStatus": logsTTL.Status, + "logsTTLValue": logsTTL.LogsTime, "patUser": telemetry.patTokenUser, } telemetry.patTokenUser = false @@ -343,6 +346,7 @@ func createTelemetry() { "tracesBasedPanels": dashboardsInfo.TracesBasedPanels, "dashboardsWithTSV2": dashboardsInfo.QueriesWithTSV2, "dashboardWithLogsChQuery": dashboardsInfo.DashboardsWithLogsChQuery, + "dashboardWithTraceChQuery": dashboardsInfo.DashboardsWithTraceChQuery, "totalAlerts": alertsInfo.TotalAlerts, "alertsWithTSV2": alertsInfo.AlertsWithTSV2, "logsBasedAlerts": alertsInfo.LogsBasedAlerts, @@ -366,6 +370,7 @@ func createTelemetry() { "spanMetricsPrometheusQueries": alertsInfo.SpanMetricsPrometheusQueries, "alertsWithLogsChQuery": alertsInfo.AlertsWithLogsChQuery, "alertsWithLogsContainsOp": alertsInfo.AlertsWithLogsContainsOp, + "alertsWithTraceChQuery": alertsInfo.AlertsWithTraceChQuery, } // send event only if there are dashboards or alerts or channels if (dashboardsInfo.TotalDashboards > 0 || alertsInfo.TotalAlerts > 0 || alertsInfo.TotalChannels > 0 || savedViewsInfo.TotalSavedViews > 0) && apiErr == nil {