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.

feat(dashboard): add public dashboard APIs to open-api spec (#9899)

Vikrant Gupta0b890154b46d
diff --git a/cmd/community/server.go b/cmd/community/server.go
index 6a059e2688..bb33627712 100644
--- a/cmd/community/server.go
+++ b/cmd/community/server.go
@@ -14,8 +14,13 @@ import (
"github.com/SigNoz/signoz/pkg/factory"
"github.com/SigNoz/signoz/pkg/licensing"
"github.com/SigNoz/signoz/pkg/licensing/nooplicensing"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
"github.com/SigNoz/signoz/pkg/modules/organization"
+ "github.com/SigNoz/signoz/pkg/modules/role"
+ "github.com/SigNoz/signoz/pkg/querier"
"github.com/SigNoz/signoz/pkg/query-service/app"
+ "github.com/SigNoz/signoz/pkg/queryparser"
"github.com/SigNoz/signoz/pkg/signoz"
"github.com/SigNoz/signoz/pkg/sqlschema"
"github.com/SigNoz/signoz/pkg/sqlstore"
@@ -82,6 +87,9 @@ func runServer(ctx context.Context, config signoz.Config, logger *slog.Logger) e
func(ctx context.Context, sqlstore sqlstore.SQLStore) factory.ProviderFactory[authz.AuthZ, authz.Config] {
return openfgaauthz.NewProviderFactory(sqlstore, openfgaschema.NewSchema().Get(ctx))
},
+ func(store sqlstore.SQLStore, settings factory.ProviderSettings, analytics analytics.Analytics, orgGetter organization.Getter, _ role.Module, queryParser queryparser.QueryParser, _ querier.Querier, _ licensing.Licensing) dashboard.Module {
+ return impldashboard.NewModule(impldashboard.NewStore(store), settings, analytics, orgGetter, queryParser)
+ },
)
if err != nil {
logger.ErrorContext(ctx, "failed to create signoz", "error", err)
diff --git a/cmd/enterprise/server.go b/cmd/enterprise/server.go
index aac32981c1..5bac2dcb90 100644
--- a/cmd/enterprise/server.go
+++ b/cmd/enterprise/server.go
@@ -12,6 +12,7 @@ import (
"github.com/SigNoz/signoz/ee/authz/openfgaschema"
enterpriselicensing "github.com/SigNoz/signoz/ee/licensing"
"github.com/SigNoz/signoz/ee/licensing/httplicensing"
+ "github.com/SigNoz/signoz/ee/modules/dashboard/impldashboard"
enterpriseapp "github.com/SigNoz/signoz/ee/query-service/app"
"github.com/SigNoz/signoz/ee/sqlschema/postgressqlschema"
"github.com/SigNoz/signoz/ee/sqlstore/postgressqlstore"
@@ -22,7 +23,12 @@ import (
"github.com/SigNoz/signoz/pkg/authz"
"github.com/SigNoz/signoz/pkg/factory"
"github.com/SigNoz/signoz/pkg/licensing"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard"
+ pkgimpldashboard "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
"github.com/SigNoz/signoz/pkg/modules/organization"
+ "github.com/SigNoz/signoz/pkg/modules/role"
+ "github.com/SigNoz/signoz/pkg/querier"
+ "github.com/SigNoz/signoz/pkg/queryparser"
"github.com/SigNoz/signoz/pkg/signoz"
"github.com/SigNoz/signoz/pkg/sqlschema"
"github.com/SigNoz/signoz/pkg/sqlstore"
@@ -111,6 +117,9 @@ func runServer(ctx context.Context, config signoz.Config, logger *slog.Logger) e
func(ctx context.Context, sqlstore sqlstore.SQLStore) factory.ProviderFactory[authz.AuthZ, authz.Config] {
return openfgaauthz.NewProviderFactory(sqlstore, openfgaschema.NewSchema().Get(ctx))
},
+ func(store sqlstore.SQLStore, settings factory.ProviderSettings, analytics analytics.Analytics, orgGetter organization.Getter, role role.Module, queryParser queryparser.QueryParser, querier querier.Querier, licensing licensing.Licensing) dashboard.Module {
+ return impldashboard.NewModule(pkgimpldashboard.NewStore(store), settings, analytics, orgGetter, role, queryParser, querier, licensing)
+ },
)
if err != nil {
logger.ErrorContext(ctx, "failed to create signoz", "error", err)
diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml
index 031f9b208d..b3d5c6ff59 100644
--- a/docs/api/openapi.yml
+++ b/docs/api/openapi.yml
@@ -206,6 +206,201 @@ paths:
summary: Create session by saml callback
tags:
- sessions
+ /api/v1/dashboards/{id}/public:
+ delete:
+ deprecated: false
+ description: This endpoints deletes the public sharing config and disables the
+ public sharing of a dashboard
+ operationId: DeletePublicDashboard
+ parameters:
+ - in: path
+ name: id
+ required: true
+ schema:
+ type: string
+ responses:
+ "204":
+ content:
+ application/json:
+ schema:
+ type: string
+ description: No Content
+ "401":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Unauthorized
+ "403":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Forbidden
+ "500":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Internal Server Error
+ security:
+ - api_key:
+ - ADMIN
+ - tokenizer:
+ - ADMIN
+ summary: Delete public dashboard
+ tags:
+ - dashboard
+ get:
+ deprecated: false
+ description: This endpoints returns public sharing config for a dashboard
+ operationId: GetPublicDashboard
+ parameters:
+ - in: path
+ name: id
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ content:
+ application/json:
+ schema:
+ properties:
+ data:
+ $ref: '#/components/schemas/DashboardtypesGettablePublicDasbhboard'
+ status:
+ type: string
+ type: object
+ description: OK
+ "401":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Unauthorized
+ "403":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Forbidden
+ "500":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Internal Server Error
+ security:
+ - api_key:
+ - ADMIN
+ - tokenizer:
+ - ADMIN
+ summary: Get public dashboard
+ tags:
+ - dashboard
+ post:
+ deprecated: false
+ description: This endpoints creates public sharing config and enables public
+ sharing of the dashboard
+ operationId: CreatePublicDashboard
+ parameters:
+ - in: path
+ name: id
+ required: true
+ schema:
+ type: string
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/DashboardtypesPostablePublicDashboard'
+ responses:
+ "201":
+ content:
+ application/json:
+ schema:
+ properties:
+ data:
+ $ref: '#/components/schemas/TypesIdentifiable'
+ status:
+ type: string
+ type: object
+ description: Created
+ "401":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Unauthorized
+ "403":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Forbidden
+ "500":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Internal Server Error
+ security:
+ - api_key:
+ - ADMIN
+ - tokenizer:
+ - ADMIN
+ summary: Create public dashboard
+ tags:
+ - dashboard
+ put:
+ deprecated: false
+ description: This endpoints updates the public sharing config for a dashboard
+ operationId: UpdatePublicDashboard
+ parameters:
+ - in: path
+ name: id
+ required: true
+ schema:
+ type: string
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/DashboardtypesUpdatablePublicDashboard'
+ responses:
+ "204":
+ content:
+ application/json:
+ schema:
+ type: string
+ description: No Content
+ "401":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Unauthorized
+ "403":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Forbidden
+ "500":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Internal Server Error
+ security:
+ - api_key:
+ - ADMIN
+ - tokenizer:
+ - ADMIN
+ summary: Update public dashboard
+ tags:
+ - dashboard
/api/v1/domains:
get:
deprecated: false
@@ -1286,6 +1481,107 @@ paths:
summary: Update api key
tags:
- users
+ /api/v1/public/dashboards/{id}:
+ get:
+ deprecated: false
+ description: This endpoints returns the sanitized dashboard data for public
+ access
+ operationId: GetPublicDashboardData
+ parameters:
+ - in: path
+ name: id
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ content:
+ application/json:
+ schema:
+ properties:
+ data:
+ $ref: '#/components/schemas/DashboardtypesGettablePublicDashboardData'
+ status:
+ type: string
+ type: object
+ description: OK
+ "401":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Unauthorized
+ "403":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Forbidden
+ "500":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Internal Server Error
+ security:
+ - anonymous:
+ - public-dashboard:read
+ summary: Get public dashboard data
+ tags:
+ - dashboard
+ /api/v1/public/dashboards/{id}/widgets/{idx}/query_range:
+ get:
+ deprecated: false
+ description: This endpoint return query range results for a widget of public
+ dashboard
+ operationId: GetPublicDashboardWidgetQueryRange
+ parameters:
+ - in: path
+ name: id
+ required: true
+ schema:
+ type: string
+ - in: path
+ name: idx
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ content:
+ application/json:
+ schema:
+ properties:
+ data:
+ $ref: '#/components/schemas/Querybuildertypesv5QueryRangeResponse'
+ status:
+ type: string
+ type: object
+ description: OK
+ "401":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Unauthorized
+ "403":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Forbidden
+ "500":
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RenderErrorResponse'
+ description: Internal Server Error
+ security:
+ - anonymous:
+ - public-dashboard:read
+ summary: Get query range result
+ tags:
+ - dashboard
/api/v1/resetPassword:
post:
deprecated: false
@@ -2200,6 +2496,60 @@ components:
config:
$ref: '#/components/schemas/AuthtypesAuthDomainConfig'
type: object
+ DashboardtypesDashboard:
+ properties:
+ createdAt:
+ format: date-time
+ type: string
+ createdBy:
+ type: string
+ data:
+ $ref: '#/components/schemas/DashboardtypesStorableDashboardData'
+ id:
+ type: string
+ locked:
+ type: boolean
+ org_id:
+ type: string
+ updatedAt:
+ format: date-time
+ type: string
+ updatedBy:
+ type: string
+ type: object
+ DashboardtypesGettablePublicDasbhboard:
+ properties:
+ defaultTimeRange:
+ type: string
+ publicPath:
+ type: string
+ timeRangeEnabled:
+ type: boolean
+ type: object
+ DashboardtypesGettablePublicDashboardData:
+ properties:
+ dashboard:
+ $ref: '#/components/schemas/DashboardtypesDashboard'
+ publicDashboard:
+ $ref: '#/components/schemas/DashboardtypesGettablePublicDasbhboard'
+ type: object
+ DashboardtypesPostablePublicDashboard:
+ properties:
+ defaultTimeRange:
+ type: string
+ timeRangeEnabled:
+ type: boolean
+ type: object
+ DashboardtypesStorableDashboardData:
+ additionalProperties: {}
+ type: object
+ DashboardtypesUpdatablePublicDashboard:
+ properties:
+ defaultTimeRange:
+ type: string
+ timeRangeEnabled:
+ type: boolean
+ type: object
ErrorsJSON:
properties:
code:
@@ -2285,6 +2635,52 @@ components:
type:
type: string
type: object
+ Querybuildertypesv5ExecStats:
+ properties:
+ bytesScanned:
+ minimum: 0
+ type: integer
+ durationMs:
+ minimum: 0
+ type: integer
+ rowsScanned:
+ minimum: 0
+ type: integer
+ type: object
+ Querybuildertypesv5QueryData:
+ properties:
+ results:
+ items: {}
+ nullable: true
+ type: array
+ type: object
+ Querybuildertypesv5QueryRangeResponse:
+ properties:
+ data:
+ $ref: '#/components/schemas/Querybuildertypesv5QueryData'
+ meta:
+ $ref: '#/components/schemas/Querybuildertypesv5ExecStats'
+ type:
+ type: string
+ warning:
+ $ref: '#/components/schemas/Querybuildertypesv5QueryWarnData'
+ type: object
+ Querybuildertypesv5QueryWarnData:
+ properties:
+ message:
+ type: string
+ url:
+ type: string
+ warnings:
+ items:
+ $ref: '#/components/schemas/Querybuildertypesv5QueryWarnDataAdditional'
+ type: array
+ type: object
+ Querybuildertypesv5QueryWarnDataAdditional:
+ properties:
+ message:
+ type: string
+ type: object
RenderErrorResponse:
properties:
error:
@@ -2343,6 +2739,11 @@ components:
ingestion_url:
type: string
type: object
+ TypesIdentifiable:
+ properties:
+ id:
+ type: string
+ type: object
TypesInvite:
properties:
createdAt:
diff --git a/ee/modules/dashboard/impldashboard/module.go b/ee/modules/dashboard/impldashboard/module.go
new file mode 100644
index 0000000000..1777ae992f
--- /dev/null
+++ b/ee/modules/dashboard/impldashboard/module.go
@@ -0,0 +1,265 @@
+package impldashboard
+
+import (
+ "context"
+ "maps"
+
+ "github.com/SigNoz/signoz/pkg/analytics"
+ "github.com/SigNoz/signoz/pkg/errors"
+ "github.com/SigNoz/signoz/pkg/factory"
+ "github.com/SigNoz/signoz/pkg/licensing"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard"
+ pkgimpldashboard "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
+ "github.com/SigNoz/signoz/pkg/modules/organization"
+ "github.com/SigNoz/signoz/pkg/modules/role"
+ "github.com/SigNoz/signoz/pkg/querier"
+ "github.com/SigNoz/signoz/pkg/queryparser"
+ "github.com/SigNoz/signoz/pkg/types"
+ "github.com/SigNoz/signoz/pkg/types/authtypes"
+ "github.com/SigNoz/signoz/pkg/types/dashboardtypes"
+ "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5"
+ "github.com/SigNoz/signoz/pkg/types/roletypes"
+ "github.com/SigNoz/signoz/pkg/valuer"
+)
+
+type module struct {
+ pkgDashboardModule dashboard.Module
+ store dashboardtypes.Store
+ settings factory.ScopedProviderSettings
+ role role.Module
+ querier querier.Querier
+ licensing licensing.Licensing
+}
+
+func NewModule(store dashboardtypes.Store, settings factory.ProviderSettings, analytics analytics.Analytics, orgGetter organization.Getter, role role.Module, queryParser queryparser.QueryParser, querier querier.Querier, licensing licensing.Licensing) dashboard.Module {
+ scopedProviderSettings := factory.NewScopedProviderSettings(settings, "github.com/SigNoz/signoz/ee/modules/dashboard/impldashboard")
+ pkgDashboardModule := pkgimpldashboard.NewModule(store, settings, analytics, orgGetter, queryParser)
+
+ return &module{
+ pkgDashboardModule: pkgDashboardModule,
+ store: store,
+ settings: scopedProviderSettings,
+ role: role,
+ querier: querier,
+ licensing: licensing,
+ }
+}
+
+func (module *module) CreatePublic(ctx context.Context, orgID valuer.UUID, publicDashboard *dashboardtypes.PublicDashboard) error {
+ _, err := module.licensing.GetActive(ctx, orgID)
+ if err != nil {
+ return errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error())
+ }
+
+ storablePublicDashboard, err := module.store.GetPublic(ctx, publicDashboard.DashboardID.StringValue())
+ if err != nil && !errors.Ast(err, errors.TypeNotFound) {
+ return err
+ }
+ if storablePublicDashboard != nil {
+ return errors.Newf(errors.TypeAlreadyExists, dashboardtypes.ErrCodePublicDashboardAlreadyExists, "dashboard with id %s is already public", storablePublicDashboard.DashboardID)
+ }
+
+ role, err := module.role.GetOrCreate(ctx, roletypes.NewRole(roletypes.AnonymousUserRoleName, roletypes.AnonymousUserRoleDescription, roletypes.RoleTypeManaged.StringValue(), orgID))
+ if err != nil {
+ return err
+ }
+
+ err = module.role.Assign(ctx, role.ID, orgID, authtypes.MustNewSubject(authtypes.TypeableAnonymous, authtypes.AnonymousUser.StringValue(), orgID, nil))
+ if err != nil {
+ return err
+ }
+
+ additionObject := authtypes.MustNewObject(
+ authtypes.Resource{
+ Name: dashboardtypes.TypeableMetaResourcePublicDashboard.Name(),
+ Type: authtypes.TypeMetaResource,
+ },
+ authtypes.MustNewSelector(authtypes.TypeMetaResource, publicDashboard.ID.String()),
+ )
+
+ err = module.role.PatchObjects(ctx, orgID, role.ID, authtypes.RelationRead, []*authtypes.Object{additionObject}, nil)
+ if err != nil {
+ return err
+ }
+
+ err = module.store.CreatePublic(ctx, dashboardtypes.NewStorablePublicDashboardFromPublicDashboard(publicDashboard))
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (module *module) GetPublic(ctx context.Context, orgID valuer.UUID, dashboardID valuer.UUID) (*dashboardtypes.PublicDashboard, error) {
+ _, err := module.licensing.GetActive(ctx, orgID)
+ if err != nil {
+ return nil, errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error())
+ }
+
+ storablePublicDashboard, err := module.store.GetPublic(ctx, dashboardID.StringValue())
+ if err != nil {
+ return nil, err
+ }
+
+ return dashboardtypes.NewPublicDashboardFromStorablePublicDashboard(storablePublicDashboard), nil
+}
+
+func (module *module) GetDashboardByPublicID(ctx context.Context, id valuer.UUID) (*dashboardtypes.Dashboard, error) {
+ storableDashboard, err := module.store.GetDashboardByPublicID(ctx, id.StringValue())
+ if err != nil {
+ return nil, err
+ }
+
+ return dashboardtypes.NewDashboardFromStorableDashboard(storableDashboard), nil
+}
+
+func (module *module) GetPublicDashboardSelectorsAndOrg(ctx context.Context, id valuer.UUID, orgs []*types.Organization) ([]authtypes.Selector, valuer.UUID, error) {
+ orgIDs := make([]string, len(orgs))
+ for idx, org := range orgs {
+ orgIDs[idx] = org.ID.StringValue()
+ }
+
+ storableDashboard, err := module.store.GetDashboardByOrgsAndPublicID(ctx, orgIDs, id.StringValue())
+ if err != nil {
+ return nil, valuer.UUID{}, err
+ }
+
+ return []authtypes.Selector{
+ authtypes.MustNewSelector(authtypes.TypeMetaResource, id.StringValue()),
+ }, storableDashboard.OrgID, nil
+}
+
+func (module *module) GetPublicWidgetQueryRange(ctx context.Context, id valuer.UUID, widgetIdx, startTime, endTime uint64) (*querybuildertypesv5.QueryRangeResponse, error) {
+ dashboard, err := module.GetDashboardByPublicID(ctx, id)
+ if err != nil {
+ return nil, err
+ }
+
+ query, err := dashboard.GetWidgetQuery(startTime, endTime, widgetIdx, module.settings.Logger())
+ if err != nil {
+ return nil, err
+ }
+
+ return module.querier.QueryRange(ctx, dashboard.OrgID, query)
+}
+
+func (module *module) UpdatePublic(ctx context.Context, orgID valuer.UUID, publicDashboard *dashboardtypes.PublicDashboard) error {
+ _, err := module.licensing.GetActive(ctx, orgID)
+ if err != nil {
+ return errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error())
+ }
+
+ return module.store.UpdatePublic(ctx, dashboardtypes.NewStorablePublicDashboardFromPublicDashboard(publicDashboard))
+}
+
+func (module *module) Delete(ctx context.Context, orgID valuer.UUID, id valuer.UUID) error {
+ dashboard, err := module.Get(ctx, orgID, id)
+ if err != nil {
+ return err
+ }
+
+ if dashboard.Locked {
+ return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "dashboard is locked, please unlock the dashboard to be delete it")
+ }
+
+ err = module.store.RunInTx(ctx, func(ctx context.Context) error {
+ err := module.DeletePublic(ctx, orgID, id)
+ if err != nil && !errors.Ast(err, errors.TypeNotFound) {
+ return err
+ }
+
+ err = module.store.Delete(ctx, orgID, id)
+ if err != nil {
+ return err
+ }
+
+ return nil
+ })
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (module *module) DeletePublic(ctx context.Context, orgID valuer.UUID, dashboardID valuer.UUID) error {
+ _, err := module.licensing.GetActive(ctx, orgID)
+ if err != nil {
+ return errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error())
+ }
+
+ publicDashboard, err := module.GetPublic(ctx, orgID, dashboardID)
+ if err != nil {
+ return err
+ }
+
+ role, err := module.role.GetOrCreate(ctx, roletypes.NewRole(roletypes.AnonymousUserRoleName, roletypes.AnonymousUserRoleDescription, roletypes.RoleTypeManaged.StringValue(), orgID))
+ if err != nil {
+ return err
+ }
+
+ deletionObject := authtypes.MustNewObject(
+ authtypes.Resource{
+ Name: dashboardtypes.TypeableMetaResourcePublicDashboard.Name(),
+ Type: authtypes.TypeMetaResource,
+ },
+ authtypes.MustNewSelector(authtypes.TypeMetaResource, publicDashboard.ID.String()),
+ )
+
+ err = module.role.PatchObjects(ctx, orgID, role.ID, authtypes.RelationRead, nil, []*authtypes.Object{deletionObject})
+ if err != nil {
+ return err
+ }
+
+ err = module.store.DeletePublic(ctx, dashboardID.StringValue())
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (module *module) Collect(ctx context.Context, orgID valuer.UUID) (map[string]any, error) {
+ dashboards, err := module.store.List(ctx, orgID)
+ if err != nil {
+ return nil, err
+ }
+
+ publicDashboards, err := module.store.ListPublic(ctx, orgID)
+ if err != nil {
+ return nil, err
+ }
+
+ stats := make(map[string]any)
+ maps.Copy(stats, dashboardtypes.NewStatsFromStorableDashboards(dashboards))
+ maps.Copy(stats, dashboardtypes.NewStatsFromStorablePublicDashboards(publicDashboards))
+ return stats, nil
+}
+
+func (module *module) Create(ctx context.Context, orgID valuer.UUID, createdBy string, creator valuer.UUID, data dashboardtypes.PostableDashboard) (*dashboardtypes.Dashboard, error) {
+ return module.pkgDashboardModule.Create(ctx, orgID, createdBy, creator, data)
+}
+
+func (module *module) Get(ctx context.Context, orgID valuer.UUID, id valuer.UUID) (*dashboardtypes.Dashboard, error) {
+ return module.pkgDashboardModule.Get(ctx, orgID, id)
+}
+
+func (module *module) GetByMetricNames(ctx context.Context, orgID valuer.UUID, metricNames []string) (map[string][]map[string]string, error) {
+ return module.pkgDashboardModule.GetByMetricNames(ctx, orgID, metricNames)
+}
+
+func (module *module) MustGetTypeables() []authtypes.Typeable {
+ return module.pkgDashboardModule.MustGetTypeables()
+}
+
+func (module *module) List(ctx context.Context, orgID valuer.UUID) ([]*dashboardtypes.Dashboard, error) {
+ return module.pkgDashboardModule.List(ctx, orgID)
+}
+
+func (module *module) Update(ctx context.Context, orgID valuer.UUID, id valuer.UUID, updatedBy string, data dashboardtypes.UpdatableDashboard, diff int) (*dashboardtypes.Dashboard, error) {
+ return module.pkgDashboardModule.Update(ctx, orgID, id, updatedBy, data, diff)
+}
+
+func (module *module) LockUnlock(ctx context.Context, orgID valuer.UUID, id valuer.UUID, updatedBy string, role types.Role, lock bool) error {
+ return module.pkgDashboardModule.LockUnlock(ctx, orgID, id, updatedBy, role, lock)
+}
diff --git a/ee/query-service/app/api/api.go b/ee/query-service/app/api/api.go
index c99a4998b9..7addedab4b 100644
--- a/ee/query-service/app/api/api.go
+++ b/ee/query-service/app/api/api.go
@@ -21,10 +21,6 @@ import (
rules "github.com/SigNoz/signoz/pkg/query-service/rules"
"github.com/SigNoz/signoz/pkg/queryparser"
"github.com/SigNoz/signoz/pkg/signoz"
- "github.com/SigNoz/signoz/pkg/types"
- "github.com/SigNoz/signoz/pkg/types/authtypes"
- "github.com/SigNoz/signoz/pkg/types/dashboardtypes"
- "github.com/SigNoz/signoz/pkg/valuer"
"github.com/SigNoz/signoz/pkg/version"
"github.com/gorilla/mux"
)
@@ -101,39 +97,6 @@ func (ah *APIHandler) RegisterRoutes(router *mux.Router, am *middleware.AuthZ) {
router.HandleFunc("/api/v1/billing", am.AdminAccess(ah.getBilling)).Methods(http.MethodGet)
router.HandleFunc("/api/v1/portal", am.AdminAccess(ah.LicensingAPI.Portal)).Methods(http.MethodPost)
- // dashboards
- router.HandleFunc("/api/v1/dashboards/{id}/public", am.AdminAccess(ah.Signoz.Handlers.Dashboard.CreatePublic)).Methods(http.MethodPost)
- router.HandleFunc("/api/v1/dashboards/{id}/public", am.AdminAccess(ah.Signoz.Handlers.Dashboard.GetPublic)).Methods(http.MethodGet)
- router.HandleFunc("/api/v1/dashboards/{id}/public", am.AdminAccess(ah.Signoz.Handlers.Dashboard.UpdatePublic)).Methods(http.MethodPut)
- router.HandleFunc("/api/v1/dashboards/{id}/public", am.AdminAccess(ah.Signoz.Handlers.Dashboard.DeletePublic)).Methods(http.MethodDelete)
-
- // public access for dashboards
- router.HandleFunc("/api/v1/public/dashboards/{id}", am.CheckWithoutClaims(
- ah.Signoz.Handlers.Dashboard.GetPublicData,
- authtypes.RelationRead, authtypes.RelationRead,
- dashboardtypes.TypeableMetaResourcePublicDashboard,
- func(req *http.Request, orgs []*types.Organization) ([]authtypes.Selector, valuer.UUID, error) {
- id, err := valuer.NewUUID(mux.Vars(req)["id"])
- if err != nil {
- return nil, valuer.UUID{}, err
- }
-
- return ah.Signoz.Modules.Dashboard.GetPublicDashboardOrgAndSelectors(req.Context(), id, orgs)
- })).Methods(http.MethodGet)
-
- router.HandleFunc("/api/v1/public/dashboards/{id}/widgets/{index}/query_range", am.CheckWithoutClaims(
- ah.Signoz.Handlers.Dashboard.GetPublicWidgetQueryRange,
- authtypes.RelationRead, authtypes.RelationRead,
- dashboardtypes.TypeableMetaResourcePublicDashboard,
- func(req *http.Request, orgs []*types.Organization) ([]authtypes.Selector, valuer.UUID, error) {
- id, err := valuer.NewUUID(mux.Vars(req)["id"])
- if err != nil {
- return nil, valuer.UUID{}, err
- }
-
- return ah.Signoz.Modules.Dashboard.GetPublicDashboardOrgAndSelectors(req.Context(), id, orgs)
- })).Methods(http.MethodGet)
-
// v3
router.HandleFunc("/api/v3/licenses", am.AdminAccess(ah.LicensingAPI.Activate)).Methods(http.MethodPost)
router.HandleFunc("/api/v3/licenses", am.AdminAccess(ah.LicensingAPI.Refresh)).Methods(http.MethodPut)
diff --git a/pkg/apiserver/signozapiserver/dashboard.go b/pkg/apiserver/signozapiserver/dashboard.go
new file mode 100644
index 0000000000..4fecb76a99
--- /dev/null
+++ b/pkg/apiserver/signozapiserver/dashboard.go
@@ -0,0 +1,141 @@
+package signozapiserver
+
+import (
+ "net/http"
+
+ "github.com/SigNoz/signoz/pkg/http/handler"
+ "github.com/SigNoz/signoz/pkg/types"
+ "github.com/SigNoz/signoz/pkg/types/authtypes"
+ "github.com/SigNoz/signoz/pkg/types/dashboardtypes"
+ "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5"
+ "github.com/SigNoz/signoz/pkg/valuer"
+ "github.com/gorilla/mux"
+)
+
+func (provider *provider) addDashboardRoutes(router *mux.Router) error {
+ if err := router.Handle("/api/v1/dashboards/{id}/public", handler.New(provider.authZ.AdminAccess(provider.dashboardHandler.CreatePublic), handler.OpenAPIDef{
+ ID: "CreatePublicDashboard",
+ Tags: []string{"dashboard"},
+ Summary: "Create public dashboard",
+ Description: "This endpoints creates public sharing config and enables public sharing of the dashboard",
+ Request: new(dashboardtypes.PostablePublicDashboard),
+ RequestContentType: "",
+ Response: new(types.Identifiable),
+ ResponseContentType: "application/json",
+ SuccessStatusCode: http.StatusCreated,
+ ErrorStatusCodes: []int{},
+ Deprecated: false,
+ SecuritySchemes: newSecuritySchemes(types.RoleAdmin),
+ })).Methods(http.MethodPost).GetError(); err != nil {
+ return err
+ }
+
+ if err := router.Handle("/api/v1/dashboards/{id}/public", handler.New(provider.authZ.AdminAccess(provider.dashboardHandler.GetPublic), handler.OpenAPIDef{
+ ID: "GetPublicDashboard",
+ Tags: []string{"dashboard"},
+ Summary: "Get public dashboard",
+ Description: "This endpoints returns public sharing config for a dashboard",
+ Request: nil,
+ RequestContentType: "",
+ Response: new(dashboardtypes.GettablePublicDasbhboard),
+ ResponseContentType: "application/json",
+ SuccessStatusCode: http.StatusOK,
+ ErrorStatusCodes: []int{},
+ Deprecated: false,
+ SecuritySchemes: newSecuritySchemes(types.RoleAdmin),
+ })).Methods(http.MethodGet).GetError(); err != nil {
+ return err
+ }
+
+ if err := router.Handle("/api/v1/dashboards/{id}/public", handler.New(provider.authZ.AdminAccess(provider.dashboardHandler.UpdatePublic), handler.OpenAPIDef{
+ ID: "UpdatePublicDashboard",
+ Tags: []string{"dashboard"},
+ Summary: "Update public dashboard",
+ Description: "This endpoints updates the public sharing config for a dashboard",
+ Request: new(dashboardtypes.UpdatablePublicDashboard),
+ RequestContentType: "",
+ Response: nil,
+ ResponseContentType: "application/json",
+ SuccessStatusCode: http.StatusNoContent,
+ ErrorStatusCodes: []int{},
+ Deprecated: false,
+ SecuritySchemes: newSecuritySchemes(types.RoleAdmin),
+ })).Methods(http.MethodPut).GetError(); err != nil {
+ return err
+ }
+
+ if err := router.Handle("/api/v1/dashboards/{id}/public", handler.New(provider.authZ.AdminAccess(provider.dashboardHandler.DeletePublic), handler.OpenAPIDef{
+ ID: "DeletePublicDashboard",
+ Tags: []string{"dashboard"},
+ Summary: "Delete public dashboard",
+ Description: "This endpoints deletes the public sharing config and disables the public sharing of a dashboard",
+ Request: nil,
+ RequestContentType: "",
+ Response: nil,
+ ResponseContentType: "application/json",
+ SuccessStatusCode: http.StatusNoContent,
+ ErrorStatusCodes: []int{},
+ Deprecated: false,
+ SecuritySchemes: newSecuritySchemes(types.RoleAdmin),
+ })).Methods(http.MethodDelete).GetError(); err != nil {
+ return err
+ }
+
+ if err := router.Handle("/api/v1/public/dashboards/{id}", handler.New(provider.authZ.CheckWithoutClaims(
+ provider.dashboardHandler.GetPublicData,
+ authtypes.RelationRead, authtypes.RelationRead,
+ dashboardtypes.TypeableMetaResourcePublicDashboard,
+ func(req *http.Request, orgs []*types.Organization) ([]authtypes.Selector, valuer.UUID, error) {
+ id, err := valuer.NewUUID(mux.Vars(req)["id"])
+ if err != nil {
+ return nil, valuer.UUID{}, err
+ }
+
+ return provider.dashboardModule.GetPublicDashboardSelectorsAndOrg(req.Context(), id, orgs)
+ }), handler.OpenAPIDef{
+ ID: "GetPublicDashboardData",
+ Tags: []string{"dashboard"},
+ Summary: "Get public dashboard data",
+ Description: "This endpoints returns the sanitized dashboard data for public access",
+ Request: nil,
+ RequestContentType: "",
+ Response: new(dashboardtypes.GettablePublicDashboardData),
+ ResponseContentType: "application/json",
+ SuccessStatusCode: http.StatusOK,
+ ErrorStatusCodes: []int{},
+ Deprecated: false,
+ SecuritySchemes: newAnonymousSecuritySchemes([]string{dashboardtypes.TypeableMetaResourcePublicDashboard.Scope(authtypes.RelationRead)}),
+ })).Methods(http.MethodGet).GetError(); err != nil {
+ return err
+ }
+
+ if err := router.Handle("/api/v1/public/dashboards/{id}/widgets/{idx}/query_range", handler.New(provider.authZ.CheckWithoutClaims(
+ provider.dashboardHandler.GetPublicWidgetQueryRange,
+ authtypes.RelationRead, authtypes.RelationRead,
+ dashboardtypes.TypeableMetaResourcePublicDashboard,
+ func(req *http.Request, orgs []*types.Organization) ([]authtypes.Selector, valuer.UUID, error) {
+ id, err := valuer.NewUUID(mux.Vars(req)["id"])
+ if err != nil {
+ return nil, valuer.UUID{}, err
+ }
+
+ return provider.dashboardModule.GetPublicDashboardSelectorsAndOrg(req.Context(), id, orgs)
+ }), handler.OpenAPIDef{
+ ID: "GetPublicDashboardWidgetQueryRange",
+ Tags: []string{"dashboard"},
+ Summary: "Get query range result",
+ Description: "This endpoint return query range results for a widget of public dashboard",
+ Request: nil,
+ RequestContentType: "",
+ Response: new(querybuildertypesv5.QueryRangeResponse),
+ ResponseContentType: "application/json",
+ SuccessStatusCode: http.StatusOK,
+ ErrorStatusCodes: []int{},
+ Deprecated: false,
+ SecuritySchemes: newAnonymousSecuritySchemes([]string{dashboardtypes.TypeableMetaResourcePublicDashboard.Scope(authtypes.RelationRead)}),
+ })).Methods(http.MethodGet).GetError(); err != nil {
+ return err
+ }
+
+ return nil
+}
diff --git a/pkg/apiserver/signozapiserver/provider.go b/pkg/apiserver/signozapiserver/provider.go
index 3efbf694b5..8396a90262 100644
--- a/pkg/apiserver/signozapiserver/provider.go
+++ b/pkg/apiserver/signozapiserver/provider.go
@@ -11,6 +11,7 @@ import (
"github.com/SigNoz/signoz/pkg/http/handler"
"github.com/SigNoz/signoz/pkg/http/middleware"
"github.com/SigNoz/signoz/pkg/modules/authdomain"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard"
"github.com/SigNoz/signoz/pkg/modules/organization"
"github.com/SigNoz/signoz/pkg/modules/preference"
"github.com/SigNoz/signoz/pkg/modules/promote"
@@ -34,6 +35,8 @@ type provider struct {
globalHandler global.Handler
promoteHandler promote.Handler
flaggerHandler flagger.Handler
+ dashboardModule dashboard.Module
+ dashboardHandler dashboard.Handler
}
func NewFactory(
@@ -47,9 +50,11 @@ func NewFactory(
globalHandler global.Handler,
promoteHandler promote.Handler,
flaggerHandler flagger.Handler,
+ dashboardModule dashboard.Module,
+ dashboardHandler dashboard.Handler,
) factory.ProviderFactory[apiserver.APIServer, apiserver.Config] {
return factory.NewProviderFactory(factory.MustNewName("signoz"), func(ctx context.Context, providerSettings factory.ProviderSettings, config apiserver.Config) (apiserver.APIServer, error) {
- return newProvider(ctx, providerSettings, config, orgGetter, authz, orgHandler, userHandler, sessionHandler, authDomainHandler, preferenceHandler, globalHandler, promoteHandler, flaggerHandler)
+ return newProvider(ctx, providerSettings, config, orgGetter, authz, orgHandler, userHandler, sessionHandler, authDomainHandler, preferenceHandler, globalHandler, promoteHandler, flaggerHandler, dashboardModule, dashboardHandler)
})
}
@@ -67,6 +72,8 @@ func newProvider(
globalHandler global.Handler,
promoteHandler promote.Handler,
flaggerHandler flagger.Handler,
+ dashboardModule dashboard.Module,
+ dashboardHandler dashboard.Handler,
) (apiserver.APIServer, error) {
settings := factory.NewScopedProviderSettings(providerSettings, "github.com/SigNoz/signoz/pkg/apiserver/signozapiserver")
router := mux.NewRouter().UseEncodedPath()
@@ -83,6 +90,8 @@ func newProvider(
globalHandler: globalHandler,
promoteHandler: promoteHandler,
flaggerHandler: flaggerHandler,
+ dashboardModule: dashboardModule,
+ dashboardHandler: dashboardHandler,
}
provider.authZ = middleware.NewAuthZ(settings.Logger(), orgGetter, authz)
@@ -131,6 +140,10 @@ func (provider *provider) AddToRouter(router *mux.Router) error {
return err
}
+ if err := provider.addDashboardRoutes(router); err != nil {
+ return err
+ }
+
return nil
}
@@ -140,3 +153,9 @@ func newSecuritySchemes(role types.Role) []handler.OpenAPISecurityScheme {
{Name: ctxtypes.AuthTypeTokenizer.StringValue(), Scopes: []string{role.String()}},
}
}
+
+func newAnonymousSecuritySchemes(scopes []string) []handler.OpenAPISecurityScheme {
+ return []handler.OpenAPISecurityScheme{
+ {Name: ctxtypes.AuthTypeAnonymous.StringValue(), Scopes: scopes},
+ }
+}
diff --git a/pkg/modules/dashboard/dashboard.go b/pkg/modules/dashboard/dashboard.go
index 54a29af137..b7a51c3d65 100644
--- a/pkg/modules/dashboard/dashboard.go
+++ b/pkg/modules/dashboard/dashboard.go
@@ -9,26 +9,30 @@ import (
"github.com/SigNoz/signoz/pkg/types"
"github.com/SigNoz/signoz/pkg/types/authtypes"
"github.com/SigNoz/signoz/pkg/types/dashboardtypes"
+ "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5"
"github.com/SigNoz/signoz/pkg/valuer"
)
type Module interface {
- // enables public sharing for dashboard.
+ // creates public sharing config and enables public sharing for the dashboard
CreatePublic(context.Context, valuer.UUID, *dashboardtypes.PublicDashboard) error
- // gets the config for public sharing by org_id and dashboard_id.
+ // gets the public sharing config for the dashboard
GetPublic(context.Context, valuer.UUID, valuer.UUID) (*dashboardtypes.PublicDashboard, error)
// get the dashboard data by public dashboard id
GetDashboardByPublicID(context.Context, valuer.UUID) (*dashboardtypes.Dashboard, error)
- // gets the org for the given public dashboard
- GetPublicDashboardOrgAndSelectors(ctx context.Context, id valuer.UUID, orgs []*types.Organization) ([]authtypes.Selector, valuer.UUID, error)
+ // gets the query results by widget index and public shared id for a dashboard
+ GetPublicWidgetQueryRange(context.Context, valuer.UUID, uint64, uint64, uint64) (*querybuildertypesv5.QueryRangeResponse, error)
- // updates the config for public sharing.
- UpdatePublic(context.Context, *dashboardtypes.PublicDashboard) error
+ // gets the selectors and org for the given public dashboard
+ GetPublicDashboardSelectorsAndOrg(context.Context, valuer.UUID, []*types.Organization) ([]authtypes.Selector, valuer.UUID, error)
- // disables the public sharing for the dashboard.
+ // updates the public sharing config for a dashboard
+ UpdatePublic(context.Context, valuer.UUID, *dashboardtypes.PublicDashboard) error
+
+ // deletes the public sharing config and disables public sharing for the dashboard
DeletePublic(context.Context, valuer.UUID, valuer.UUID) error
Create(ctx context.Context, orgID valuer.UUID, createdBy string, creator valuer.UUID, data dashboardtypes.PostableDashboard) (*dashboardtypes.Dashboard, error)
diff --git a/pkg/modules/dashboard/impldashboard/handler.go b/pkg/modules/dashboard/impldashboard/handler.go
index ff1ffa67ef..85ccd572dd 100644
--- a/pkg/modules/dashboard/impldashboard/handler.go
+++ b/pkg/modules/dashboard/impldashboard/handler.go
@@ -11,9 +11,7 @@ import (
"github.com/SigNoz/signoz/pkg/factory"
"github.com/SigNoz/signoz/pkg/http/binding"
"github.com/SigNoz/signoz/pkg/http/render"
- "github.com/SigNoz/signoz/pkg/licensing"
"github.com/SigNoz/signoz/pkg/modules/dashboard"
- "github.com/SigNoz/signoz/pkg/querier"
"github.com/SigNoz/signoz/pkg/transition"
"github.com/SigNoz/signoz/pkg/types"
"github.com/SigNoz/signoz/pkg/types/authtypes"
@@ -26,12 +24,10 @@ import (
type handler struct {
module dashboard.Module
providerSettings factory.ProviderSettings
- querier querier.Querier
- licensing licensing.Licensing
}
-func NewHandler(module dashboard.Module, providerSettings factory.ProviderSettings, querier querier.Querier, licensing licensing.Licensing) dashboard.Handler {
- return &handler{module: module, providerSettings: providerSettings, querier: querier, licensing: licensing}
+func NewHandler(module dashboard.Module, providerSettings factory.ProviderSettings) dashboard.Handler {
+ return &handler{module: module, providerSettings: providerSettings}
}
func (handler *handler) Create(rw http.ResponseWriter, r *http.Request) {
@@ -214,12 +210,6 @@ func (handler *handler) CreatePublic(rw http.ResponseWriter, r *http.Request) {
return
}
- _, err = handler.licensing.GetActive(ctx, valuer.MustNewUUID(claims.OrgID))
- if err != nil {
- render.Error(rw, errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error()))
- return
- }
-
id, err := valuer.NewUUID(mux.Vars(r)["id"])
if err != nil {
render.Error(rw, err)
@@ -258,12 +248,6 @@ func (handler *handler) GetPublic(rw http.ResponseWriter, r *http.Request) {
return
}
- _, err = handler.licensing.GetActive(ctx, valuer.MustNewUUID(claims.OrgID))
- if err != nil {
- render.Error(rw, errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error()))
- return
- }
-
id, err := valuer.NewUUID(mux.Vars(r)["id"])
if err != nil {
render.Error(rw, err)
@@ -326,7 +310,7 @@ func (handler *handler) GetPublicWidgetQueryRange(rw http.ResponseWriter, r *htt
return
}
- widgetIndex, ok := mux.Vars(r)["index"]
+ widgetIndex, ok := mux.Vars(r)["idx"]
if !ok {
render.Error(rw, errors.New(errors.TypeInvalidInput, dashboardtypes.ErrCodePublicDashboardInvalidInput, "widget index is missing from the path"))
return
@@ -344,7 +328,7 @@ func (handler *handler) GetPublicWidgetQueryRange(rw http.ResponseWriter, r *htt
return
}
- widgetIdxInt, err := strconv.ParseInt(widgetIndex, 10, 64)
+ widgetIdx, err := strconv.ParseUint(widgetIndex, 10, 64)
if err != nil {
render.Error(rw, errors.New(errors.TypeInvalidInput, dashboardtypes.ErrCodePublicDashboardInvalidInput, "invalid widget index"))
return
@@ -377,13 +361,7 @@ func (handler *handler) GetPublicWidgetQueryRange(rw http.ResponseWriter, r *htt
endTime = uint64(time.Now().UnixMilli())
}
- query, err := dashboard.GetWidgetQuery(startTime, endTime, widgetIdxInt, handler.providerSettings.Logger)
- if err != nil {
- render.Error(rw, err)
- return
- }
-
- queryRangeResults, err := handler.querier.QueryRange(ctx, dashboard.OrgID, query)
+ queryRangeResults, err := handler.module.GetPublicWidgetQueryRange(ctx, id, widgetIdx, startTime, endTime)
if err != nil {
render.Error(rw, err)
return
@@ -402,12 +380,6 @@ func (handler *handler) UpdatePublic(rw http.ResponseWriter, r *http.Request) {
return
}
- _, err = handler.licensing.GetActive(ctx, valuer.MustNewUUID(claims.OrgID))
- if err != nil {
- render.Error(rw, errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error()))
- return
- }
-
id, err := valuer.NewUUID(mux.Vars(r)["id"])
if err != nil {
render.Error(rw, err)
@@ -433,7 +405,7 @@ func (handler *handler) UpdatePublic(rw http.ResponseWriter, r *http.Request) {
}
publicDashboard.Update(req.TimeRangeEnabled, req.DefaultTimeRange)
- err = handler.module.UpdatePublic(ctx, publicDashboard)
+ err = handler.module.UpdatePublic(ctx, valuer.MustNewUUID(claims.OrgID), publicDashboard)
if err != nil {
render.Error(rw, err)
return
@@ -452,12 +424,6 @@ func (handler *handler) DeletePublic(rw http.ResponseWriter, r *http.Request) {
return
}
- _, err = handler.licensing.GetActive(ctx, valuer.MustNewUUID(claims.OrgID))
- if err != nil {
- render.Error(rw, errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error()))
- return
- }
-
id, err := valuer.NewUUID(mux.Vars(r)["id"])
if err != nil {
render.Error(rw, err)
diff --git a/pkg/modules/dashboard/impldashboard/module.go b/pkg/modules/dashboard/impldashboard/module.go
index b5d8ad0a8c..2c7a92e83d 100644
--- a/pkg/modules/dashboard/impldashboard/module.go
+++ b/pkg/modules/dashboard/impldashboard/module.go
@@ -2,7 +2,6 @@ package impldashboard
import (
"context"
- "maps"
"slices"
"github.com/SigNoz/signoz/pkg/analytics"
@@ -10,14 +9,12 @@ import (
"github.com/SigNoz/signoz/pkg/factory"
"github.com/SigNoz/signoz/pkg/modules/dashboard"
"github.com/SigNoz/signoz/pkg/modules/organization"
- "github.com/SigNoz/signoz/pkg/modules/role"
"github.com/SigNoz/signoz/pkg/queryparser"
- "github.com/SigNoz/signoz/pkg/sqlstore"
"github.com/SigNoz/signoz/pkg/types"
"github.com/SigNoz/signoz/pkg/types/authtypes"
"github.com/SigNoz/signoz/pkg/types/dashboardtypes"
+ "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5"
qbtypes "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5"
- "github.com/SigNoz/signoz/pkg/types/roletypes"
"github.com/SigNoz/signoz/pkg/valuer"
)
@@ -26,18 +23,16 @@ type module struct {
settings factory.ScopedProviderSettings
analytics analytics.Analytics
orgGetter organization.Getter
- role role.Module
queryParser queryparser.QueryParser
}
-func NewModule(sqlstore sqlstore.SQLStore, settings factory.ProviderSettings, analytics analytics.Analytics, orgGetter organization.Getter, role role.Module, queryParser queryparser.QueryParser) dashboard.Module {
- scopedProviderSettings := factory.NewScopedProviderSettings(settings, "github.com/SigNoz/signoz/pkg/modules/impldashboard")
+func NewModule(store dashboardtypes.Store, settings factory.ProviderSettings, analytics analytics.Analytics, orgGetter organization.Getter, queryParser queryparser.QueryParser) dashboard.Module {
+ scopedProviderSettings := factory.NewScopedProviderSettings(settings, "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard")
return &module{
- store: NewStore(sqlstore),
+ store: store,
settings: scopedProviderSettings,
analytics: analytics,
orgGetter: orgGetter,
- role: role,
queryParser: queryParser,
}
}
@@ -62,46 +57,6 @@ func (module *module) Create(ctx context.Context, orgID valuer.UUID, createdBy s
return dashboard, nil
}
-func (module *module) CreatePublic(ctx context.Context, orgID valuer.UUID, publicDashboard *dashboardtypes.PublicDashboard) error {
- storablePublicDashboard, err := module.store.GetPublic(ctx, publicDashboard.DashboardID.StringValue())
- if err != nil && !errors.Ast(err, errors.TypeNotFound) {
- return err
- }
- if storablePublicDashboard != nil {
- return errors.Newf(errors.TypeAlreadyExists, dashboardtypes.ErrCodePublicDashboardAlreadyExists, "dashboard with id %s is already public", storablePublicDashboard.DashboardID)
- }
-
- role, err := module.role.GetOrCreate(ctx, roletypes.NewRole(roletypes.AnonymousUserRoleName, roletypes.AnonymousUserRoleDescription, roletypes.RoleTypeManaged.StringValue(), orgID))
- if err != nil {
- return err
- }
-
- err = module.role.Assign(ctx, role.ID, orgID, authtypes.MustNewSubject(authtypes.TypeableAnonymous, authtypes.AnonymousUser.StringValue(), orgID, nil))
- if err != nil {
- return err
- }
-
- additionObject := authtypes.MustNewObject(
- authtypes.Resource{
- Name: dashboardtypes.TypeableMetaResourcePublicDashboard.Name(),
- Type: authtypes.TypeMetaResource,
- },
- authtypes.MustNewSelector(authtypes.TypeMetaResource, publicDashboard.ID.String()),
- )
-
- err = module.role.PatchObjects(ctx, orgID, role.ID, authtypes.RelationRead, []*authtypes.Object{additionObject}, nil)
- if err != nil {
- return err
- }
-
- err = module.store.CreatePublic(ctx, dashboardtypes.NewStorablePublicDashboardFromPublicDashboard(publicDashboard))
- if err != nil {
- return err
- }
-
- return nil
-}
-
func (module *module) Get(ctx context.Context, orgID valuer.UUID, id valuer.UUID) (*dashboardtypes.Dashboard, error) {
storableDashboard, err := module.store.Get(ctx, orgID, id)
if err != nil {
@@ -111,40 +66,6 @@ func (module *module) Get(ctx context.Context, orgID valuer.UUID, id valuer.UUID
return dashboardtypes.NewDashboardFromStorableDashboard(storableDashboard), nil
}
-func (module *module) GetPublic(ctx context.Context, orgID valuer.UUID, dashboardID valuer.UUID) (*dashboardtypes.PublicDashboard, error) {
- storablePublicDashboard, err := module.store.GetPublic(ctx, dashboardID.StringValue())
- if err != nil {
- return nil, err
- }
-
- return dashboardtypes.NewPublicDashboardFromStorablePublicDashboard(storablePublicDashboard), nil
-}
-
-func (module *module) GetDashboardByPublicID(ctx context.Context, id valuer.UUID) (*dashboardtypes.Dashboard, error) {
- storableDashboard, err := module.store.GetDashboardByPublicID(ctx, id.StringValue())
- if err != nil {
- return nil, err
- }
-
- return dashboardtypes.NewDashboardFromStorableDashboard(storableDashboard), nil
-}
-
-func (module *module) GetPublicDashboardOrgAndSelectors(ctx context.Context, id valuer.UUID, orgs []*types.Organization) ([]authtypes.Selector, valuer.UUID, error) {
- orgIDs := make([]string, len(orgs))
- for idx, org := range orgs {
- orgIDs[idx] = org.ID.StringValue()
- }
-
- storableDashboard, err := module.store.GetDashboardByOrgsAndPublicID(ctx, orgIDs, id.StringValue())
- if err != nil {
- return nil, valuer.UUID{}, err
- }
-
- return []authtypes.Selector{
- authtypes.MustNewSelector(authtypes.TypeMetaResource, id.StringValue()),
- }, storableDashboard.OrgID, nil
-}
-
func (module *module) List(ctx context.Context, orgID valuer.UUID) ([]*dashboardtypes.Dashboard, error) {
storableDashboards, err := module.store.List(ctx, orgID)
if err != nil {
@@ -178,10 +99,6 @@ func (module *module) Update(ctx context.Context, orgID valuer.UUID, id valuer.U
return dashboard, nil
}
-func (module *module) UpdatePublic(ctx context.Context, publicDashboard *dashboardtypes.PublicDashboard) error {
- return module.store.UpdatePublic(ctx, dashboardtypes.NewStorablePublicDashboardFromPublicDashboard(publicDashboard))
-}
-
func (module *module) LockUnlock(ctx context.Context, orgID valuer.UUID, id valuer.UUID, updatedBy string, role types.Role, lock bool) error {
dashboard, err := module.Get(ctx, orgID, id)
if err != nil {
@@ -215,51 +132,7 @@ func (module *module) Delete(ctx context.Context, orgID valuer.UUID, id valuer.U
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "dashboard is locked, please unlock the dashboard to be delete it")
}
- err = module.store.RunInTx(ctx, func(ctx context.Context) error {
- err := module.DeletePublic(ctx, orgID, id)
- if err != nil && !errors.Ast(err, errors.TypeNotFound) {
- return err
- }
-
- err = module.store.Delete(ctx, orgID, id)
- if err != nil {
- return err
- }
-
- return nil
- })
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func (module *module) DeletePublic(ctx context.Context, orgID valuer.UUID, dashboardID valuer.UUID) error {
- publicDashboard, err := module.GetPublic(ctx, orgID, dashboardID)
- if err != nil {
- return err
- }
-
- role, err := module.role.GetOrCreate(ctx, roletypes.NewRole(roletypes.AnonymousUserRoleName, roletypes.AnonymousUserRoleDescription, roletypes.RoleTypeManaged.StringValue(), orgID))
- if err != nil {
- return err
- }
-
- deletionObject := authtypes.MustNewObject(
- authtypes.Resource{
- Name: dashboardtypes.TypeableMetaResourcePublicDashboard.Name(),
- Type: authtypes.TypeMetaResource,
- },
- authtypes.MustNewSelector(authtypes.TypeMetaResource, publicDashboard.ID.String()),
- )
-
- err = module.role.PatchObjects(ctx, orgID, role.ID, authtypes.RelationRead, nil, []*authtypes.Object{deletionObject})
- if err != nil {
- return err
- }
-
- err = module.store.DeletePublic(ctx, dashboardID.StringValue())
+ err = module.store.Delete(ctx, orgID, id)
if err != nil {
return err
}
@@ -326,21 +199,42 @@ func (module *module) Collect(ctx context.Context, orgID valuer.UUID) (map[strin
return nil, err
}
- publicDashboards, err := module.store.ListPublic(ctx, orgID)
- if err != nil {
- return nil, err
- }
-
- stats := make(map[string]any)
- maps.Copy(stats, dashboardtypes.NewStatsFromStorableDashboards(dashboards))
- maps.Copy(stats, dashboardtypes.NewStatsFromStorablePublicDashboards(publicDashboards))
- return stats, nil
+ return dashboardtypes.NewStatsFromStorableDashboards(dashboards), nil
}
func (module *module) MustGetTypeables() []authtypes.Typeable {
return []authtypes.Typeable{dashboardtypes.TypeableMetaResourceDashboard, dashboardtypes.TypeableMetaResourcesDashboards}
}
+// not supported
+func (module *module) CreatePublic(ctx context.Context, orgID valuer.UUID, publicDashboard *dashboardtypes.PublicDashboard) error {
+ return errors.Newf(errors.TypeUnsupported, dashboardtypes.ErrCodePublicDashboardUnsupported, "not implemented")
+}
+
+func (module *module) GetPublic(_ context.Context, _, _ valuer.UUID) (*dashboardtypes.PublicDashboard, error) {
+ return nil, errors.Newf(errors.TypeUnsupported, dashboardtypes.ErrCodePublicDashboardUnsupported, "not implemented")
+}
+
+func (module *module) GetDashboardByPublicID(_ context.Context, _ valuer.UUID) (*dashboardtypes.Dashboard, error) {
+ return nil, errors.Newf(errors.TypeUnsupported, dashboardtypes.ErrCodePublicDashboardUnsupported, "not implemented")
+}
+
+func (module *module) GetPublicWidgetQueryRange(context.Context, valuer.UUID, uint64, uint64, uint64) (*querybuildertypesv5.QueryRangeResponse, error) {
+ return nil, errors.Newf(errors.TypeUnsupported, dashboardtypes.ErrCodePublicDashboardUnsupported, "not implemented")
+}
+
+func (module *module) GetPublicDashboardSelectorsAndOrg(_ context.Context, _ valuer.UUID, _ []*types.Organization) ([]authtypes.Selector, valuer.UUID, error) {
+ return nil, valuer.UUID{}, errors.Newf(errors.TypeUnsupported, dashboardtypes.ErrCodePublicDashboardUnsupported, "not implemented")
+}
+
+func (module *module) UpdatePublic(_ context.Context, _ valuer.UUID, _ *dashboardtypes.PublicDashboard) error {
+ return errors.Newf(errors.TypeUnsupported, dashboardtypes.ErrCodePublicDashboardUnsupported, "not implemented")
+}
+
+func (module *module) DeletePublic(_ context.Context, _ valuer.UUID, _ valuer.UUID) error {
+ return errors.Newf(errors.TypeUnsupported, dashboardtypes.ErrCodePublicDashboardUnsupported, "not implemented")
+}
+
// checkBuilderQueriesForMetricNames checks builder.queryData[] for aggregations[].metricName
func (module *module) checkBuilderQueriesForMetricNames(query map[string]interface{}, metricNames []string, foundMetrics map[string]bool) {
builder, ok := query["builder"].(map[string]interface{})
diff --git a/pkg/signoz/handler.go b/pkg/signoz/handler.go
index 73305074d8..d439e6b18c 100644
--- a/pkg/signoz/handler.go
+++ b/pkg/signoz/handler.go
@@ -45,7 +45,7 @@ func NewHandlers(modules Modules, providerSettings factory.ProviderSettings, que
return Handlers{
SavedView: implsavedview.NewHandler(modules.SavedView),
Apdex: implapdex.NewHandler(modules.Apdex),
- Dashboard: impldashboard.NewHandler(modules.Dashboard, providerSettings, querier, licensing),
+ Dashboard: impldashboard.NewHandler(modules.Dashboard, providerSettings),
QuickFilter: implquickfilter.NewHandler(modules.QuickFilter),
TraceFunnel: impltracefunnel.NewHandler(modules.TraceFunnel),
RawDataExport: implrawdataexport.NewHandler(modules.RawDataExport),
diff --git a/pkg/signoz/handler_test.go b/pkg/signoz/handler_test.go
index d91fad8d94..758b7df6a8 100644
--- a/pkg/signoz/handler_test.go
+++ b/pkg/signoz/handler_test.go
@@ -11,6 +11,7 @@ import (
"github.com/SigNoz/signoz/pkg/alertmanager/signozalertmanager"
"github.com/SigNoz/signoz/pkg/emailing/emailingtest"
"github.com/SigNoz/signoz/pkg/factory/factorytest"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
"github.com/SigNoz/signoz/pkg/modules/organization/implorganization"
"github.com/SigNoz/signoz/pkg/queryparser"
"github.com/SigNoz/signoz/pkg/sharder"
@@ -38,7 +39,8 @@ func TestNewHandlers(t *testing.T) {
emailing := emailingtest.New()
queryParser := queryparser.New(providerSettings)
require.NoError(t, err)
- modules := NewModules(sqlstore, tokenizer, emailing, providerSettings, orgGetter, alertmanager, nil, nil, nil, nil, nil, nil, nil, queryParser, Config{})
+ dashboardModule := impldashboard.NewModule(impldashboard.NewStore(sqlstore), providerSettings, nil, orgGetter, queryParser)
+ modules := NewModules(sqlstore, tokenizer, emailing, providerSettings, orgGetter, alertmanager, nil, nil, nil, nil, nil, nil, nil, queryParser, Config{}, dashboardModule)
handlers := NewHandlers(modules, providerSettings, nil, nil, nil, nil)
diff --git a/pkg/signoz/module.go b/pkg/signoz/module.go
index 32c67120c1..c33205393b 100644
--- a/pkg/signoz/module.go
+++ b/pkg/signoz/module.go
@@ -13,7 +13,6 @@ import (
"github.com/SigNoz/signoz/pkg/modules/authdomain"
"github.com/SigNoz/signoz/pkg/modules/authdomain/implauthdomain"
"github.com/SigNoz/signoz/pkg/modules/dashboard"
- "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
"github.com/SigNoz/signoz/pkg/modules/metricsexplorer"
"github.com/SigNoz/signoz/pkg/modules/metricsexplorer/implmetricsexplorer"
"github.com/SigNoz/signoz/pkg/modules/organization"
@@ -26,7 +25,6 @@ import (
"github.com/SigNoz/signoz/pkg/modules/quickfilter/implquickfilter"
"github.com/SigNoz/signoz/pkg/modules/rawdataexport"
"github.com/SigNoz/signoz/pkg/modules/rawdataexport/implrawdataexport"
- "github.com/SigNoz/signoz/pkg/modules/role/implrole"
"github.com/SigNoz/signoz/pkg/modules/savedview"
"github.com/SigNoz/signoz/pkg/modules/savedview/implsavedview"
"github.com/SigNoz/signoz/pkg/modules/services"
@@ -86,13 +84,13 @@ func NewModules(
cache cache.Cache,
queryParser queryparser.QueryParser,
config Config,
+ dashboard dashboard.Module,
) Modules {
quickfilter := implquickfilter.NewModule(implquickfilter.NewStore(sqlstore))
orgSetter := implorganization.NewSetter(implorganization.NewStore(sqlstore), alertmanager, quickfilter)
user := impluser.NewModule(impluser.NewStore(sqlstore, providerSettings), tokenizer, emailing, providerSettings, orgSetter, analytics)
userGetter := impluser.NewGetter(impluser.NewStore(sqlstore, providerSettings))
ruleStore := sqlrulestore.NewRuleStore(sqlstore, queryParser, providerSettings)
- dashboard := impldashboard.NewModule(sqlstore, providerSettings, analytics, orgGetter, implrole.NewModule(implrole.NewStore(sqlstore), authz, nil), queryParser)
return Modules{
OrgGetter: orgGetter,
diff --git a/pkg/signoz/module_test.go b/pkg/signoz/module_test.go
index 515e15e67b..4da21769e4 100644
--- a/pkg/signoz/module_test.go
+++ b/pkg/signoz/module_test.go
@@ -11,6 +11,7 @@ import (
"github.com/SigNoz/signoz/pkg/alertmanager/signozalertmanager"
"github.com/SigNoz/signoz/pkg/emailing/emailingtest"
"github.com/SigNoz/signoz/pkg/factory/factorytest"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
"github.com/SigNoz/signoz/pkg/modules/organization/implorganization"
"github.com/SigNoz/signoz/pkg/queryparser"
"github.com/SigNoz/signoz/pkg/sharder"
@@ -38,7 +39,8 @@ func TestNewModules(t *testing.T) {
emailing := emailingtest.New()
queryParser := queryparser.New(providerSettings)
require.NoError(t, err)
- modules := NewModules(sqlstore, tokenizer, emailing, providerSettings, orgGetter, alertmanager, nil, nil, nil, nil, nil, nil, nil, queryParser, Config{})
+ dashboardModule := impldashboard.NewModule(impldashboard.NewStore(sqlstore), providerSettings, nil, orgGetter, queryParser)
+ modules := NewModules(sqlstore, tokenizer, emailing, providerSettings, orgGetter, alertmanager, nil, nil, nil, nil, nil, nil, nil, queryParser, Config{}, dashboardModule)
reflectVal := reflect.ValueOf(modules)
for i := 0; i < reflectVal.NumField(); i++ {
diff --git a/pkg/signoz/openapi.go b/pkg/signoz/openapi.go
index e58f1f28f0..50dbec33d9 100644
--- a/pkg/signoz/openapi.go
+++ b/pkg/signoz/openapi.go
@@ -13,6 +13,7 @@ import (
"github.com/SigNoz/signoz/pkg/http/handler"
"github.com/SigNoz/signoz/pkg/instrumentation"
"github.com/SigNoz/signoz/pkg/modules/authdomain"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard"
"github.com/SigNoz/signoz/pkg/modules/organization"
"github.com/SigNoz/signoz/pkg/modules/preference"
"github.com/SigNoz/signoz/pkg/modules/promote"
@@ -42,6 +43,8 @@ func NewOpenAPI(ctx context.Context, instrumentation instrumentation.Instrumenta
struct{ global.Handler }{},
struct{ promote.Handler }{},
struct{ flagger.Handler }{},
+ struct{ dashboard.Module }{},
+ struct{ dashboard.Handler }{},
).New(ctx, instrumentation.ToProviderSettings(), apiserver.Config{})
if err != nil {
return nil, err
diff --git a/pkg/signoz/provider.go b/pkg/signoz/provider.go
index a4a4cf2f65..b8aa5d3ea7 100644
--- a/pkg/signoz/provider.go
+++ b/pkg/signoz/provider.go
@@ -240,6 +240,8 @@ func NewAPIServerProviderFactories(orgGetter organization.Getter, authz authz.Au
signozglobal.NewHandler(global),
implpromote.NewHandler(modules.Promote),
handlers.FlaggerHandler,
+ modules.Dashboard,
+ handlers.Dashboard,
),
)
}
diff --git a/pkg/signoz/signoz.go b/pkg/signoz/signoz.go
index ab95f744ee..fcdda9a1af 100644
--- a/pkg/signoz/signoz.go
+++ b/pkg/signoz/signoz.go
@@ -17,8 +17,11 @@ import (
"github.com/SigNoz/signoz/pkg/flagger"
"github.com/SigNoz/signoz/pkg/instrumentation"
"github.com/SigNoz/signoz/pkg/licensing"
+ "github.com/SigNoz/signoz/pkg/modules/dashboard"
"github.com/SigNoz/signoz/pkg/modules/organization"
"github.com/SigNoz/signoz/pkg/modules/organization/implorganization"
+ "github.com/SigNoz/signoz/pkg/modules/role"
+ "github.com/SigNoz/signoz/pkg/modules/role/implrole"
"github.com/SigNoz/signoz/pkg/modules/user/impluser"
"github.com/SigNoz/signoz/pkg/prometheus"
"github.com/SigNoz/signoz/pkg/querier"
@@ -85,6 +88,7 @@ func New(
telemetrystoreProviderFactories factory.NamedMap[factory.ProviderFactory[telemetrystore.TelemetryStore, telemetrystore.Config]],
authNsCallback func(ctx context.Context, providerSettings factory.ProviderSettings, store authtypes.AuthNStore, licensing licensing.Licensing) (map[authtypes.AuthNProvider]authn.AuthN, error),
authzCallback func(context.Context, sqlstore.SQLStore) factory.ProviderFactory[authz.AuthZ, authz.Config],
+ dashboardModuleCallback func(sqlstore.SQLStore, factory.ProviderSettings, analytics.Analytics, organization.Getter, role.Module, queryparser.QueryParser, querier.Querier, licensing.Licensing) dashboard.Module,
) (*SigNoz, error) {
// Initialize instrumentation
instrumentation, err := instrumentation.New(ctx, config.Instrumentation, version.Info, "signoz")
@@ -373,7 +377,9 @@ func New(
}
// Initialize all modules
- modules := NewModules(sqlstore, tokenizer, emailing, providerSettings, orgGetter, alertmanager, analytics, querier, telemetrystore, telemetryMetadataStore, authNs, authz, cache, queryParser, config)
+ roleModule := implrole.NewModule(implrole.NewStore(sqlstore), authz, nil)
+ dashboardModule := dashboardModuleCallback(sqlstore, providerSettings, analytics, orgGetter, roleModule, queryParser, querier, licensing)
+ modules := NewModules(sqlstore, tokenizer, emailing, providerSettings, orgGetter, alertmanager, analytics, querier, telemetrystore, telemetryMetadataStore, authNs, authz, cache, queryParser, config, dashboardModule)
// Initialize all handlers for the modules
handlers := NewHandlers(modules, providerSettings, querier, licensing, global, flagger)
diff --git a/pkg/types/authtypes/typeable.go b/pkg/types/authtypes/typeable.go
index 6b00e7cbdf..0bb2b6c3d5 100644
--- a/pkg/types/authtypes/typeable.go
+++ b/pkg/types/authtypes/typeable.go
@@ -35,6 +35,7 @@ type Typeable interface {
Name() Name
Prefix(orgId valuer.UUID) string
Tuples(subject string, relation Relation, selector []Selector, orgID valuer.UUID) ([]*openfgav1.TupleKey, error)
+ Scope(relation Relation) string
}
type Type struct{ valuer.String }
diff --git a/pkg/types/authtypes/typeable_anonymous.go b/pkg/types/authtypes/typeable_anonymous.go
index 0950a40085..f77db52ea2 100644
--- a/pkg/types/authtypes/typeable_anonymous.go
+++ b/pkg/types/authtypes/typeable_anonymous.go
@@ -35,3 +35,7 @@ func (typeableAnonymous *typeableAnonymous) Name() Name {
func (typeableAnonymous *typeableAnonymous) Prefix(orgID valuer.UUID) string {
return typeableAnonymous.Type().StringValue() + ":" + "organization" + "/" + orgID.StringValue() + "/" + typeableAnonymous.Name().String()
}
+
+func (typeableAnonymous *typeableAnonymous) Scope(relation Relation) string {
+ return typeableAnonymous.Name().String() + ":" + relation.StringValue()
+}
diff --git a/pkg/types/authtypes/typeable_metaresource.go b/pkg/types/authtypes/typeable_metaresource.go
index f7f1015df2..f26b0f0eb5 100644
--- a/pkg/types/authtypes/typeable_metaresource.go
+++ b/pkg/types/authtypes/typeable_metaresource.go
@@ -46,3 +46,7 @@ func (typeableMetaResource *typeableMetaResource) Name() Name {
func (typeableMetaResource *typeableMetaResource) Prefix(orgID valuer.UUID) string {
return typeableMetaResource.Type().StringValue() + ":" + "organization" + "/" + orgID.StringValue() + "/" + typeableMetaResource.Name().String()
}
+
+func (typeableMetaResource *typeableMetaResource) Scope(relation Relation) string {
+ return typeableMetaResource.Name().String() + ":" + relation.StringValue()
+}
diff --git a/pkg/types/authtypes/typeable_metaresources.go b/pkg/types/authtypes/typeable_metaresources.go
index 68c2427322..ca0c8d1ebd 100644
--- a/pkg/types/authtypes/typeable_metaresources.go
+++ b/pkg/types/authtypes/typeable_metaresources.go
@@ -46,3 +46,7 @@ func (typeableMetaResources *typeableMetaResources) Name() Name {
func (typeableMetaResources *typeableMetaResources) Prefix(orgID valuer.UUID) string {
return typeableMetaResources.Type().StringValue() + ":" + "organization" + "/" + orgID.StringValue() + "/" + typeableMetaResources.Name().String()
}
+
+func (typeableMetaResources *typeableMetaResources) Scope(relation Relation) string {
+ return typeableMetaResources.Name().String() + ":" + relation.StringValue()
+}
diff --git a/pkg/types/authtypes/typeable_organization.go b/pkg/types/authtypes/typeable_organization.go
index ae0a157926..d8c697963a 100644
--- a/pkg/types/authtypes/typeable_organization.go
+++ b/pkg/types/authtypes/typeable_organization.go
@@ -32,3 +32,7 @@ func (typeableOrganization *typeableOrganization) Name() Name {
func (typeableOrganization *typeableOrganization) Prefix(_ valuer.UUID) string {
return typeableOrganization.Type().StringValue()
}
+
+func (typeableOrganization *typeableOrganization) Scope(relation Relation) string {
+ return typeableOrganization.Name().String() + ":" + relation.StringValue()
+}
diff --git a/pkg/types/authtypes/typeable_role.go b/pkg/types/authtypes/typeable_role.go
index 5d855b89a6..9b9aaf1084 100644
--- a/pkg/types/authtypes/typeable_role.go
+++ b/pkg/types/authtypes/typeable_role.go
@@ -31,3 +31,7 @@ func (typeableRole *typeableRole) Name() Name {
func (typeableRole *typeableRole) Prefix(orgID valuer.UUID) string {
return typeableRole.Type().StringValue() + ":" + "organization" + "/" + orgID.StringValue() + "/" + typeableRole.Name().String()
}
+
+func (typeableRole *typeableRole) Scope(relation Relation) string {
+ return typeableRole.Name().String() + ":" + relation.StringValue()
+}
diff --git a/pkg/types/authtypes/typeable_user.go b/pkg/types/authtypes/typeable_user.go
index ad8b7ed3fe..590e067d4e 100644
--- a/pkg/types/authtypes/typeable_user.go
+++ b/pkg/types/authtypes/typeable_user.go
@@ -31,3 +31,7 @@ func (typeableUser *typeableUser) Name() Name {
func (typeableUser *typeableUser) Prefix(orgID valuer.UUID) string {
return typeableUser.Type().StringValue() + ":" + "organization" + "/" + orgID.StringValue() + "/" + typeableUser.Name().String()
}
+
+func (typeableUser *typeableUser) Scope(relation Relation) string {
+ return typeableUser.Name().String() + ":" + relation.StringValue()
+}
diff --git a/pkg/types/ctxtypes/auth.go b/pkg/types/ctxtypes/auth.go
index ec4d926290..20083e0186 100644
--- a/pkg/types/ctxtypes/auth.go
+++ b/pkg/types/ctxtypes/auth.go
@@ -14,6 +14,7 @@ var (
AuthTypeTokenizer = AuthType{valuer.NewString("tokenizer")}
AuthTypeAPIKey = AuthType{valuer.NewString("api_key")}
AuthTypeInternal = AuthType{valuer.NewString("internal")}
+ AuthTypeAnonymous = AuthType{valuer.NewString("anonymous")}
)
type authTypeKey struct{}
diff --git a/pkg/types/dashboardtypes/dashboard.go b/pkg/types/dashboardtypes/dashboard.go
index b5177539a2..fb60d7681b 100644
--- a/pkg/types/dashboardtypes/dashboard.go
+++ b/pkg/types/dashboardtypes/dashboard.go
@@ -320,7 +320,7 @@ func (lockUnlockDashboard *LockUnlockDashboard) UnmarshalJSON(src []byte) error
return nil
}
-func (dashboard *Dashboard) GetWidgetQuery(startTime, endTime uint64, widgetIndex int64, logger *slog.Logger) (*querybuildertypesv5.QueryRangeRequest, error) {
+func (dashboard *Dashboard) GetWidgetQuery(startTime, endTime, widgetIndex uint64, logger *slog.Logger) (*querybuildertypesv5.QueryRangeRequest, error) {
type dashboardData struct {
Widgets []struct {
PanelTypes string `json:"panelTypes"`
diff --git a/pkg/types/dashboardtypes/public_dashboard.go b/pkg/types/dashboardtypes/public_dashboard.go
index f4e055a18a..682f893c63 100644
--- a/pkg/types/dashboardtypes/public_dashboard.go
+++ b/pkg/types/dashboardtypes/public_dashboard.go
@@ -11,6 +11,7 @@ import (
)
var (
+ ErrCodePublicDashboardUnsupported = errors.MustNewCode("public_dashboard_unsupported")
ErrCodePublicDashboardInvalidInput = errors.MustNewCode("public_dashboard_invalid_input")
ErrCodePublicDashboardNotFound = errors.MustNewCode("public_dashboard_not_found")
ErrCodePublicDashboardAlreadyExists = errors.MustNewCode("public_dashboard_already_exists")