chore: add telemetry for dashboards/alerts with tsv2 table (#5677)

This commit is contained in:
Srikanth Chekuri 2024-08-16 16:16:12 +05:30 committed by GitHub
parent 5d903b5487
commit 29f1883edd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 0 deletions

View File

@ -3346,17 +3346,30 @@ func (r *ClickHouseReader) GetDashboardsInfo(ctx context.Context) (*model.Dashbo
return &dashboardsInfo, err
}
totalDashboardsWithPanelAndName := 0
count := 0
for _, dashboard := range dashboardsData {
if isDashboardWithPanelAndName(dashboard.Data) {
totalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName + 1
}
dashboardsInfo = countPanelsInDashboard(dashboard.Data)
if isDashboardWithTSV2(dashboard.Data) {
count = count + 1
}
}
dashboardsInfo.TotalDashboards = len(dashboardsData)
dashboardsInfo.TotalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName
dashboardsInfo.QueriesWithTSV2 = count
return &dashboardsInfo, nil
}
func isDashboardWithTSV2(data map[string]interface{}) bool {
jsonData, err := json.Marshal(data)
if err != nil {
return false
}
return strings.Contains(string(jsonData), "time_series_v2")
}
func isDashboardWithPanelAndName(data map[string]interface{}) bool {
isDashboardName := false
isDashboardWithPanelAndName := false

View File

@ -648,6 +648,7 @@ type AlertsInfo struct {
MetricsClickHouseQueries int `json:"metricsClickHouseQueries"`
MetricsPrometheusQueries int `json:"metricsPrometheusQueries"`
SpanMetricsPrometheusQueries int `json:"spanMetricsPrometheusQueries"`
AlertsWithTSV2 int `json:"alertsWithTSv2"`
}
type SavedViewsInfo struct {
@ -661,6 +662,7 @@ type DashboardsInfo struct {
TotalDashboardsWithPanelAndName int `json:"totalDashboardsWithPanelAndName"` // dashboards with panel and name without sample title
LogsBasedPanels int `json:"logsBasedPanels"`
MetricBasedPanels int `json:"metricBasedPanels"`
QueriesWithTSV2 int `json:"queriesWithTSV2"`
TracesBasedPanels int `json:"tracesBasedPanels"`
}

View File

@ -315,6 +315,9 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
}
for _, alert := range alertsData {
var rule GettableRule
if strings.Contains(alert, "time_series_v2") {
alertsInfo.AlertsWithTSV2 = alertsInfo.AlertsWithTSV2 + 1
}
err = json.Unmarshal([]byte(alert), &rule)
if err != nil {
zap.L().Error("invalid rule data", zap.Error(err))

View File

@ -317,7 +317,9 @@ func createTelemetry() {
"logsBasedPanels": dashboardsInfo.LogsBasedPanels,
"metricBasedPanels": dashboardsInfo.MetricBasedPanels,
"tracesBasedPanels": dashboardsInfo.TracesBasedPanels,
"dashboardsWithTSV2": dashboardsInfo.QueriesWithTSV2,
"totalAlerts": alertsInfo.TotalAlerts,
"alertsWithTSV2": alertsInfo.AlertsWithTSV2,
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,
"metricBasedAlerts": alertsInfo.MetricBasedAlerts,
"tracesBasedAlerts": alertsInfo.TracesBasedAlerts,