mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 15:05:55 +08:00
chore: add telemetry for dashboards/alerts with tsv2 table (#5677)
This commit is contained in:
parent
5d903b5487
commit
29f1883edd
@ -3346,17 +3346,30 @@ func (r *ClickHouseReader) GetDashboardsInfo(ctx context.Context) (*model.Dashbo
|
|||||||
return &dashboardsInfo, err
|
return &dashboardsInfo, err
|
||||||
}
|
}
|
||||||
totalDashboardsWithPanelAndName := 0
|
totalDashboardsWithPanelAndName := 0
|
||||||
|
count := 0
|
||||||
for _, dashboard := range dashboardsData {
|
for _, dashboard := range dashboardsData {
|
||||||
if isDashboardWithPanelAndName(dashboard.Data) {
|
if isDashboardWithPanelAndName(dashboard.Data) {
|
||||||
totalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName + 1
|
totalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName + 1
|
||||||
}
|
}
|
||||||
dashboardsInfo = countPanelsInDashboard(dashboard.Data)
|
dashboardsInfo = countPanelsInDashboard(dashboard.Data)
|
||||||
|
if isDashboardWithTSV2(dashboard.Data) {
|
||||||
|
count = count + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dashboardsInfo.TotalDashboards = len(dashboardsData)
|
dashboardsInfo.TotalDashboards = len(dashboardsData)
|
||||||
dashboardsInfo.TotalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName
|
dashboardsInfo.TotalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName
|
||||||
|
dashboardsInfo.QueriesWithTSV2 = count
|
||||||
return &dashboardsInfo, nil
|
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 {
|
func isDashboardWithPanelAndName(data map[string]interface{}) bool {
|
||||||
isDashboardName := false
|
isDashboardName := false
|
||||||
isDashboardWithPanelAndName := false
|
isDashboardWithPanelAndName := false
|
||||||
|
@ -648,6 +648,7 @@ type AlertsInfo struct {
|
|||||||
MetricsClickHouseQueries int `json:"metricsClickHouseQueries"`
|
MetricsClickHouseQueries int `json:"metricsClickHouseQueries"`
|
||||||
MetricsPrometheusQueries int `json:"metricsPrometheusQueries"`
|
MetricsPrometheusQueries int `json:"metricsPrometheusQueries"`
|
||||||
SpanMetricsPrometheusQueries int `json:"spanMetricsPrometheusQueries"`
|
SpanMetricsPrometheusQueries int `json:"spanMetricsPrometheusQueries"`
|
||||||
|
AlertsWithTSV2 int `json:"alertsWithTSv2"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SavedViewsInfo struct {
|
type SavedViewsInfo struct {
|
||||||
@ -661,6 +662,7 @@ type DashboardsInfo struct {
|
|||||||
TotalDashboardsWithPanelAndName int `json:"totalDashboardsWithPanelAndName"` // dashboards with panel and name without sample title
|
TotalDashboardsWithPanelAndName int `json:"totalDashboardsWithPanelAndName"` // dashboards with panel and name without sample title
|
||||||
LogsBasedPanels int `json:"logsBasedPanels"`
|
LogsBasedPanels int `json:"logsBasedPanels"`
|
||||||
MetricBasedPanels int `json:"metricBasedPanels"`
|
MetricBasedPanels int `json:"metricBasedPanels"`
|
||||||
|
QueriesWithTSV2 int `json:"queriesWithTSV2"`
|
||||||
TracesBasedPanels int `json:"tracesBasedPanels"`
|
TracesBasedPanels int `json:"tracesBasedPanels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +315,9 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
|
|||||||
}
|
}
|
||||||
for _, alert := range alertsData {
|
for _, alert := range alertsData {
|
||||||
var rule GettableRule
|
var rule GettableRule
|
||||||
|
if strings.Contains(alert, "time_series_v2") {
|
||||||
|
alertsInfo.AlertsWithTSV2 = alertsInfo.AlertsWithTSV2 + 1
|
||||||
|
}
|
||||||
err = json.Unmarshal([]byte(alert), &rule)
|
err = json.Unmarshal([]byte(alert), &rule)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.L().Error("invalid rule data", zap.Error(err))
|
zap.L().Error("invalid rule data", zap.Error(err))
|
||||||
|
@ -317,7 +317,9 @@ func createTelemetry() {
|
|||||||
"logsBasedPanels": dashboardsInfo.LogsBasedPanels,
|
"logsBasedPanels": dashboardsInfo.LogsBasedPanels,
|
||||||
"metricBasedPanels": dashboardsInfo.MetricBasedPanels,
|
"metricBasedPanels": dashboardsInfo.MetricBasedPanels,
|
||||||
"tracesBasedPanels": dashboardsInfo.TracesBasedPanels,
|
"tracesBasedPanels": dashboardsInfo.TracesBasedPanels,
|
||||||
|
"dashboardsWithTSV2": dashboardsInfo.QueriesWithTSV2,
|
||||||
"totalAlerts": alertsInfo.TotalAlerts,
|
"totalAlerts": alertsInfo.TotalAlerts,
|
||||||
|
"alertsWithTSV2": alertsInfo.AlertsWithTSV2,
|
||||||
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,
|
"logsBasedAlerts": alertsInfo.LogsBasedAlerts,
|
||||||
"metricBasedAlerts": alertsInfo.MetricBasedAlerts,
|
"metricBasedAlerts": alertsInfo.MetricBasedAlerts,
|
||||||
"tracesBasedAlerts": alertsInfo.TracesBasedAlerts,
|
"tracesBasedAlerts": alertsInfo.TracesBasedAlerts,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user