From 4c8b49b193eeab4a7f80f7b2cbd344744340109b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 23 Jul 2020 14:57:42 +0300 Subject: [PATCH] app/vminsert: export `vm_relabel_metrics_dropped_total` metric that shows the number of metrics dropped due to relabeling --- app/vminsert/relabel/relabel.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/vminsert/relabel/relabel.go b/app/vminsert/relabel/relabel.go index 1c8facec2..25274c9ad 100644 --- a/app/vminsert/relabel/relabel.go +++ b/app/vminsert/relabel/relabel.go @@ -11,6 +11,7 @@ import ( "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompb" "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal" "github.com/VictoriaMetrics/VictoriaMetrics/lib/promrelabel" + "github.com/VictoriaMetrics/metrics" ) var relabelConfig = flag.String("relabelConfig", "", "Optional path to a file with relabeling rules, which are applied to all the ingested metrics. "+ @@ -103,6 +104,9 @@ func (ctx *Ctx) ApplyRelabeling(labels []prompb.Label) []prompb.Label { // Apply relabeling tmpLabels = promrelabel.ApplyRelabelConfigs(tmpLabels, 0, *prcs, true) ctx.tmpLabels = tmpLabels + if len(tmpLabels) == 0 { + metricsDropped.Inc() + } // Return back labels to the desired format. dst := labels[:0] @@ -119,3 +123,5 @@ func (ctx *Ctx) ApplyRelabeling(labels []prompb.Label) []prompb.Label { } return dst } + +var metricsDropped = metrics.NewCounter(`vm_relabel_metrics_dropped_total`)