diff --git a/README.md b/README.md index 41a395a8a..982dbae9f 100644 --- a/README.md +++ b/README.md @@ -1651,8 +1651,10 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li -maxInsertRequestSize size The maximum size in bytes of a single Prometheus remote_write API request Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 33554432) + -maxLabelValueLen int + The maximum length of label values in the accepted time series. Longer label values are truncated. In this case the vm_too_long_label_values_total metric at /metrics page is incremented (default 16384) -maxLabelsPerTimeseries int - The maximum number of labels accepted per time series. Superfluous labels are dropped (default 30) + The maximum number of labels accepted per time series. Superfluous labels are dropped. In this case the vm_metrics_with_dropped_labels_total metric at /metrics page is incremented (default 30) -memory.allowedBytes size Allowed size of system memory VictoriaMetrics caches may occupy. This option overrides -memory.allowedPercent if set to a non-zero value. Too low a value may increase the cache miss rate usually resulting in higher CPU and disk IO usage. Too high a value may evict too much data from OS page cache resulting in higher disk IO usage Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 0) diff --git a/app/vminsert/main.go b/app/vminsert/main.go index acd9779a9..c77d78a4a 100644 --- a/app/vminsert/main.go +++ b/app/vminsert/main.go @@ -43,7 +43,8 @@ var ( "Usually :4242 must be set. Doesn't work if empty") opentsdbHTTPListenAddr = flag.String("opentsdbHTTPListenAddr", "", "TCP address to listen for OpentTSDB HTTP put requests. Usually :4242 must be set. Doesn't work if empty") configAuthKey = flag.String("configAuthKey", "", "Authorization key for accessing /config page. It must be passed via authKey query arg") - maxLabelsPerTimeseries = flag.Int("maxLabelsPerTimeseries", 30, "The maximum number of labels accepted per time series. Superfluous labels are dropped") + maxLabelsPerTimeseries = flag.Int("maxLabelsPerTimeseries", 30, "The maximum number of labels accepted per time series. Superfluous labels are dropped. In this case the vm_metrics_with_dropped_labels_total metric at /metrics page is incremented") + maxLabelValueLen = flag.Int("maxLabelValueLen", 16*1024, "The maximum length of label values in the accepted time series. Longer label values are truncated. In this case the vm_too_long_label_values_total metric at /metrics page is incremented") ) var ( @@ -57,6 +58,7 @@ var ( func Init() { relabel.Init() storage.SetMaxLabelsPerTimeseries(*maxLabelsPerTimeseries) + storage.SetMaxLabelValueLen(*maxLabelValueLen) common.StartUnmarshalWorkers() writeconcurrencylimiter.Init() if len(*graphiteListenAddr) > 0 { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 99865a468..11d8c705d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,7 @@ sort: 15 * FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth.html): allow specifying `http` and `https` urls in `-auth.config` command-line flag. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1898). Thanks for @TFM93 . * FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): allow specifying `http` and `https` urls in the following command-line flags: `-promscrape.config`, `-remoteWrite.relabelConfig` and `-remoteWrite.urlRelabelConfig`. * FEATURE: vminsert: allow specifying `http` and `https` urls in `-relabelConfig` command-line flag. +* FEATURE: vminsert: add `-maxLabelValueLen` command-line flag for the ability to configure the maximum length of label value. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1908). * BUGFIX: fix `unaligned 64-bit atomic operation` panic on 32-bit architectures, which has been introduced in v1.70.0. diff --git a/docs/README.md b/docs/README.md index 41a395a8a..982dbae9f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1651,8 +1651,10 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li -maxInsertRequestSize size The maximum size in bytes of a single Prometheus remote_write API request Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 33554432) + -maxLabelValueLen int + The maximum length of label values in the accepted time series. Longer label values are truncated. In this case the vm_too_long_label_values_total metric at /metrics page is incremented (default 16384) -maxLabelsPerTimeseries int - The maximum number of labels accepted per time series. Superfluous labels are dropped (default 30) + The maximum number of labels accepted per time series. Superfluous labels are dropped. In this case the vm_metrics_with_dropped_labels_total metric at /metrics page is incremented (default 30) -memory.allowedBytes size Allowed size of system memory VictoriaMetrics caches may occupy. This option overrides -memory.allowedPercent if set to a non-zero value. Too low a value may increase the cache miss rate usually resulting in higher CPU and disk IO usage. Too high a value may evict too much data from OS page cache resulting in higher disk IO usage Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 0) diff --git a/docs/Single-server-VictoriaMetrics.md b/docs/Single-server-VictoriaMetrics.md index beb77cc8e..f6bdd6f24 100644 --- a/docs/Single-server-VictoriaMetrics.md +++ b/docs/Single-server-VictoriaMetrics.md @@ -1655,8 +1655,10 @@ Pass `-help` to VictoriaMetrics in order to see the list of supported command-li -maxInsertRequestSize size The maximum size in bytes of a single Prometheus remote_write API request Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 33554432) + -maxLabelValueLen int + The maximum length of label values in the accepted time series. Longer label values are truncated. In this case the vm_too_long_label_values_total metric at /metrics page is incremented (default 16384) -maxLabelsPerTimeseries int - The maximum number of labels accepted per time series. Superfluous labels are dropped (default 30) + The maximum number of labels accepted per time series. Superfluous labels are dropped. In this case the vm_metrics_with_dropped_labels_total metric at /metrics page is incremented (default 30) -memory.allowedBytes size Allowed size of system memory VictoriaMetrics caches may occupy. This option overrides -memory.allowedPercent if set to a non-zero value. Too low a value may increase the cache miss rate usually resulting in higher CPU and disk IO usage. Too high a value may evict too much data from OS page cache resulting in higher disk IO usage Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 0) diff --git a/lib/storage/metric_name.go b/lib/storage/metric_name.go index e1ab7da75..e997006d5 100644 --- a/lib/storage/metric_name.go +++ b/lib/storage/metric_name.go @@ -418,7 +418,18 @@ const maxLabelNameLen = 256 // The maximum length of label value. // // Longer values are truncated. -const maxLabelValueLen = 16 * 1024 +var maxLabelValueLen = 16 * 1024 + +// SetMaxLabelValueLen sets the limit on the label value length. +// +// This function can be called before using the storage package. +// +// Label values with longer length are truncated. +func SetMaxLabelValueLen(n int) { + if n > 0 { + maxLabelValueLen = n + } +} // The maximum number of labels per each timeseries. var maxLabelsPerTimeseries = 30 @@ -426,12 +437,13 @@ var maxLabelsPerTimeseries = 30 // SetMaxLabelsPerTimeseries sets the limit on the number of labels // per each time series. // +// This function can be called before using the storage package. +// // Superfluous labels are dropped. func SetMaxLabelsPerTimeseries(maxLabels int) { - if maxLabels <= 0 { - logger.Panicf("BUG: maxLabels must be positive; got %d", maxLabels) + if maxLabels > 0 { + maxLabelsPerTimeseries = maxLabels } - maxLabelsPerTimeseries = maxLabels } // MarshalMetricNameRaw marshals labels to dst and returns the result.