diff --git a/app/vminsert/main.go b/app/vminsert/main.go index a9273ad7f..0ed86956d 100644 --- a/app/vminsert/main.go +++ b/app/vminsert/main.go @@ -19,6 +19,7 @@ import ( "github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver" "github.com/VictoriaMetrics/VictoriaMetrics/lib/logger" "github.com/VictoriaMetrics/VictoriaMetrics/lib/procutil" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/storage" "github.com/VictoriaMetrics/metrics" ) @@ -28,6 +29,7 @@ var ( opentsdbHTTPListenAddr = flag.String("opentsdbHTTPListenAddr", "", "TCP address to listen for OpentTSDB HTTP put requests. Usually :4242 must be set. Doesn't work if empty") httpListenAddr = flag.String("httpListenAddr", ":8480", "Address to listen for http connections") maxInsertRequestSize = flag.Int("maxInsertRequestSize", 32*1024*1024, "The maximum size of a single insert request in bytes") + maxLabelsPerTimeseries = flag.Int("maxLabelsPerTimeseries", 30, "The maximum number of labels accepted per time series. Superflouos labels are dropped") storageNodes = flagutil.NewArray("storageNode", "Address of vmstorage nodes; usage: -storageNode=vmstorage-host1:8400 -storageNode=vmstorage-host2:8400") ) @@ -44,6 +46,8 @@ func main() { netstorage.InitStorageNodes(*storageNodes) logger.Infof("successfully initialized netstorage in %s", time.Since(startTime)) + storage.SetMaxLabelsPerTimeseries(*maxLabelsPerTimeseries) + concurrencylimiter.Init() if len(*graphiteListenAddr) > 0 { go graphite.Serve(*graphiteListenAddr) diff --git a/lib/storage/metric_name.go b/lib/storage/metric_name.go index 41ae8f46d..f53058db7 100644 --- a/lib/storage/metric_name.go +++ b/lib/storage/metric_name.go @@ -9,6 +9,7 @@ import ( "github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil" "github.com/VictoriaMetrics/VictoriaMetrics/lib/encoding" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/logger" "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompb" ) @@ -405,9 +406,18 @@ const maxLabelNameLen = 256 const maxLabelValueLen = 16 * 1024 // The maximum number of labels per each timeseries. +var maxLabelsPerTimeseries = 30 + +// SetMaxLabelsPerTimeseries sets the limit on the number of labels +// per each time series. // -// Superflouos lables are dropped. -const maxLabelsPerTimeseries = 30 +// Superfouos labels are dropped. +func SetMaxLabelsPerTimeseries(maxLabels int) { + if maxLabels <= 0 { + logger.Panicf("BUG: maxLabels must be positive; got %d", maxLabels) + } + maxLabelsPerTimeseries = maxLabels +} // MarshalMetricNameRaw marshals labels to dst and returns the result. //