mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/{vminsert,vmagent}: add -influxSkipMeasurement
command-line flag for using field name as metric name
See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/626
This commit is contained in:
parent
be0ab4fbfe
commit
86044f6561
2 changed files with 10 additions and 2 deletions
|
@ -19,6 +19,7 @@ import (
|
||||||
var (
|
var (
|
||||||
measurementFieldSeparator = flag.String("influxMeasurementFieldSeparator", "_", "Separator for '{measurement}{separator}{field_name}' metric name when inserted via Influx line protocol")
|
measurementFieldSeparator = flag.String("influxMeasurementFieldSeparator", "_", "Separator for '{measurement}{separator}{field_name}' metric name when inserted via Influx line protocol")
|
||||||
skipSingleField = flag.Bool("influxSkipSingleField", false, "Uses '{measurement}' instead of '{measurement}{separator}{field_name}' for metic name if Influx line contains only a single field")
|
skipSingleField = flag.Bool("influxSkipSingleField", false, "Uses '{measurement}' instead of '{measurement}{separator}{field_name}' for metic name if Influx line contains only a single field")
|
||||||
|
skipMeasurement = flag.Bool("influxSkipMeasurement", false, "Uses '{field_name}' as a metric name while ignoring '{measurement}' and '-influxMeasurementFieldSeparator'")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -79,7 +80,10 @@ func insertRows(db string, rows []parser.Row) error {
|
||||||
Value: db,
|
Value: db,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ctx.metricGroupBuf = append(ctx.metricGroupBuf[:0], r.Measurement...)
|
ctx.metricGroupBuf = ctx.metricGroupBuf[:0]
|
||||||
|
if !*skipMeasurement {
|
||||||
|
ctx.metricGroupBuf = append(ctx.metricGroupBuf, r.Measurement...)
|
||||||
|
}
|
||||||
skipFieldKey := len(r.Fields) == 1 && *skipSingleField
|
skipFieldKey := 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...)
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
var (
|
var (
|
||||||
measurementFieldSeparator = flag.String("influxMeasurementFieldSeparator", "_", "Separator for '{measurement}{separator}{field_name}' metric name when inserted via Influx line protocol")
|
measurementFieldSeparator = flag.String("influxMeasurementFieldSeparator", "_", "Separator for '{measurement}{separator}{field_name}' metric name when inserted via Influx line protocol")
|
||||||
skipSingleField = flag.Bool("influxSkipSingleField", false, "Uses '{measurement}' instead of '{measurement}{separator}{field_name}' for metic name if Influx line contains only a single field")
|
skipSingleField = flag.Bool("influxSkipSingleField", false, "Uses '{measurement}' instead of '{measurement}{separator}{field_name}' for metic name if Influx line contains only a single field")
|
||||||
|
skipMeasurement = flag.Bool("influxSkipMeasurement", false, "Uses '{field_name}' as a metric name while ignoring '{measurement}' and '-influxMeasurementFieldSeparator'")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -88,7 +89,10 @@ func insertRows(at *auth.Token, db string, rows []parser.Row, mayOverrideAccount
|
||||||
if len(db) > 0 && !hasDBLabel {
|
if len(db) > 0 && !hasDBLabel {
|
||||||
ic.AddLabel("db", db)
|
ic.AddLabel("db", db)
|
||||||
}
|
}
|
||||||
ctx.metricGroupBuf = append(ctx.metricGroupBuf[:0], r.Measurement...)
|
ctx.metricGroupBuf = ctx.metricGroupBuf[:0]
|
||||||
|
if !*skipMeasurement {
|
||||||
|
ctx.metricGroupBuf = append(ctx.metricGroupBuf, r.Measurement...)
|
||||||
|
}
|
||||||
skipFieldKey := len(r.Fields) == 1 && *skipSingleField
|
skipFieldKey := 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...)
|
||||||
|
|
Loading…
Reference in a new issue