mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vminsert: export metrics for determining ingested rows with dropped or truncated labels
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/565
This commit is contained in:
parent
af7db914c2
commit
4f673a5201
3 changed files with 30 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/csvimport"
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/csvimport"
|
||||||
|
@ -208,4 +209,14 @@ var (
|
||||||
influxWriteErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/insert/{}/influx/", protocol="influx"}`)
|
influxWriteErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/insert/{}/influx/", protocol="influx"}`)
|
||||||
|
|
||||||
influxQueryRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/influx/query", protocol="influx"}`)
|
influxQueryRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/influx/query", protocol="influx"}`)
|
||||||
|
|
||||||
|
_ = metrics.NewGauge(`vm_metrics_with_dropped_labels_total`, func() float64 {
|
||||||
|
return float64(atomic.LoadUint64(&storage.MetricsWithDroppedLabels))
|
||||||
|
})
|
||||||
|
_ = metrics.NewGauge(`vm_too_long_label_names_total`, func() float64 {
|
||||||
|
return float64(atomic.LoadUint64(&storage.TooLongLabelNames))
|
||||||
|
})
|
||||||
|
_ = metrics.NewGauge(`vm_too_long_label_values_total`, func() float64 {
|
||||||
|
return float64(atomic.LoadUint64(&storage.TooLongLabelValues))
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
|
@ -987,6 +987,10 @@ The most interesting metrics are:
|
||||||
VictoriaMetrics accepts optional `date=YYYY-MM-DD` and `topN=42` args on this page. By default `date` equals to the current date,
|
VictoriaMetrics accepts optional `date=YYYY-MM-DD` and `topN=42` args on this page. By default `date` equals to the current date,
|
||||||
while `topN` equals to 10.
|
while `topN` equals to 10.
|
||||||
|
|
||||||
|
* VictoriaMetrics limits the number of labels per each metric with `-maxLabelsPerTimeseries` command-line flag.
|
||||||
|
This prevents from ingesting metrics with too many labels. It is recommended [monitoring](#monitoring) `vm_metrics_with_dropped_labels_total`
|
||||||
|
metric in order to determine whether `-maxLabelsPerTimeseries` must be adjusted for your workload.
|
||||||
|
|
||||||
|
|
||||||
### Backfilling
|
### Backfilling
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/encoding"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/encoding"
|
||||||
|
@ -430,13 +431,16 @@ func MarshalMetricNameRaw(dst []byte, accountID, projectID uint32, labels []prom
|
||||||
dstSize := dstLen + 8
|
dstSize := dstLen + 8
|
||||||
for i := range labels {
|
for i := range labels {
|
||||||
if i >= maxLabelsPerTimeseries {
|
if i >= maxLabelsPerTimeseries {
|
||||||
|
atomic.AddUint64(&MetricsWithDroppedLabels, 1)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
label := &labels[i]
|
label := &labels[i]
|
||||||
if len(label.Name) > maxLabelNameLen {
|
if len(label.Name) > maxLabelNameLen {
|
||||||
|
atomic.AddUint64(&TooLongLabelNames, 1)
|
||||||
label.Name = label.Name[:maxLabelNameLen]
|
label.Name = label.Name[:maxLabelNameLen]
|
||||||
}
|
}
|
||||||
if len(label.Value) > maxLabelValueLen {
|
if len(label.Value) > maxLabelValueLen {
|
||||||
|
atomic.AddUint64(&TooLongLabelValues, 1)
|
||||||
label.Value = label.Value[:maxLabelValueLen]
|
label.Value = label.Value[:maxLabelValueLen]
|
||||||
}
|
}
|
||||||
if len(label.Value) == 0 {
|
if len(label.Value) == 0 {
|
||||||
|
@ -470,6 +474,17 @@ func MarshalMetricNameRaw(dst []byte, accountID, projectID uint32, labels []prom
|
||||||
return dst
|
return dst
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// MetricsWithDroppedLabels is the number of metrics with at least a single dropped label
|
||||||
|
MetricsWithDroppedLabels uint64
|
||||||
|
|
||||||
|
// TooLongLabelNames is the number of too long label names
|
||||||
|
TooLongLabelNames uint64
|
||||||
|
|
||||||
|
// TooLongLabelValues is the number of too long label values
|
||||||
|
TooLongLabelValues uint64
|
||||||
|
)
|
||||||
|
|
||||||
// MarshalMetricLabelRaw marshals label to dst.
|
// MarshalMetricLabelRaw marshals label to dst.
|
||||||
func MarshalMetricLabelRaw(dst []byte, label *prompb.Label) []byte {
|
func MarshalMetricLabelRaw(dst []byte, label *prompb.Label) []byte {
|
||||||
dst = marshalBytesFast(dst, label.Name)
|
dst = marshalBytesFast(dst, label.Name)
|
||||||
|
|
Loading…
Reference in a new issue