Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

mode to print only invalid data #921

Merged
merged 1 commit into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/mt-kafka-mdm-sniff/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
formatP = flag.String("format-point", "{{.Part}} {{.MKey}} {{.Value}} {{.Time}}", "template to render MetricPoint data with")
prefix = flag.String("prefix", "", "only show metrics that have this prefix")
substr = flag.String("substr", "", "only show metrics that have this substring")
invalid = flag.Bool("invalid", false, "only show metrics that are invalid")

stdoutLock = sync.Mutex{}
)
Expand Down Expand Up @@ -61,6 +62,12 @@ func (ip inputPrinter) ProcessMetricData(metric *schema.MetricData, partition in
if *substr != "" && !strings.Contains(metric.Name, *substr) {
return
}
if *invalid {
err := metric.Validate()
if err == nil && metric.Time != 0 {
return
}
}
stdoutLock.Lock()
err := ip.tplMd.Execute(os.Stdout, DataMd{
partition,
Expand All @@ -74,6 +81,11 @@ func (ip inputPrinter) ProcessMetricData(metric *schema.MetricData, partition in
}

func (ip inputPrinter) ProcessMetricPoint(point schema.MetricPoint, format msg.Format, partition int32) {

if *invalid && point.Valid() {
return
}

stdoutLock.Lock()
err := ip.tplP.Execute(os.Stdout, DataP{
partition,
Expand Down
2 changes: 2 additions & 0 deletions docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ Flags:
template to render MetricData with (default "{{.Part}} {{.OrgId}} {{.Id}} {{.Name}} {{.Interval}} {{.Value}} {{.Time}} {{.Unit}} {{.Mtype}} {{.Tags}}")
-format-point string
template to render MetricPoint data with (default "{{.Part}} {{.MKey}} {{.Value}} {{.Time}}")
-invalid
only show metrics that are invalid
-prefix string
only show metrics that have this prefix
-substr string
Expand Down