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

Commit 1e16dca

Browse files
authored
Merge pull request #921 from grafana/mt-kafka-mdm-sniff-invalid
mode to print only invalid data
2 parents a5d95d6 + f61d4d4 commit 1e16dca

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cmd/mt-kafka-mdm-sniff/main.go

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var (
2626
formatP = flag.String("format-point", "{{.Part}} {{.MKey}} {{.Value}} {{.Time}}", "template to render MetricPoint data with")
2727
prefix = flag.String("prefix", "", "only show metrics that have this prefix")
2828
substr = flag.String("substr", "", "only show metrics that have this substring")
29+
invalid = flag.Bool("invalid", false, "only show metrics that are invalid")
2930

3031
stdoutLock = sync.Mutex{}
3132
)
@@ -61,6 +62,12 @@ func (ip inputPrinter) ProcessMetricData(metric *schema.MetricData, partition in
6162
if *substr != "" && !strings.Contains(metric.Name, *substr) {
6263
return
6364
}
65+
if *invalid {
66+
err := metric.Validate()
67+
if err == nil && metric.Time != 0 {
68+
return
69+
}
70+
}
6471
stdoutLock.Lock()
6572
err := ip.tplMd.Execute(os.Stdout, DataMd{
6673
partition,
@@ -74,6 +81,11 @@ func (ip inputPrinter) ProcessMetricData(metric *schema.MetricData, partition in
7481
}
7582

7683
func (ip inputPrinter) ProcessMetricPoint(point schema.MetricPoint, format msg.Format, partition int32) {
84+
85+
if *invalid && point.Valid() {
86+
return
87+
}
88+
7789
stdoutLock.Lock()
7890
err := ip.tplP.Execute(os.Stdout, DataP{
7991
partition,

docs/tools.md

+2
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ Flags:
190190
template to render MetricData with (default "{{.Part}} {{.OrgId}} {{.Id}} {{.Name}} {{.Interval}} {{.Value}} {{.Time}} {{.Unit}} {{.Mtype}} {{.Tags}}")
191191
-format-point string
192192
template to render MetricPoint data with (default "{{.Part}} {{.MKey}} {{.Value}} {{.Time}}")
193+
-invalid
194+
only show metrics that are invalid
193195
-prefix string
194196
only show metrics that have this prefix
195197
-substr string

0 commit comments

Comments
 (0)