diff --git a/layouts/layouts.go b/layouts/layouts.go index a1ae502bd4..6ff575aafe 100644 --- a/layouts/layouts.go +++ b/layouts/layouts.go @@ -16,6 +16,7 @@ type MultiLayoutStore struct { // All returns the set of all layouts func (s *MultiLayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) { all := []chronograf.Layout{} + layoutSet := map[string]chronograf.Layout{} ok := false var err error for _, store := range s.Stores { @@ -26,7 +27,14 @@ func (s *MultiLayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) continue } ok = true - all = append(all, layouts...) + for _, l := range layouts { + // Enforce that the layout has a unique ID + // If the layout has been seen before then skip + if _, okay := layoutSet[l.ID]; !okay { + layoutSet[l.ID] = l + all = append(all, l) + } + } } if !ok { return nil, err diff --git a/server/server.go b/server/server.go index 642853c3b4..2cc65e2f5a 100644 --- a/server/server.go +++ b/server/server.go @@ -117,7 +117,7 @@ func openService(boltPath, cannedPath string, logger chronograf.Logger) Service // These apps are those handled from a directory apps := canned.NewApps(cannedPath, &uuid.V4{}, logger) // These apps are statically compiled into chronograf - _ = &canned.BinLayoutStore{ + binApps := &canned.BinLayoutStore{ Logger: logger, } @@ -128,6 +128,7 @@ func openService(boltPath, cannedPath string, logger chronograf.Logger) Service Stores: []chronograf.LayoutStore{ db.LayoutStore, apps, + binApps, }, }