diff --git a/app/vmstorage/main.go b/app/vmstorage/main.go index 4c138be2f0..e722d60101 100644 --- a/app/vmstorage/main.go +++ b/app/vmstorage/main.go @@ -500,6 +500,13 @@ func registerStorageMetrics() { return float64(idbm().AssistedMerges) }) + metrics.NewGauge(`vm_indexdb_items_added_total`, func() float64 { + return float64(idbm().ItemsAdded) + }) + metrics.NewGauge(`vm_indexdb_items_added_size_bytes_total`, func() float64 { + return float64(idbm().ItemsAddedSizeBytes) + }) + // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/686 metrics.NewGauge(`vm_merge_need_free_disk_space{type="storage/small"}`, func() float64 { return float64(tm().SmallMergeNeedFreeDiskSpace) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 32c385915f..5c4dc9e2da 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -22,6 +22,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * FEATURE: allow specifying TLS cipher suites for incoming https requests via `-tlsCipherSuites` command-line flag. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2404). * FEATURE: allow specifying TLS cipher suites for mTLS connections between cluster components via `-cluster.tlsCipherSuites` command-line flag. See [these docs](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#mtls-protection). * FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): shown an empty graph on the selected time range when there is no data on it. Previously `No data to show` placeholder was shown instead of the graph in this case. This prevented from zooming and scrolling of such a graph. +* FEATURE: expose `vm_indexdb_items_added_total` and `vm_indexdb_items_added_size_bytes_total` counters at `/metrics` page, which can be used for monitoring the rate for addition of new entries in `indexdb` (aka `inverted index`) alongside the total size in bytes for the added entries. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2471). * BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): return non-zero exit code on error. This allows handling `vmctl` errors in shell scripts. Previously `vmctl` was returning 0 exit code on error. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2322). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly show `scrape_timeout` and `scrape_interval` options at `http://vmagent:8429/config` page. Previously these options weren't displayed even if they were set in `-promscrape.config`. diff --git a/lib/mergeset/table.go b/lib/mergeset/table.go index f0473c9d4a..217c454e83 100644 --- a/lib/mergeset/table.go +++ b/lib/mergeset/table.go @@ -75,10 +75,12 @@ type Table struct { // aligned to 8 bytes on 32-bit architectures. // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/212 - activeMerges uint64 - mergesCount uint64 - itemsMerged uint64 - assistedMerges uint64 + activeMerges uint64 + mergesCount uint64 + itemsMerged uint64 + assistedMerges uint64 + itemsAdded uint64 + itemsAddedSizeBytes uint64 mergeIdx uint64 @@ -396,10 +398,12 @@ func (tb *Table) Path() string { // TableMetrics contains essential metrics for the Table. type TableMetrics struct { - ActiveMerges uint64 - MergesCount uint64 - ItemsMerged uint64 - AssistedMerges uint64 + ActiveMerges uint64 + MergesCount uint64 + ItemsMerged uint64 + AssistedMerges uint64 + ItemsAdded uint64 + ItemsAddedSizeBytes uint64 PendingItems uint64 @@ -430,6 +434,8 @@ func (tb *Table) UpdateMetrics(m *TableMetrics) { m.MergesCount += atomic.LoadUint64(&tb.mergesCount) m.ItemsMerged += atomic.LoadUint64(&tb.itemsMerged) m.AssistedMerges += atomic.LoadUint64(&tb.assistedMerges) + m.ItemsAdded += atomic.LoadUint64(&tb.itemsAdded) + m.ItemsAddedSizeBytes += atomic.LoadUint64(&tb.itemsAddedSizeBytes) m.PendingItems += uint64(tb.rawItems.Len()) @@ -464,6 +470,12 @@ func (tb *Table) AddItems(items [][]byte) error { if err := tb.rawItems.addItems(tb, items); err != nil { return fmt.Errorf("cannot insert data into %q: %w", tb.path, err) } + atomic.AddUint64(&tb.itemsAdded, uint64(len(items))) + n := 0 + for _, item := range items { + n += len(item) + } + atomic.AddUint64(&tb.itemsAddedSizeBytes, uint64(n)) return nil }