mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 06:26:03 +08:00
fix: add telemetry for trace migration (#6537)
This commit is contained in:
parent
24ab18d988
commit
a3e57a1829
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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"`
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user