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
This commit is contained in:
Aliaksandr Valialkin 2021-03-22 13:53:42 +02:00
parent 910092ca4d
commit 44a6cc5eca
2 changed files with 4 additions and 2 deletions

View file

@ -96,7 +96,8 @@ func insertRows(db string, rows []parser.Row, extraLabels []prompbmarshal.Label)
if !*skipMeasurement { if !*skipMeasurement {
ctx.metricGroupBuf = append(ctx.metricGroupBuf, r.Measurement...) 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 { if len(ctx.metricGroupBuf) > 0 && !skipFieldKey {
ctx.metricGroupBuf = append(ctx.metricGroupBuf, *measurementFieldSeparator...) ctx.metricGroupBuf = append(ctx.metricGroupBuf, *measurementFieldSeparator...)
} }

View file

@ -96,7 +96,8 @@ func insertRows(db string, rows []parser.Row, extraLabels []prompbmarshal.Label)
if !*skipMeasurement { if !*skipMeasurement {
ctx.metricGroupBuf = append(ctx.metricGroupBuf, r.Measurement...) 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 { if len(ctx.metricGroupBuf) > 0 && !skipFieldKey {
ctx.metricGroupBuf = append(ctx.metricGroupBuf, *measurementFieldSeparator...) ctx.metricGroupBuf = append(ctx.metricGroupBuf, *measurementFieldSeparator...)
} }