mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 04:35:58 +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.MetricBasedPanels += dashboardsInfo.MetricBasedPanels
|
||||||
dashboardsInfo.LogsPanelsWithAttrContainsOp += dashboardInfo.LogsPanelsWithAttrContainsOp
|
dashboardsInfo.LogsPanelsWithAttrContainsOp += dashboardInfo.LogsPanelsWithAttrContainsOp
|
||||||
dashboardsInfo.DashboardsWithLogsChQuery += dashboardInfo.DashboardsWithLogsChQuery
|
dashboardsInfo.DashboardsWithLogsChQuery += dashboardInfo.DashboardsWithLogsChQuery
|
||||||
|
dashboardsInfo.DashboardsWithTraceChQuery += dashboardInfo.DashboardsWithTraceChQuery
|
||||||
if isDashboardWithTSV2(dashboard.Data) {
|
if isDashboardWithTSV2(dashboard.Data) {
|
||||||
count = count + 1
|
count = count + 1
|
||||||
}
|
}
|
||||||
@ -499,6 +500,18 @@ func isDashboardWithLogsClickhouseQuery(data map[string]interface{}) bool {
|
|||||||
return result
|
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 {
|
func isDashboardWithPanelAndName(data map[string]interface{}) bool {
|
||||||
isDashboardName := false
|
isDashboardName := false
|
||||||
isDashboardWithPanelAndName := false
|
isDashboardWithPanelAndName := false
|
||||||
@ -559,7 +572,9 @@ func checkLogPanelAttrContains(data map[string]interface{}) int {
|
|||||||
|
|
||||||
func countPanelsInDashboard(inputData map[string]interface{}) model.DashboardsInfo {
|
func countPanelsInDashboard(inputData map[string]interface{}) model.DashboardsInfo {
|
||||||
var logsPanelCount, tracesPanelCount, metricsPanelCount, logsPanelsWithAttrContains int
|
var logsPanelCount, tracesPanelCount, metricsPanelCount, logsPanelsWithAttrContains int
|
||||||
var logChQuery bool
|
traceChQueryCount := 0
|
||||||
|
logChQueryCount := 0
|
||||||
|
|
||||||
// totalPanels := 0
|
// totalPanels := 0
|
||||||
if inputData != nil && inputData["widgets"] != nil {
|
if inputData != nil && inputData["widgets"] != nil {
|
||||||
widgets, ok := inputData["widgets"]
|
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 {
|
} else if ok && query["queryType"] == "clickhouse_sql" && query["clickhouse_sql"] != nil {
|
||||||
if isDashboardWithLogsClickhouseQuery(inputData) {
|
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{
|
return model.DashboardsInfo{
|
||||||
LogsBasedPanels: logsPanelCount,
|
LogsBasedPanels: logsPanelCount,
|
||||||
TracesBasedPanels: tracesPanelCount,
|
TracesBasedPanels: tracesPanelCount,
|
||||||
MetricBasedPanels: metricsPanelCount,
|
MetricBasedPanels: metricsPanelCount,
|
||||||
|
|
||||||
DashboardsWithLogsChQuery: logChQueryCount,
|
DashboardsWithLogsChQuery: logChQueryCount,
|
||||||
|
DashboardsWithTraceChQuery: traceChQueryCount,
|
||||||
LogsPanelsWithAttrContainsOp: logsPanelsWithAttrContains,
|
LogsPanelsWithAttrContainsOp: logsPanelsWithAttrContains,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -636,6 +636,7 @@ type AlertsInfo struct {
|
|||||||
AlertNames []string `json:"alertNames"`
|
AlertNames []string `json:"alertNames"`
|
||||||
AlertsWithTSV2 int `json:"alertsWithTSv2"`
|
AlertsWithTSV2 int `json:"alertsWithTSv2"`
|
||||||
AlertsWithLogsChQuery int `json:"alertsWithLogsChQuery"`
|
AlertsWithLogsChQuery int `json:"alertsWithLogsChQuery"`
|
||||||
|
AlertsWithTraceChQuery int `json:"alertsWithTraceChQuery"`
|
||||||
AlertsWithLogsContainsOp int `json:"alertsWithLogsContainsOp"`
|
AlertsWithLogsContainsOp int `json:"alertsWithLogsContainsOp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,6 +657,7 @@ type DashboardsInfo struct {
|
|||||||
DashboardNames []string `json:"dashboardNames"`
|
DashboardNames []string `json:"dashboardNames"`
|
||||||
QueriesWithTSV2 int `json:"queriesWithTSV2"`
|
QueriesWithTSV2 int `json:"queriesWithTSV2"`
|
||||||
DashboardsWithLogsChQuery int `json:"dashboardsWithLogsChQuery"`
|
DashboardsWithLogsChQuery int `json:"dashboardsWithLogsChQuery"`
|
||||||
|
DashboardsWithTraceChQuery int `json:"dashboardsWithTraceChQuery"`
|
||||||
LogsPanelsWithAttrContainsOp int `json:"logsPanelsWithAttrContainsOp"`
|
LogsPanelsWithAttrContainsOp int `json:"logsPanelsWithAttrContainsOp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,6 +604,16 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
|
|||||||
}
|
}
|
||||||
} else if rule.AlertType == AlertTypeTraces {
|
} else if rule.AlertType == AlertTypeTraces {
|
||||||
alertsInfo.TracesBasedAlerts = alertsInfo.TracesBasedAlerts + 1
|
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
|
alertsInfo.TotalAlerts = alertsInfo.TotalAlerts + 1
|
||||||
}
|
}
|
||||||
|
@ -307,8 +307,11 @@ func createTelemetry() {
|
|||||||
"getLogsInfoInLastHeartBeatInterval": getLogsInfoInLastHeartBeatInterval,
|
"getLogsInfoInLastHeartBeatInterval": getLogsInfoInLastHeartBeatInterval,
|
||||||
"countUsers": userCount,
|
"countUsers": userCount,
|
||||||
"metricsTTLStatus": metricsTTL.Status,
|
"metricsTTLStatus": metricsTTL.Status,
|
||||||
|
"metricsTTLValue": metricsTTL.MetricsMoveTime,
|
||||||
"tracesTTLStatus": traceTTL.Status,
|
"tracesTTLStatus": traceTTL.Status,
|
||||||
|
"traceTTLValue": traceTTL.TracesTime,
|
||||||
"logsTTLStatus": logsTTL.Status,
|
"logsTTLStatus": logsTTL.Status,
|
||||||
|
"logsTTLValue": logsTTL.LogsTime,
|
||||||
"patUser": telemetry.patTokenUser,
|
"patUser": telemetry.patTokenUser,
|
||||||
}
|
}
|
||||||
telemetry.patTokenUser = false
|
telemetry.patTokenUser = false
|
||||||
@ -343,6 +346,7 @@ func createTelemetry() {
|
|||||||
"tracesBasedPanels": dashboardsInfo.TracesBasedPanels,
|
"tracesBasedPanels": dashboardsInfo.TracesBasedPanels,
|
||||||
"dashboardsWithTSV2": dashboardsInfo.QueriesWithTSV2,
|
"dashboardsWithTSV2": dashboardsInfo.QueriesWithTSV2,
|
||||||
"dashboardWithLogsChQuery": dashboardsInfo.DashboardsWithLogsChQuery,
|
"dashboardWithLogsChQuery": dashboardsInfo.DashboardsWithLogsChQuery,
|
||||||
|
"dashboardWithTraceChQuery": dashboardsInfo.DashboardsWithTraceChQuery,
|
||||||
"totalAlerts": alertsInfo.TotalAlerts,
|
"totalAlerts": alertsInfo.TotalAlerts,
|
||||||
"alertsWithTSV2": alertsInfo.AlertsWithTSV2,
|
"alertsWithTSV2": alertsInfo.AlertsWithTSV2,
|
||||||
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,
|
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,
|
||||||
@ -366,6 +370,7 @@ func createTelemetry() {
|
|||||||
"spanMetricsPrometheusQueries": alertsInfo.SpanMetricsPrometheusQueries,
|
"spanMetricsPrometheusQueries": alertsInfo.SpanMetricsPrometheusQueries,
|
||||||
"alertsWithLogsChQuery": alertsInfo.AlertsWithLogsChQuery,
|
"alertsWithLogsChQuery": alertsInfo.AlertsWithLogsChQuery,
|
||||||
"alertsWithLogsContainsOp": alertsInfo.AlertsWithLogsContainsOp,
|
"alertsWithLogsContainsOp": alertsInfo.AlertsWithLogsContainsOp,
|
||||||
|
"alertsWithTraceChQuery": alertsInfo.AlertsWithTraceChQuery,
|
||||||
}
|
}
|
||||||
// send event only if there are dashboards or alerts or channels
|
// 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 {
|
if (dashboardsInfo.TotalDashboards > 0 || alertsInfo.TotalAlerts > 0 || alertsInfo.TotalChannels > 0 || savedViewsInfo.TotalSavedViews > 0) && apiErr == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user