fix: add dashbard names and update logs count in telemetry (#6553)

This commit is contained in:
Nityananda Gohain 2024-11-28 20:46:06 +05:30 committed by GitHub
parent 813cd845f4
commit f7f8bf1867
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 1 deletions

View File

@ -2540,7 +2540,7 @@ func (r *ClickHouseReader) GetTotalLogs(ctx context.Context) (uint64, error) {
var totalLogs uint64
queryStr := fmt.Sprintf("SELECT count() from %s.%s;", r.logsDB, r.logsTable)
queryStr := fmt.Sprintf("SELECT count() from %s.%s;", r.logsDB, r.logsTableName)
r.db.QueryRow(ctx, queryStr).Scan(&totalLogs)
return totalLogs, nil

View File

@ -472,6 +472,11 @@ func GetDashboardsInfo(ctx context.Context) (*model.DashboardsInfo, error) {
if isDashboardWithTSV2(dashboard.Data) {
count = count + 1
}
if dashboardInfo.DashboardsWithTraceChQuery > 0 {
dashboardsInfo.DashboardNamesWithTraceChQuery = append(dashboardsInfo.DashboardNamesWithTraceChQuery, dashboardName)
}
// check if dashboard is a has a log operator with contains
}
@ -505,6 +510,8 @@ func isDashboardWithTracesClickhouseQuery(data map[string]interface{}) bool {
if err != nil {
return false
}
// also check if the query is actually active
str := string(jsonData)
result := strings.Contains(str, "signoz_traces.distributed_signoz_index_v2") ||
strings.Contains(str, "signoz_traces.distributed_signoz_spans") ||

View File

@ -658,6 +658,7 @@ type DashboardsInfo struct {
QueriesWithTSV2 int `json:"queriesWithTSV2"`
DashboardsWithLogsChQuery int `json:"dashboardsWithLogsChQuery"`
DashboardsWithTraceChQuery int `json:"dashboardsWithTraceChQuery"`
DashboardNamesWithTraceChQuery []string `json:"dashboardNamesWithTraceChQuery"`
LogsPanelsWithAttrContainsOp int `json:"logsPanelsWithAttrContainsOp"`
}

View File

@ -347,6 +347,7 @@ func createTelemetry() {
"dashboardsWithTSV2": dashboardsInfo.QueriesWithTSV2,
"dashboardWithLogsChQuery": dashboardsInfo.DashboardsWithLogsChQuery,
"dashboardWithTraceChQuery": dashboardsInfo.DashboardsWithTraceChQuery,
"dashboardNamesWithTraceChQuery": dashboardsInfo.DashboardNamesWithTraceChQuery,
"totalAlerts": alertsInfo.TotalAlerts,
"alertsWithTSV2": alertsInfo.AlertsWithTSV2,
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,