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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(dashboard): add datasource and default values for query (#9705)
Vikrant Guptae716a2a7b1d0
diff --git a/pkg/types/dashboardtypes/dashboard.go b/pkg/types/dashboardtypes/dashboard.goindex 871620eaf5..414537ebbd 100644--- a/pkg/types/dashboardtypes/dashboard.go+++ b/pkg/types/dashboardtypes/dashboard.go@@ -334,6 +334,7 @@ func (dashboard *Dashboard) GetWidgetQuery(startTime, endTime uint64, widgetIndePromQL []map[string]any `json:"promql"`QueryType string `json:"queryType"`} `json:"query"`+ FillGaps bool `json:"fillSpans"`} `json:"widgets"`}@@ -414,6 +415,10 @@ func (dashboard *Dashboard) GetWidgetQuery(startTime, endTime uint64, widgetInde"compositeQuery": map[string]any{"queries": compositeQueries,},+ "formatOptions": map[string]any{+ "fillGaps": widgetData.FillGaps,+ "formatTableResultForUI": widgetData.PanelTypes == "table",+ },}req, err := json.Marshal(queryRangeReq)diff --git a/pkg/types/dashboardtypes/public_dashboard.go b/pkg/types/dashboardtypes/public_dashboard.goindex cf6466cecf..f4e055a18a 100644--- a/pkg/types/dashboardtypes/public_dashboard.go+++ b/pkg/types/dashboardtypes/public_dashboard.go@@ -128,86 +128,59 @@ func NewPublicDashboardDataFromDashboard(dashboard *Dashboard, publicDashboard *}for idx, widget := range data.Widgets {- switch widget.Query.QueryType {- case "builder":- widget.Query.ClickhouseSQL = []map[string]any{}- widget.Query.PromQL = []map[string]any{}-- updatedQueryData := []map[string]any{}- for _, queryData := range widget.Query.Builder.QueryData {- updatedQueryMap := map[string]any{}- updatedQueryMap["aggregations"] = queryData["aggregations"]- updatedQueryMap["legend"] = queryData["legend"]- updatedQueryMap["queryName"] = queryData["queryName"]- updatedQueryMap["expression"] = queryData["expression"]- updatedQueryMap["groupBy"] = queryData["groupBy"]- updatedQueryData = append(updatedQueryData, updatedQueryMap)- }- widget.Query.Builder.QueryData = updatedQueryData-- updatedQueryFormulas := []map[string]any{}- for _, queryFormula := range widget.Query.Builder.QueryFormulas {- updatedQueryFormulaMap := map[string]any{}- updatedQueryFormulaMap["legend"] = queryFormula["legend"]- updatedQueryFormulaMap["queryName"] = queryFormula["queryName"]- updatedQueryFormulaMap["expression"] = queryFormula["expression"]- updatedQueryFormulas = append(updatedQueryFormulas, updatedQueryFormulaMap)- }- widget.Query.Builder.QueryFormulas = updatedQueryFormulas-- updatedQueryTraceOperator := []map[string]any{}- for _, queryTraceOperator := range widget.Query.Builder.QueryTraceOperator {- updatedQueryTraceOperatorMap := map[string]any{}- updatedQueryTraceOperatorMap["aggregations"] = queryTraceOperator["aggregations"]- updatedQueryTraceOperatorMap["legend"] = queryTraceOperator["legend"]- updatedQueryTraceOperatorMap["queryName"] = queryTraceOperator["queryName"]- updatedQueryTraceOperatorMap["expression"] = queryTraceOperator["expression"]- updatedQueryTraceOperatorMap["groupBy"] = queryTraceOperator["groupBy"]- updatedQueryTraceOperator = append(updatedQueryTraceOperator, updatedQueryTraceOperatorMap)- }- widget.Query.Builder.QueryTraceOperator = updatedQueryTraceOperator-- case "clickhouse_sql":- widget.Query.Builder = struct {- QueryData []map[string]any `json:"queryData"`- QueryFormulas []map[string]any `json:"queryFormulas"`- QueryTraceOperator []map[string]any `json:"queryTraceOperator"`- }{}- widget.Query.PromQL = []map[string]any{}-- updatedClickhouseSQLQuery := []map[string]any{}- for _, clickhouseSQLQuery := range widget.Query.ClickhouseSQL {- updatedClickhouseSQLQueryMap := make(map[string]any)- updatedClickhouseSQLQueryMap["legend"] = clickhouseSQLQuery["legend"]- updatedClickhouseSQLQueryMap["name"] = clickhouseSQLQuery["name"]- updatedClickhouseSQLQuery = append(updatedClickhouseSQLQuery, updatedClickhouseSQLQueryMap)- }- widget.Query.ClickhouseSQL = updatedClickhouseSQLQuery- case "promql":- widget.Query.Builder = struct {- QueryData []map[string]any `json:"queryData"`- QueryFormulas []map[string]any `json:"queryFormulas"`- QueryTraceOperator []map[string]any `json:"queryTraceOperator"`- }{}- widget.Query.ClickhouseSQL = []map[string]any{}-- updatedPromQLQuery := []map[string]any{}- for _, promQLQuery := range widget.Query.PromQL {- updatedPromQLQueryMap := make(map[string]any)- updatedPromQLQueryMap["legend"] = promQLQuery["legend"]- updatedPromQLQueryMap["name"] = promQLQuery["name"]- updatedPromQLQuery = append(updatedPromQLQuery, updatedPromQLQueryMap)- }- widget.Query.PromQL = updatedPromQLQuery- default:- widget.Query.Builder = struct {- QueryData []map[string]any `json:"queryData"`- QueryFormulas []map[string]any `json:"queryFormulas"`- QueryTraceOperator []map[string]any `json:"queryTraceOperator"`- }{}- widget.Query.ClickhouseSQL = []map[string]any{}- widget.Query.PromQL = []map[string]any{}+ updatedQueryData := []map[string]any{}+ for _, queryData := range widget.Query.Builder.QueryData {+ updatedQueryMap := map[string]any{}+ updatedQueryMap["aggregations"] = queryData["aggregations"]+ updatedQueryMap["legend"] = queryData["legend"]+ updatedQueryMap["queryName"] = queryData["queryName"]+ updatedQueryMap["expression"] = queryData["expression"]+ updatedQueryMap["groupBy"] = queryData["groupBy"]+ updatedQueryMap["dataSource"] = queryData["dataSource"]+ updatedQueryData = append(updatedQueryData, updatedQueryMap)+ }+ widget.Query.Builder.QueryData = updatedQueryData++ updatedQueryFormulas := []map[string]any{}+ for _, queryFormula := range widget.Query.Builder.QueryFormulas {+ updatedQueryFormulaMap := map[string]any{}+ updatedQueryFormulaMap["legend"] = queryFormula["legend"]+ updatedQueryFormulaMap["queryName"] = queryFormula["queryName"]+ updatedQueryFormulaMap["expression"] = queryFormula["expression"]+ updatedQueryFormulas = append(updatedQueryFormulas, updatedQueryFormulaMap)+ }+ widget.Query.Builder.QueryFormulas = updatedQueryFormulas++ updatedQueryTraceOperator := []map[string]any{}+ for _, queryTraceOperator := range widget.Query.Builder.QueryTraceOperator {+ updatedQueryTraceOperatorMap := map[string]any{}+ updatedQueryTraceOperatorMap["aggregations"] = queryTraceOperator["aggregations"]+ updatedQueryTraceOperatorMap["legend"] = queryTraceOperator["legend"]+ updatedQueryTraceOperatorMap["queryName"] = queryTraceOperator["queryName"]+ updatedQueryTraceOperatorMap["expression"] = queryTraceOperator["expression"]+ updatedQueryTraceOperatorMap["groupBy"] = queryTraceOperator["groupBy"]+ updatedQueryTraceOperatorMap["dataSource"] = queryTraceOperator["dataSource"]+ updatedQueryTraceOperator = append(updatedQueryTraceOperator, updatedQueryTraceOperatorMap)+ }+ widget.Query.Builder.QueryTraceOperator = updatedQueryTraceOperator++ updatedClickhouseSQLQuery := []map[string]any{}+ for _, clickhouseSQLQuery := range widget.Query.ClickhouseSQL {+ updatedClickhouseSQLQueryMap := make(map[string]any)+ updatedClickhouseSQLQueryMap["legend"] = clickhouseSQLQuery["legend"]+ updatedClickhouseSQLQueryMap["name"] = clickhouseSQLQuery["name"]+ updatedClickhouseSQLQuery = append(updatedClickhouseSQLQuery, updatedClickhouseSQLQueryMap)+ }+ widget.Query.ClickhouseSQL = updatedClickhouseSQLQuery++ updatedPromQLQuery := []map[string]any{}+ for _, promQLQuery := range widget.Query.PromQL {+ updatedPromQLQueryMap := make(map[string]any)+ updatedPromQLQueryMap["legend"] = promQLQuery["legend"]+ updatedPromQLQueryMap["name"] = promQLQuery["name"]+ updatedPromQLQuery = append(updatedPromQLQuery, updatedPromQLQueryMap)}+ widget.Query.PromQL = updatedPromQLQueryif widgets, ok := dashboard.Data["widgets"].([]any); ok {if widgetMap, ok := widgets[idx].(map[string]any); ok {