From 44a6cc5eca4f7f2f78c8c45a9648e2bbe53300b2 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 22 Mar 2021 13:53:42 +0200 Subject: [PATCH] app/{vminsert,vmagent}: use Influx field as metric name if measurement is empty and -influxSkipSingleField command-line is set See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1139 --- app/vmagent/influx/request_handler.go | 3 ++- app/vminsert/influx/request_handler.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/vmagent/influx/request_handler.go b/app/vmagent/influx/request_handler.go index b39d365f3..9da1be933 100644 --- a/app/vmagent/influx/request_handler.go +++ b/app/vmagent/influx/request_handler.go @@ -96,7 +96,8 @@ func insertRows(db string, rows []parser.Row, extraLabels []prompbmarshal.Label) if !*skipMeasurement { ctx.metricGroupBuf = append(ctx.metricGroupBuf, r.Measurement...) } - skipFieldKey := len(r.Fields) == 1 && *skipSingleField + // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1139 + skipFieldKey := len(r.Measurement) > 0 && len(r.Fields) == 1 && *skipSingleField if len(ctx.metricGroupBuf) > 0 && !skipFieldKey { ctx.metricGroupBuf = append(ctx.metricGroupBuf, *measurementFieldSeparator...) } diff --git a/app/vminsert/influx/request_handler.go b/app/vminsert/influx/request_handler.go index 4e4e17c28..784c2c3ec 100644 --- a/app/vminsert/influx/request_handler.go +++ b/app/vminsert/influx/request_handler.go @@ -96,7 +96,8 @@ func insertRows(db string, rows []parser.Row, extraLabels []prompbmarshal.Label) if !*skipMeasurement { ctx.metricGroupBuf = append(ctx.metricGroupBuf, r.Measurement...) } - skipFieldKey := len(r.Fields) == 1 && *skipSingleField + // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1139 + skipFieldKey := len(r.Measurement) > 0 && len(r.Fields) == 1 && *skipSingleField if len(ctx.metricGroupBuf) > 0 && !skipFieldKey { ctx.metricGroupBuf = append(ctx.metricGroupBuf, *measurementFieldSeparator...) }