Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

filer.meta.tail: output json format for easier parsing

Chris Lu024c186a487a
diff --git a/weed/command/filer_meta_tail.go b/weed/command/filer_meta_tail.go
index fa0262160c..f055b19a80 100644
--- a/weed/command/filer_meta_tail.go
+++ b/weed/command/filer_meta_tail.go
@@ -3,9 +3,11 @@ package command
import (
"context"
"fmt"
+ "github.com/golang/protobuf/jsonpb"
jsoniter "github.com/json-iterator/go"
"github.com/olivere/elastic/v7"
"io"
+ "os"
"path/filepath"
"strings"
"time"
@@ -25,6 +27,10 @@ var cmdFilerMetaTail = &Command{
Short: "see recent changes on a filer",
Long: `See recent changes on a filer.
+ weed filer.meta.tail -timeAgo=30h | grep truncate
+ weed filer.meta.tail -timeAgo=30h | jq .
+ weed filer.meta.tail -timeAgo=30h | jq .eventNotification.newEntry.name
+
`,
}
@@ -80,8 +86,12 @@ func runFilerMetaTail(cmd *Command, args []string) bool {
return false
}
+ jsonpbMarshaler := jsonpb.Marshaler{
+ EmitDefaults: false,
+ }
eachEntryFunc := func(resp *filer_pb.SubscribeMetadataResponse) error {
- fmt.Printf("dir:%s %+v\n", resp.Directory, resp.EventNotification)
+ jsonpbMarshaler.Marshal(os.Stdout, resp)
+ fmt.Fprintln(os.Stdout)
return nil
}
if *esServers != "" {