From 979d89f5dd39e0b77946924439ebc1e4bb828c8c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 21 Feb 2022 14:03:00 +0200 Subject: [PATCH] app/vmagent: add `-influxDBLabel` in the same way as for app/vminsert This is a follow-up for 3d19fa6932815e0f2aad114bce588f02f88a4860 --- README.md | 2 ++ app/vmagent/README.md | 2 ++ app/vmagent/influx/request_handler.go | 5 +++-- docs/README.md | 2 ++ docs/Single-server-VictoriaMetrics.md | 2 ++ docs/vmagent.md | 2 ++ 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d76674a45..a9d272a46 100644 --- a/README.md +++ b/README.md @@ -1713,6 +1713,8 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li -influx.maxLineSize size The maximum size in bytes for a single InfluxDB line during parsing Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 262144) + -influxDBLabel string + Default label for the DB name sent over '?db={db_name}' query parameter (default "db") -influxListenAddr string TCP and UDP address to listen for InfluxDB line protocol data. Usually :8189 must be set. Doesn't work if empty. This flag isn't needed when ingesting data over HTTP - just send it to http://:8428/write -influxMeasurementFieldSeparator string diff --git a/app/vmagent/README.md b/app/vmagent/README.md index 61cbe7216..ec551d5ea 100644 --- a/app/vmagent/README.md +++ b/app/vmagent/README.md @@ -771,6 +771,8 @@ See the docs at https://docs.victoriametrics.com/vmagent.html . -influx.maxLineSize size The maximum size in bytes for a single InfluxDB line during parsing Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 262144) + -influxDBLabel string + Default label for the DB name sent over '?db={db_name}' query parameter (default "db") -influxListenAddr string TCP and UDP address to listen for InfluxDB line protocol data. Usually :8189 must be set. Doesn't work if empty. This flag isn't needed when ingesting data over HTTP - just send it to http://:8429/write -influxMeasurementFieldSeparator string diff --git a/app/vmagent/influx/request_handler.go b/app/vmagent/influx/request_handler.go index ee519ef09..ef409ef9c 100644 --- a/app/vmagent/influx/request_handler.go +++ b/app/vmagent/influx/request_handler.go @@ -24,6 +24,7 @@ var ( measurementFieldSeparator = flag.String("influxMeasurementFieldSeparator", "_", "Separator for '{measurement}{separator}{field_name}' metric name when inserted via InfluxDB line protocol") skipSingleField = flag.Bool("influxSkipSingleField", false, "Uses '{measurement}' instead of '{measurement}{separator}{field_name}' for metic name if InfluxDB line contains only a single field") skipMeasurement = flag.Bool("influxSkipMeasurement", false, "Uses '{field_name}' as a metric name while ignoring '{measurement}' and '-influxMeasurementFieldSeparator'") + dbLabel = flag.String("influxDBLabel", "db", "Default label for the DB name sent over '?db={db_name}' query parameter") ) var ( @@ -80,7 +81,7 @@ func insertRows(at *auth.Token, db string, rows []parser.Row, extraLabels []prom hasDBKey := false for j := range r.Tags { tag := &r.Tags[j] - if tag.Key == "db" { + if tag.Key == *dbLabel { hasDBKey = true } commonLabels = append(commonLabels, prompbmarshal.Label{ @@ -90,7 +91,7 @@ func insertRows(at *auth.Token, db string, rows []parser.Row, extraLabels []prom } if len(db) > 0 && !hasDBKey { commonLabels = append(commonLabels, prompbmarshal.Label{ - Name: "db", + Name: *dbLabel, Value: db, }) } diff --git a/docs/README.md b/docs/README.md index d76674a45..a9d272a46 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1713,6 +1713,8 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li -influx.maxLineSize size The maximum size in bytes for a single InfluxDB line during parsing Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 262144) + -influxDBLabel string + Default label for the DB name sent over '?db={db_name}' query parameter (default "db") -influxListenAddr string TCP and UDP address to listen for InfluxDB line protocol data. Usually :8189 must be set. Doesn't work if empty. This flag isn't needed when ingesting data over HTTP - just send it to http://:8428/write -influxMeasurementFieldSeparator string diff --git a/docs/Single-server-VictoriaMetrics.md b/docs/Single-server-VictoriaMetrics.md index bb003a758..0b6f5727e 100644 --- a/docs/Single-server-VictoriaMetrics.md +++ b/docs/Single-server-VictoriaMetrics.md @@ -1717,6 +1717,8 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li -influx.maxLineSize size The maximum size in bytes for a single InfluxDB line during parsing Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 262144) + -influxDBLabel string + Default label for the DB name sent over '?db={db_name}' query parameter (default "db") -influxListenAddr string TCP and UDP address to listen for InfluxDB line protocol data. Usually :8189 must be set. Doesn't work if empty. This flag isn't needed when ingesting data over HTTP - just send it to http://:8428/write -influxMeasurementFieldSeparator string diff --git a/docs/vmagent.md b/docs/vmagent.md index ee3a09aa2..ecfbf065b 100644 --- a/docs/vmagent.md +++ b/docs/vmagent.md @@ -775,6 +775,8 @@ See the docs at https://docs.victoriametrics.com/vmagent.html . -influx.maxLineSize size The maximum size in bytes for a single InfluxDB line during parsing Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 262144) + -influxDBLabel string + Default label for the DB name sent over '?db={db_name}' query parameter (default "db") -influxListenAddr string TCP and UDP address to listen for InfluxDB line protocol data. Usually :8189 must be set. Doesn't work if empty. This flag isn't needed when ingesting data over HTTP - just send it to http://:8429/write -influxMeasurementFieldSeparator string