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: make some fields required in perses replicated spec (#11612)

Naman Vermadf26eb1c1db0
diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml
index 6acbc432dc..e8195b5b1c 100644
--- a/docs/api/openapi.yml
+++ b/docs/api/openapi.yml
@@ -2436,13 +2436,6 @@ components:
url:
type: string
type: object
- DashboardPanelDisplay:
- properties:
- description:
- type: string
- name:
- type: string
- type: object
DashboardTextVariableSpec:
properties:
constant:
@@ -2570,13 +2563,12 @@ components:
$ref: '#/components/schemas/DashboardtypesDatasourceSpec'
type: object
display:
- $ref: '#/components/schemas/CommonDisplay'
+ $ref: '#/components/schemas/DashboardtypesDisplay'
duration:
type: string
layouts:
items:
$ref: '#/components/schemas/DashboardtypesLayout'
- nullable: true
type: array
links:
items:
@@ -2585,7 +2577,6 @@ components:
panels:
additionalProperties:
$ref: '#/components/schemas/DashboardtypesPanel'
- nullable: true
type: object
refreshInterval:
type: string
@@ -2593,6 +2584,11 @@ components:
items:
$ref: '#/components/schemas/DashboardtypesVariable'
type: array
+ required:
+ - display
+ - variables
+ - panels
+ - layouts
type: object
DashboardtypesDatasourcePlugin:
discriminator:
@@ -2628,6 +2624,15 @@ components:
plugin:
$ref: '#/components/schemas/DashboardtypesDatasourcePlugin'
type: object
+ DashboardtypesDisplay:
+ properties:
+ description:
+ type: string
+ name:
+ type: string
+ required:
+ - name
+ type: object
DashboardtypesDynamicVariableSpec:
properties:
name:
@@ -2822,7 +2827,7 @@ components:
defaultValue:
$ref: '#/components/schemas/VariableDefaultValue'
display:
- $ref: '#/components/schemas/VariableDisplay'
+ $ref: '#/components/schemas/DashboardtypesDisplay'
name:
type: string
plugin:
@@ -2830,6 +2835,8 @@ components:
sort:
nullable: true
type: string
+ required:
+ - display
type: object
DashboardtypesListableDashboardForUserV2:
properties:
@@ -2957,7 +2964,7 @@ components:
DashboardtypesListedDashboardV2Spec:
properties:
display:
- $ref: '#/components/schemas/CommonDisplay'
+ $ref: '#/components/schemas/DashboardtypesDisplay'
type: object
DashboardtypesNumberPanelSpec:
properties:
@@ -2977,6 +2984,9 @@ components:
$ref: '#/components/schemas/DashboardtypesPanelKind'
spec:
$ref: '#/components/schemas/DashboardtypesPanelSpec'
+ required:
+ - kind
+ - spec
type: object
DashboardtypesPanelFormatting:
properties:
@@ -3106,7 +3116,7 @@ components:
DashboardtypesPanelSpec:
properties:
display:
- $ref: '#/components/schemas/DashboardPanelDisplay'
+ $ref: '#/components/schemas/DashboardtypesDisplay'
links:
items:
$ref: '#/components/schemas/DashboardLink'
@@ -3116,7 +3126,12 @@ components:
queries:
items:
$ref: '#/components/schemas/DashboardtypesQuery'
+ nullable: true
type: array
+ required:
+ - display
+ - plugin
+ - queries
type: object
DashboardtypesPatchOp:
enum:
@@ -3185,6 +3200,9 @@ components:
$ref: '#/components/schemas/Querybuildertypesv5RequestType'
spec:
$ref: '#/components/schemas/DashboardtypesQuerySpec'
+ required:
+ - kind
+ - spec
type: object
DashboardtypesQueryPlugin:
discriminator:
@@ -3291,6 +3309,8 @@ components:
type: string
plugin:
$ref: '#/components/schemas/DashboardtypesQueryPlugin'
+ required:
+ - plugin
type: object
DashboardtypesQueryVariableSpec:
properties:
diff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.ts
index 7ed0166f42..9bccab4694 100644
--- a/frontend/src/api/generated/services/sigNoz.schemas.ts
+++ b/frontend/src/api/generated/services/sigNoz.schemas.ts
@@ -3156,17 +3156,6 @@ export interface DashboardLinkDTO {
url?: string;
}
-export interface DashboardPanelDisplayDTO {
- /**
- * @type string
- */
- description?: string;
- /**
- * @type string
- */
- name?: string;
-}
-
export interface VariableDisplayDTO {
/**
* @type string
@@ -3892,6 +3881,17 @@ export type DashboardtypesDashboardSpecDTODatasources = {
export enum DashboardtypesPanelKindDTO {
Panel = 'Panel',
}
+export interface DashboardtypesDisplayDTO {
+ /**
+ * @type string
+ */
+ description?: string;
+ /**
+ * @type string
+ */
+ name: string;
+}
+
export enum DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesTimeSeriesPanelSpecDTOKind {
'signoz/TimeSeriesPanel' = 'signoz/TimeSeriesPanel',
}
@@ -4440,42 +4440,36 @@ export interface DashboardtypesQuerySpecDTO {
* @type string
*/
name?: string;
- plugin?: DashboardtypesQueryPluginDTO;
+ plugin: DashboardtypesQueryPluginDTO;
}
export interface DashboardtypesQueryDTO {
- kind?: Querybuildertypesv5RequestTypeDTO;
- spec?: DashboardtypesQuerySpecDTO;
+ kind: Querybuildertypesv5RequestTypeDTO;
+ spec: DashboardtypesQuerySpecDTO;
}
export interface DashboardtypesPanelSpecDTO {
- display?: DashboardPanelDisplayDTO;
+ display: DashboardtypesDisplayDTO;
/**
* @type array
*/
links?: DashboardLinkDTO[];
- plugin?: DashboardtypesPanelPluginDTO;
+ plugin: DashboardtypesPanelPluginDTO;
/**
- * @type array
+ * @type array,null
*/
- queries?: DashboardtypesQueryDTO[];
+ queries: DashboardtypesQueryDTO[] | null;
}
export interface DashboardtypesPanelDTO {
- kind?: DashboardtypesPanelKindDTO;
- spec?: DashboardtypesPanelSpecDTO;
+ kind: DashboardtypesPanelKindDTO;
+ spec: DashboardtypesPanelSpecDTO;
}
-export type DashboardtypesDashboardSpecDTOPanelsAnyOf = {
+export type DashboardtypesDashboardSpecDTOPanels = {
[key: string]: DashboardtypesPanelDTO;
};
-/**
- * @nullable
- */
-export type DashboardtypesDashboardSpecDTOPanels =
- DashboardtypesDashboardSpecDTOPanelsAnyOf | null;
-
export enum DashboardtypesLayoutEnvelopeGithubComPersesSpecGoDashboardGridLayoutSpecDTOKind {
Grid = 'Grid',
}
@@ -4572,7 +4566,7 @@ export interface DashboardtypesListVariableSpecDTO {
*/
customAllValue?: string;
defaultValue?: VariableDefaultValueDTO;
- display?: VariableDisplayDTO;
+ display: DashboardtypesDisplayDTO;
/**
* @type string
*/
@@ -4614,23 +4608,23 @@ export interface DashboardtypesDashboardSpecDTO {
* @type object
*/
datasources?: DashboardtypesDashboardSpecDTODatasources;
- display?: CommonDisplayDTO;
+ display: DashboardtypesDisplayDTO;
/**
* @type string
*/
duration?: string;
/**
- * @type array,null
+ * @type array
*/
- layouts?: DashboardtypesLayoutDTO[] | null;
+ layouts: DashboardtypesLayoutDTO[];
/**
* @type array
*/
links?: DashboardLinkDTO[];
/**
- * @type object,null
+ * @type object
*/
- panels?: DashboardtypesDashboardSpecDTOPanels;
+ panels: DashboardtypesDashboardSpecDTOPanels;
/**
* @type string
*/
@@ -4638,7 +4632,7 @@ export interface DashboardtypesDashboardSpecDTO {
/**
* @type array
*/
- variables?: DashboardtypesVariableDTO[];
+ variables: DashboardtypesVariableDTO[];
}
export enum DashboardtypesDatasourcePluginKindDTO {
@@ -4762,7 +4756,7 @@ export enum DashboardtypesListSortDTO {
name = 'name',
}
export interface DashboardtypesListedDashboardV2SpecDTO {
- display?: CommonDisplayDTO;
+ display?: DashboardtypesDisplayDTO;
}
export interface DashboardtypesListedDashboardForUserV2DTO {
diff --git a/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsList.tsx b/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsList.tsx
index cc41e393f9..98cc70b938 100644
--- a/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsList.tsx
+++ b/frontend/src/pages/DashboardsListPageV2/components/DashboardsList/DashboardsList.tsx
@@ -133,6 +133,10 @@ function DashboardsList(): JSX.Element {
tags: null,
spec: {
display: { name: t('new_dashboard_title', { ns: 'dashboard' }) },
+ layouts: [],
+ panels: {},
+ variables: [],
+ // TODO(@AshwinBhatkal): duration and refresh interval need to be integrated
},
});
safeNavigate(
diff --git a/pkg/types/dashboardtypes/list_v2.go b/pkg/types/dashboardtypes/list_v2.go
index 2a1622f794..6dd7d84054 100644
--- a/pkg/types/dashboardtypes/list_v2.go
+++ b/pkg/types/dashboardtypes/list_v2.go
@@ -7,7 +7,6 @@ import (
"github.com/SigNoz/signoz/pkg/types"
"github.com/SigNoz/signoz/pkg/types/tagtypes"
"github.com/SigNoz/signoz/pkg/valuer"
- "github.com/perses/spec/go/common"
)
const (
@@ -110,7 +109,7 @@ type listedDashboardV2 struct {
}
type listedDashboardV2Spec struct {
- Display *common.Display `json:"display,omitempty"`
+ Display Display `json:"display,omitempty"`
}
func newListedDashboardV2(v2 *DashboardV2) *listedDashboardV2 {
diff --git a/pkg/types/dashboardtypes/perses_dashboard.go b/pkg/types/dashboardtypes/perses_dashboard.go
index e391f4c7fd..cd936a2f92 100644
--- a/pkg/types/dashboardtypes/perses_dashboard.go
+++ b/pkg/types/dashboardtypes/perses_dashboard.go
@@ -12,7 +12,6 @@ import (
"github.com/SigNoz/signoz/pkg/types/coretypes"
"github.com/SigNoz/signoz/pkg/types/tagtypes"
"github.com/SigNoz/signoz/pkg/valuer"
- "github.com/perses/spec/go/common"
"k8s.io/apimachinery/pkg/util/validation"
)
@@ -168,9 +167,6 @@ func (p *PostableDashboardV2) UnmarshalJSON(data []byte) error {
return errors.WrapInvalidInputf(err, ErrCodeDashboardInvalidInput, "%s", err.Error())
}
*p = PostableDashboardV2(tmp)
- if p.Spec.Display == nil {
- p.Spec.Display = &common.Display{}
- }
if !p.GenerateName && p.Spec.Display.Name == "" {
p.Spec.Display.Name = p.Name
}
@@ -197,7 +193,7 @@ func (p *PostableDashboardV2) validateName() error {
if p.Name != "" {
return errors.NewInvalidInputf(ErrCodeDashboardInvalidInput, "name must be empty when generateName is true, got %q", p.Name)
}
- if p.Spec.Display == nil || p.Spec.Display.Name == "" {
+ if p.Spec.Display.Name == "" {
return errors.NewInvalidInputf(ErrCodeDashboardInvalidInput, "spec.display.name is required when generateName is true")
}
return nil
@@ -341,9 +337,6 @@ func (u *UpdatableDashboardV2) UnmarshalJSON(data []byte) error {
return errors.WrapInvalidInputf(err, ErrCodeDashboardInvalidInput, "%s", err.Error())
}
*u = UpdatableDashboardV2(tmp)
- if u.Spec.Display == nil {
- u.Spec.Display = &common.Display{}
- }
if u.Spec.Display.Name == "" {
u.Spec.Display.Name = u.Name
}
diff --git a/pkg/types/dashboardtypes/perses_dashboard_convertors_test.go b/pkg/types/dashboardtypes/perses_dashboard_convertors_test.go
index f3c01fd592..660c6f3e53 100644
--- a/pkg/types/dashboardtypes/perses_dashboard_convertors_test.go
+++ b/pkg/types/dashboardtypes/perses_dashboard_convertors_test.go
@@ -8,10 +8,9 @@ import (
"github.com/SigNoz/signoz/pkg/types"
"github.com/SigNoz/signoz/pkg/types/coretypes"
- "github.com/SigNoz/signoz/pkg/types/tagtypes"
qb "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5"
+ "github.com/SigNoz/signoz/pkg/types/tagtypes"
"github.com/SigNoz/signoz/pkg/valuer"
- "github.com/perses/spec/go/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -166,7 +165,7 @@ func TestPostableDashboardV2NewDashboardV2(t *testing.T) {
DashboardV2MetadataBase: DashboardV2MetadataBase{SchemaVersion: SchemaVersion},
GenerateName: true,
Spec: DashboardSpec{
- Display: &common.Display{Name: "My Dashboard!"},
+ Display: Display{Name: "My Dashboard!"},
},
}
diff --git a/pkg/types/dashboardtypes/perses_dashboard_data.go b/pkg/types/dashboardtypes/perses_dashboard_data.go
index 58ed091351..bfc884d089 100644
--- a/pkg/types/dashboardtypes/perses_dashboard_data.go
+++ b/pkg/types/dashboardtypes/perses_dashboard_data.go
@@ -17,12 +17,12 @@ import (
// occurrence is replaced with a typed SigNoz plugin whose OpenAPI schema is a
// per-site discriminated oneOf.
type DashboardSpec struct {
- Display *common.Display `json:"display,omitempty"`
+ Display Display `json:"display" required:"true"`
Datasources map[string]*DatasourceSpec `json:"datasources,omitempty"`
- Variables []Variable `json:"variables,omitempty"`
- Panels map[string]*Panel `json:"panels"`
- Layouts []Layout `json:"layouts"`
- Duration common.DurationString `json:"duration"`
+ Variables []Variable `json:"variables" required:"true" nullable:"false"`
+ Panels map[string]*Panel `json:"panels" required:"true" nullable:"false"`
+ Layouts []Layout `json:"layouts" required:"true" nullable:"false"`
+ Duration common.DurationString `json:"duration,omitempty"`
RefreshInterval common.DurationString `json:"refreshInterval,omitempty"`
Links []dashboard.Link `json:"links,omitempty"`
}
diff --git a/pkg/types/dashboardtypes/perses_plugin_wrappers.go b/pkg/types/dashboardtypes/perses_plugin_wrappers.go
index cb87d55e04..ff42b18f17 100644
--- a/pkg/types/dashboardtypes/perses_plugin_wrappers.go
+++ b/pkg/types/dashboardtypes/perses_plugin_wrappers.go
@@ -18,8 +18,8 @@ import (
// ══════════════════════════════════════════════
type PanelPlugin struct {
- Kind PanelPluginKind `json:"kind"`
- Spec any `json:"spec"`
+ Kind PanelPluginKind `json:"kind" required:"true"`
+ Spec any `json:"spec" required:"true"`
}
// PrepareJSONSchema marks the envelope with x-signoz-discriminator;
@@ -81,8 +81,8 @@ func (v PanelPluginVariant[S]) PrepareJSONSchema(s *jsonschema.Schema) error {
// ══════════════════════════════════════════════
type QueryPlugin struct {
- Kind QueryPluginKind `json:"kind"`
- Spec any `json:"spec"`
+ Kind QueryPluginKind `json:"kind" required:"true"`
+ Spec any `json:"spec" required:"true"`
}
func (QueryPlugin) PrepareJSONSchema(s *jsonschema.Schema) error {
@@ -139,8 +139,8 @@ func (v QueryPluginVariant[S]) PrepareJSONSchema(s *jsonschema.Schema) error {
// ══════════════════════════════════════════════
type VariablePlugin struct {
- Kind VariablePluginKind `json:"kind"`
- Spec any `json:"spec"`
+ Kind VariablePluginKind `json:"kind" required:"true"`
+ Spec any `json:"spec" required:"true"`
}
func (VariablePlugin) PrepareJSONSchema(s *jsonschema.Schema) error {
@@ -191,8 +191,8 @@ func (v VariablePluginVariant[S]) PrepareJSONSchema(s *jsonschema.Schema) error
// ══════════════════════════════════════════════
type DatasourcePlugin struct {
- Kind DatasourcePluginKind `json:"kind"`
- Spec any `json:"spec"`
+ Kind DatasourcePluginKind `json:"kind" required:"true"`
+ Spec any `json:"spec" required:"true"`
}
func (DatasourcePlugin) PrepareJSONSchema(s *jsonschema.Schema) error {
diff --git a/pkg/types/dashboardtypes/perses_replicas.go b/pkg/types/dashboardtypes/perses_replicas.go
index 2436b96b2e..448548d3d0 100644
--- a/pkg/types/dashboardtypes/perses_replicas.go
+++ b/pkg/types/dashboardtypes/perses_replicas.go
@@ -13,6 +13,11 @@ import (
"github.com/swaggest/jsonschema-go"
)
+type Display struct {
+ Name string `json:"name" required:"true"`
+ Description string `json:"description,omitempty"`
+}
+
// ══════════════════════════════════════════════
// Datasource
// ══════════════════════════════════════════════
@@ -28,8 +33,8 @@ type DatasourceSpec struct {
// ══════════════════════════════════════════════
type Panel struct {
- Kind PanelKind `json:"kind"`
- Spec PanelSpec `json:"spec"`
+ Kind PanelKind `json:"kind" required:"true"`
+ Spec PanelSpec `json:"spec" required:"true"`
}
// PanelKind is the panel envelope discriminator. Perses leaves it a free
@@ -54,10 +59,10 @@ func (k *PanelKind) UnmarshalJSON(data []byte) error {
}
type PanelSpec struct {
- Display *dashboard.PanelDisplay `json:"display,omitempty"`
- Plugin PanelPlugin `json:"plugin"`
- Queries []Query `json:"queries,omitempty"`
- Links []dashboard.Link `json:"links,omitempty"`
+ Display Display `json:"display" required:"true"`
+ Plugin PanelPlugin `json:"plugin" required:"true"`
+ Queries []Query `json:"queries" required:"true"`
+ Links []dashboard.Link `json:"links,omitempty"`
}
// ══════════════════════════════════════════════
@@ -65,13 +70,13 @@ type PanelSpec struct {
// ══════════════════════════════════════════════
type Query struct {
- Kind qb.RequestType `json:"kind"`
- Spec QuerySpec `json:"spec"`
+ Kind qb.RequestType `json:"kind" required:"true"`
+ Spec QuerySpec `json:"spec" required:"true"`
}
type QuerySpec struct {
Name string `json:"name,omitempty"`
- Plugin QueryPlugin `json:"plugin"`
+ Plugin QueryPlugin `json:"plugin" required:"true"`
}
// ══════════════════════════════════════════════
@@ -82,8 +87,8 @@ type QuerySpec struct {
// *dashboard.TextVariableSpec by UnmarshalJSON based on Kind. The schema is a
// discriminated oneOf (see JSONSchemaOneOf).
type Variable struct {
- Kind variable.Kind `json:"kind"`
- Spec any `json:"spec"`
+ Kind variable.Kind `json:"kind" required:"true"`
+ Spec any `json:"spec" required:"true"`
}
func (Variable) PrepareJSONSchema(s *jsonschema.Schema) error {
@@ -138,7 +143,7 @@ func (v VariableEnvelope[S]) PrepareJSONSchema(s *jsonschema.Schema) error {
// ListVariableSpec mirrors dashboard.ListVariableSpec (variable.ListSpec
// fields + Name) but with a typed VariablePlugin replacing common.Plugin.
type ListVariableSpec struct {
- Display *variable.Display `json:"display,omitempty"`
+ Display Display `json:"display" required:"true"`
DefaultValue *variable.DefaultValue `json:"defaultValue,omitempty"`
AllowAllValue bool `json:"allowAllValue"`
AllowMultiple bool `json:"allowMultiple"`
@@ -158,8 +163,8 @@ type ListVariableSpec struct {
// based on Kind. No plugin is involved, so we reuse the Perses spec types as
// leaf imports.
type Layout struct {
- Kind dashboard.LayoutKind `json:"kind"`
- Spec any `json:"spec"`
+ Kind dashboard.LayoutKind `json:"kind" required:"true"`
+ Spec any `json:"spec" required:"true"`
}
// layoutSpecs is the layout sum type factory. Perses only defines