app/vminsert/influx: add -influxMeasurementFieldSeparator flag for the ability to change separator for {measurement}{separator}{field_name} metric name

This commit is contained in:
Aliaksandr Valialkin 2019-06-14 09:57:13 +03:00
parent 14edd122a6
commit 5f0b3589b2

View file

@ -2,6 +2,7 @@ package influx
import (
"compress/gzip"
"flag"
"fmt"
"io"
"net/http"
@ -19,6 +20,10 @@ import (
"github.com/VictoriaMetrics/metrics"
)
var (
measurementFieldSeparator = flag.String("influxMeasurementFieldSeparator", ".", "Separator for `{measurement}{separator}{field_name}` metric name when inserted via Influx line protocol")
)
var rowsInserted = tenantmetrics.NewCounterMap(`vm_rows_inserted_total{type="influx"}`)
// InsertHandler processes remote write for influx line protocol.
@ -89,7 +94,7 @@ func (ctx *pushCtx) InsertRows(at *auth.Token, db string) error {
ic.MetricNameBuf = storage.MarshalMetricNameRaw(ic.MetricNameBuf[:0], at.AccountID, at.ProjectID, ic.Labels)
metricNameBufLen := len(ic.MetricNameBuf)
ctx.metricGroupBuf = append(ctx.metricGroupBuf[:0], r.Measurement...)
ctx.metricGroupBuf = append(ctx.metricGroupBuf, '.')
ctx.metricGroupBuf = append(ctx.metricGroupBuf, *measurementFieldSeparator...)
metricGroupPrefixLen := len(ctx.metricGroupBuf)
ic.AddLabel("", "placeholder")
placeholderLabel := &ic.Labels[len(ic.Labels)-1]