Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

chore: dashboard and alert names (#5705)

Vishal Sharma871e5ada9e7d
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go
index 5f33bfe2a9..8dce05250d 100644
--- a/pkg/query-service/app/clickhouseReader/reader.go
+++ b/pkg/query-service/app/clickhouseReader/reader.go
@@ -3346,16 +3346,26 @@ func (r *ClickHouseReader) GetDashboardsInfo(ctx context.Context) (*model.Dashbo
return &dashboardsInfo, err
}
totalDashboardsWithPanelAndName := 0
+ var dashboardNames []string
count := 0
for _, dashboard := range dashboardsData {
if isDashboardWithPanelAndName(dashboard.Data) {
totalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName + 1
}
- dashboardsInfo = countPanelsInDashboard(dashboard.Data)
+ dashboardName := extractDashboardName(dashboard.Data)
+ if dashboardName != "" {
+ dashboardNames = append(dashboardNames, dashboardName)
+ }
+ dashboardInfo := countPanelsInDashboard(dashboard.Data)
+ dashboardsInfo.LogsBasedPanels += dashboardInfo.LogsBasedPanels
+ dashboardsInfo.TracesBasedPanels += dashboardInfo.TracesBasedPanels
+ dashboardsInfo.MetricBasedPanels += dashboardsInfo.MetricBasedPanels
if isDashboardWithTSV2(dashboard.Data) {
count = count + 1
}
}
+
+ dashboardsInfo.DashboardNames = dashboardNames
dashboardsInfo.TotalDashboards = len(dashboardsData)
dashboardsInfo.TotalDashboardsWithPanelAndName = totalDashboardsWithPanelAndName
dashboardsInfo.QueriesWithTSV2 = count
@@ -3389,6 +3399,19 @@ func isDashboardWithPanelAndName(data map[string]interface{}) bool {
return isDashboardWithPanelAndName
}
+
+func extractDashboardName(data map[string]interface{}) string {
+
+ if data != nil && data["title"] != nil {
+ title, ok := data["title"].(string)
+ if ok {
+ return title
+ }
+ }
+
+ return ""
+}
+
func countPanelsInDashboard(data map[string]interface{}) model.DashboardsInfo {
var logsPanelCount, tracesPanelCount, metricsPanelCount int
// totalPanels := 0
diff --git a/pkg/query-service/model/response.go b/pkg/query-service/model/response.go
index b8250bd1d3..83df872175 100644
--- a/pkg/query-service/model/response.go
+++ b/pkg/query-service/model/response.go
@@ -634,21 +634,22 @@ type TagsInfo struct {
}
type AlertsInfo struct {
- TotalAlerts int `json:"totalAlerts"`
- LogsBasedAlerts int `json:"logsBasedAlerts"`
- MetricBasedAlerts int `json:"metricBasedAlerts"`
- TracesBasedAlerts int `json:"tracesBasedAlerts"`
- SlackChannels int `json:"slackChannels"`
- WebHookChannels int `json:"webHookChannels"`
- PagerDutyChannels int `json:"pagerDutyChannels"`
- OpsGenieChannels int `json:"opsGenieChannels"`
- EmailChannels int `json:"emailChannels"`
- MSTeamsChannels int `json:"microsoftTeamsChannels"`
- MetricsBuilderQueries int `json:"metricsBuilderQueries"`
- MetricsClickHouseQueries int `json:"metricsClickHouseQueries"`
- MetricsPrometheusQueries int `json:"metricsPrometheusQueries"`
- SpanMetricsPrometheusQueries int `json:"spanMetricsPrometheusQueries"`
- AlertsWithTSV2 int `json:"alertsWithTSv2"`
+ TotalAlerts int `json:"totalAlerts"`
+ LogsBasedAlerts int `json:"logsBasedAlerts"`
+ MetricBasedAlerts int `json:"metricBasedAlerts"`
+ TracesBasedAlerts int `json:"tracesBasedAlerts"`
+ SlackChannels int `json:"slackChannels"`
+ WebHookChannels int `json:"webHookChannels"`
+ PagerDutyChannels int `json:"pagerDutyChannels"`
+ OpsGenieChannels int `json:"opsGenieChannels"`
+ EmailChannels int `json:"emailChannels"`
+ MSTeamsChannels int `json:"microsoftTeamsChannels"`
+ MetricsBuilderQueries int `json:"metricsBuilderQueries"`
+ MetricsClickHouseQueries int `json:"metricsClickHouseQueries"`
+ MetricsPrometheusQueries int `json:"metricsPrometheusQueries"`
+ SpanMetricsPrometheusQueries int `json:"spanMetricsPrometheusQueries"`
+ AlertNames []string `json:"alertNames"`
+ AlertsWithTSV2 int `json:"alertsWithTSv2"`
}
type SavedViewsInfo struct {
@@ -658,12 +659,13 @@ type SavedViewsInfo struct {
}
type DashboardsInfo struct {
- TotalDashboards int `json:"totalDashboards"`
- 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"`
+ TotalDashboards int `json:"totalDashboards"`
+ TotalDashboardsWithPanelAndName int `json:"totalDashboardsWithPanelAndName"` // dashboards with panel and name without sample title
+ LogsBasedPanels int `json:"logsBasedPanels"`
+ MetricBasedPanels int `json:"metricBasedPanels"`
+ TracesBasedPanels int `json:"tracesBasedPanels"`
+ DashboardNames []string `json:"dashboardNames"`
+ QueriesWithTSV2 int `json:"queriesWithTSV2"`
}
type TagTelemetryData struct {
diff --git a/pkg/query-service/rules/db.go b/pkg/query-service/rules/db.go
index c49a8dd391..37e45f2711 100644
--- a/pkg/query-service/rules/db.go
+++ b/pkg/query-service/rules/db.go
@@ -308,6 +308,7 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
// fetch alerts from rules db
query := "SELECT data FROM rules"
var alertsData []string
+ var alertNames []string
err := r.Select(&alertsData, query)
if err != nil {
zap.L().Error("Error in processing sql query", zap.Error(err))
@@ -323,6 +324,7 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
zap.L().Error("invalid rule data", zap.Error(err))
continue
}
+ alertNames = append(alertNames, rule.AlertName)
if rule.AlertType == "LOGS_BASED_ALERT" {
alertsInfo.LogsBasedAlerts = alertsInfo.LogsBasedAlerts + 1
} else if rule.AlertType == "METRIC_BASED_ALERT" {
@@ -346,6 +348,6 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
}
alertsInfo.TotalAlerts = alertsInfo.TotalAlerts + 1
}
-
+ alertsInfo.AlertNames = alertNames
return &alertsInfo, nil
}
diff --git a/pkg/query-service/telemetry/telemetry.go b/pkg/query-service/telemetry/telemetry.go
index ecfa86298e..c916135f4e 100644
--- a/pkg/query-service/telemetry/telemetry.go
+++ b/pkg/query-service/telemetry/telemetry.go
@@ -314,6 +314,8 @@ func createTelemetry() {
dashboardsAlertsData := map[string]interface{}{
"totalDashboards": dashboardsInfo.TotalDashboards,
"totalDashboardsWithPanelAndName": dashboardsInfo.TotalDashboardsWithPanelAndName,
+ "dashboardNames": dashboardsInfo.DashboardNames,
+ "alertNames": alertsInfo.AlertNames,
"logsBasedPanels": dashboardsInfo.LogsBasedPanels,
"metricBasedPanels": dashboardsInfo.MetricBasedPanels,
"tracesBasedPanels": dashboardsInfo.TracesBasedPanels,