Skip to content

Commit

Permalink
fix(query-service): skip preloading non-json files under dashboards (S…
Browse files Browse the repository at this point in the history
…igNoz#6979)

### Summary

- query-service: skip preloading non-json files under dashboards

Resolves the error log:

```
{"level":"INFO","timestamp":"2025-01-29T17:37:18.635Z","caller":"dashboards/provision.go:26","msg":"Provisioning dashboard: ","filename":".gitkeep"}
{"level":"ERROR","timestamp":"2025-01-29T17:37:18.635Z","caller":"dashboards/provision.go:38","msg":"Creating Dashboards: Error in unmarshalling json from file","filename":".gitkeep","error":"unexpected end of JSON input","stacktrace":"go.signoz.io/signoz/pkg/query-service/app/dashboards.readCurrentDir\n\t/home/sa_100696978840572610735/signoz/pkg/query-service/app/dashboards/provision.go:38\ngo.signoz.io/signoz/pkg/query-service/app/dashboards.LoadDashboardFiles\n\t/home/sa_100696978840572610735/signoz/pkg/query-service/app/dashboards/provision.go:79\ngo.signoz.io/signoz/pkg/query-service/app.NewAPIHandler\n\t/home/sa_100696978840572610735/signoz/pkg/query-service/app/http_handler.go:271\ngo.signoz.io/signoz/ee/query-service/app/api.NewAPIHandler\n\t/home/sa_100696978840572610735/signoz/ee/query-service/app/api/api.go:56\ngo.signoz.io/signoz/ee/query-service/app.NewServer\n\t/home/sa_100696978840572610735/signoz/ee/query-service/app/server.go:287\nmain.main\n\t/home/sa_100696978840572610735/signoz/ee/query-service/main.go:191\nruntime.main\n\t/home/sa_100696978840572610735/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:271"}
```

Signed-off-by: Prashant Shahi <[email protected]>
  • Loading branch information
prashant-shahi authored and hudsongeovane committed Feb 22, 2025
1 parent c10d6a4 commit 6bb78b9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/query-service/app/dashboards/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"strings"

"go.uber.org/zap"

Expand All @@ -23,6 +24,10 @@ func readCurrentDir(dir string, fm interfaces.FeatureLookup) error {

list, _ := file.Readdirnames(0) // 0 to read all files and folders
for _, filename := range list {
if strings.ToLower(filepath.Ext(filename)) != ".json" {
zap.L().Debug("Skipping non-json file", zap.String("filename", filename))
continue
}
zap.L().Info("Provisioning dashboard: ", zap.String("filename", filename))

// using filepath.Join for platform specific path creation
Expand Down

0 comments on commit 6bb78b9

Please sign in to comment.