Commit graph

6661 commits

Author SHA1 Message Date
Aliaksandr Valialkin
3dacdcb707
lib/storage: optimize BenchmarkIndexDBGetTSIDs()
- Sort MetricName tags only once before the benchmark loop.
- Obtain indexSearch per each benchmark loop in order to give a chance for background merge
  for the recently created parts
2023-07-13 21:56:53 -07:00
Aliaksandr Valialkin
443661a5da
lib/storage: properly free up resources from newTestStorage() by calling stopTestStorage() 2023-07-13 17:13:24 -07:00
Aliaksandr Valialkin
71f3898f84
docs/CHANGELOG.md: refer to the commit 7094fa38bc 2023-07-13 16:14:28 -07:00
Aliaksandr Valialkin
7094fa38bc
lib/storage: switch from global to per-day index for MetricName -> TSID mapping
Previously all the newly ingested time series were registered in global `MetricName -> TSID` index.
This index was used during data ingestion for locating the TSID (internal series id)
for the given canonical metric name (the canonical metric name consists of metric name plus all its labels sorted by label names).

The `MetricName -> TSID` index is stored on disk in order to make sure that the data
isn't lost on VictoriaMetrics restart or unclean shutdown.

The lookup in this index is relatively slow, since VictoriaMetrics needs to read the corresponding
data block from disk, unpack it, put the unpacked block into `indexdb/dataBlocks` cache,
and then search for the given `MetricName -> TSID` entry there. So VictoriaMetrics
uses in-memory cache for speeding up the lookup for active time series.
This cache is named `storage/tsid`. If this cache capacity is enough for all the currently ingested
active time series, then VictoriaMetrics works fast, since it doesn't need to read the data from disk.

VictoriaMetrics starts reading data from `MetricName -> TSID` on-disk index in the following cases:

- If `storage/tsid` cache capacity isn't enough for active time series.
  Then just increase available memory for VictoriaMetrics or reduce the number of active time series
  ingested into VictoriaMetrics.

- If new time series is ingested into VictoriaMetrics. In this case it cannot find
  the needed entry in the `storage/tsid` cache, so it needs to consult on-disk `MetricName -> TSID` index,
  since it doesn't know that the index has no the corresponding entry too.
  This is a typical event under high churn rate, when old time series are constantly substituted
  with new time series.

Reading the data from `MetricName -> TSID` index is slow, so inserts, which lead to reading this index,
are counted as slow inserts, and they can be monitored via `vm_slow_row_inserts_total` metric exposed by VictoriaMetrics.

Prior to this commit the `MetricName -> TSID` index was global, e.g. it contained entries sorted by `MetricName`
for all the time series ever ingested into VictoriaMetrics during the configured -retentionPeriod.
This index can become very large under high churn rate and long retention. VictoriaMetrics
caches data from this index in `indexdb/dataBlocks` in-memory cache for speeding up index lookups.
The `indexdb/dataBlocks` cache may occupy significant share of available memory for storing
recently accessed blocks at `MetricName -> TSID` index when searching for newly ingested time series.

This commit switches from global `MetricName -> TSID` index to per-day index. This allows significantly
reducing the amounts of data, which needs to be cached in `indexdb/dataBlocks`, since now VictoriaMetrics
consults only the index for the current day when new time series is ingested into it.

The downside of this change is increased indexdb size on disk for workloads without high churn rate,
e.g. with static time series, which do no change over time, since now VictoriaMetrics needs to store
identical `MetricName -> TSID` entries for static time series for every day.

This change removes an optimization for reducing CPU and disk IO spikes at indexdb rotation,
since it didn't work correctly - see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1401 .

At the same time the change fixes the issue, which could result in lost access to time series,
which stop receving new samples during the first hour after indexdb rotation - see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2698

The issue with the increased CPU and disk IO usage during indexdb rotation will be addressed
in a separate commit according to https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1401#issuecomment-1553488685

This is a follow-up for 1f28b46ae9
2023-07-13 16:07:30 -07:00
Aliaksandr Valialkin
3b50b94f7a
lib/storage: fix possible test failure in TestStorageAddRowsConcurrent
The number of parts in the snapshot partition may be zero if concurrent goroutine just
started creating new partition, but didn't put data into it yet when the current
goroutine made a snapshot.
2023-07-13 15:03:45 -07:00
Aliaksandr Valialkin
4ba19f6b32
lib/mergeset: simplify fulsuhInmemoryParts() a bit 2023-07-13 12:33:30 -07:00
Aliaksandr Valialkin
8eeaf9b1f6
docs/CHANGELOG.md: clarify the description of the bugfix at 177a0c1ca9
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4555
2023-07-13 12:20:03 -07:00
Aliaksandr Valialkin
9ae5a49787
Revert "make: add goimports task (#4582)"
This reverts commit 20b18e9feb.

Reason for revert: running goimports on `make check-all` introduces the following issues:

- It runs only on modified files, which weren't commited yet into git repository.
  This means the formatting for the remaining files becomes different comparing to the formatting
  for the changed files. This also means that the goimports has no any effect
  at github actions and when the changed code is already commited to git repository.
- `gomiports` performs formatting in the same way as gofmt, so `make fmt` becomes unnecessary.
  But when `gofmt` is substituted with `goimports`, then it performs unnecessary formatting for *.qtpl.go files.
  It is possible to make a hack, which will prepare a list of all the *.go files at lib/ and app/
  without the *.qtpl.go files, and then feed this list to `goimports`, but this looks too fragile
  for the task of just fixing the ordering of Go imports.

So it is better to leave source code formatting as is with `gofmt`, while manually fixing improper ordering
of Go import from time to time in dedicated commits until better solution arises.
2023-07-13 12:03:48 -07:00
Aliaksandr Valialkin
4f6dc25c71
app/vmalert: silence golagci-lint at TestAlertingRule_Template
Add a break if gotAlert is nil

This removes the following golangci-lint warning:

app/vmalert/alerting_test.go:868:8: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
				if gotAlert == nil {
				   ^
2023-07-13 11:40:44 -07:00
Aliaksandr Valialkin
a79e53d82a
lib/logstorage: fix TestValuesEncoder() on 32-bit architectures 2023-07-13 11:27:13 -07:00
Dmytro Kozlov
c76084b529
app/vmctl: fix panic --remote-read-filter-time-start flag not defined (#4605)
* app/vmctl: fix panic `--remote-read-filter-time-start` flag not defined

* app/vmctl: update CHANGELOG.md

---------

Co-authored-by: Nikolay <nik@victoriametrics.com>
2023-07-13 17:14:43 +02:00
Yury Molodov
3bb3ad9991
feat: add link to MetricsQL (#4562) (#4608) 2023-07-13 17:13:54 +02:00
Dmytro Kozlov
177a0c1ca9
app/vmctl: fix issue with adding many seconds (#4617)
* app/vmctl: fix issue with adding many seconds

* app/vmagent: add CHANGELOG.md
2023-07-13 17:11:48 +02:00
Roman Khavronenko
cbc28ccdb2
vmalert: check for negative offset for missed rounds (#4628)
It could happen for low evaluation intervals and irregular
delays during execution that evaluation time would get
a negative offset. This could result into cumulative
discrepancy between the actual time and evaluation time for rules.

Signed-off-by: hagen1778 <roman@victoriametrics.com>
2023-07-13 17:11:22 +02:00
Dmytro Kozlov
79c42814cf
lib/logstorage: fix panic (#4620) 2023-07-13 09:53:41 +02:00
Zakhar Bessarab
20b18e9feb
make: add goimports task (#4582)
* make: add goimports task

Adds task to fix imports formatting implace.
Formats imports into:
- native library
- external libraries
- local packages based on github.com/VictoriaMetrics/VictoriaMetrics prefix

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* make: add goimports install task

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* make: run goimports only for changed files

Applying goimports to all existing files would create a lot of problems with cherry-picking changes between different branches used for development. To avoid this it was decided to only run goimports on changed files to fix formatting gradually.

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* make: update goimports to run on all changed files

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

---------

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
2023-07-13 09:25:00 +02:00
Alexander Marshalov
41b58a8e55
fixed typo (#4622)
Signed-off-by: Alexander Marshalov <_@marshalov.org>
2023-07-12 18:14:41 +02:00
Alexander Marshalov
0b9fadb02c
add info about using stream aggregation as statsd alternative (#4600) (#4621)
Signed-off-by: Alexander Marshalov <_@marshalov.org>
2023-07-12 16:53:25 +02:00
Aliaksandr Valialkin
2b9e288a03
docs/VictoriaLogs/FAQ.md: small fixes 2023-07-12 01:10:32 -07:00
Aliaksandr Valialkin
30cdcc751d
all: update Go builder from 1.20.5 to 1.20.6
See https://github.com/golang/go/issues?q=milestone%3AGo1.20.6+label%3ACherryPickApproved
2023-07-12 00:59:59 -07:00
Aliaksandr Valialkin
0953e48c3a
docs/keyConcepts.md: cosmetic fixes after b67bd156d5 2023-07-12 00:28:44 -07:00
Aliaksandr Valialkin
dc5e50451d
docs/VictoriaLogs: add FAQ 2023-07-12 00:25:05 -07:00
Aliaksandr Valialkin
a46c0146c9
docs/VictoriaLogs/README.md: make it clear that VictoriaLogs is open source 2023-07-12 00:25:04 -07:00
Alexander Marshalov
e3bb0afe82
follow up for #4612 and #4584 (#4614)
Signed-off-by: Alexander Marshalov <_@marshalov.org>
2023-07-11 13:59:46 +04:00
Zakhar Bessarab
195b9386cb
doc: fix image src after b67bd156 (#4612)
Followup for b67bd156d5

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
2023-07-11 13:19:05 +04:00
Alexander Marshalov
b67bd156d5
added info about search.latencyOffset to key concepts (#4567) (#4584)
Signed-off-by: Alexander Marshalov <_@marshalov.org>
Co-authored-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
2023-07-11 09:57:36 +02:00
Aliaksandr Valialkin
a0ff5c2627
docs/VictoriaLogs: make more prominent the information about returned log fields in query responses
Thanks to @candlerb for suggestions on how to improve VictoriaLogs docs
at https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4609#issuecomment-1629758426
2023-07-10 15:01:20 -07:00
Dmytro Kozlov
a0a76d7b48
app/vmctl: remove undefined flag from the documentation. See: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4552. (#4606) 2023-07-10 19:20:31 +04:00
Aliaksandr Valialkin
a360fd5f71
app/{vmselect,vlselect}: run make vmui-update vmui-logs-update 2023-07-09 12:43:48 -07:00
Aliaksandr Valialkin
7d45fc1f99
app/vmselect/netstorage: follow-up after 173ccf4333
- Clarify docs about -replicationFactor command-line flag at vmselect
- Clarify description for -replicationFactor and -search.skipSlowReplicas command-line flags
- Fix the logic for returning responses if -search.skipSlowReplicas command-line flag
  is enabled. The logic was broken in the 173ccf4333,
  so it could return responses only if some of vmstorage nodes return error,
  while it should return when query results are successfully collected from more than
  (len(storageNodes) - replicationFactor) vmstorage nodes.

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1207
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/711
2023-07-09 12:40:06 -07:00
Roman Khavronenko
fb03762d4d
vmselect: introduce search.skipSlowReplicas cmd-line flag (#4538)
* vmselect: introduce `search.skipSlowReplicas` cmd-line flag

vmselect has two logical conditions during request processing when
`-replicationFactor` cmd-line flag is set:
1. If at least `len(storageNodes) - replicationFactor` responded, it could skip
waiting for the rest of nodes to respond. This could lead to problems described
here https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1207.
2. Mark response as partial if less than `len(storageNodes) - replicationFactor` responded
without an error.

The P1 showed itself error-prone and became the main reason why
`-replicationFactor` wasn't recommended to use at vmselect level.
However, this optimization could be still very useful in situations
when there are slow and fast replicas in cluster.

But P2 remains viable and important conditionless.
Hiding P1 behind the feature-flag `search.skipSlowReplicas`
should make `-replicationFactor` flag usable again. And let users
choose whether they want P1 to be respected.

Related issues
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1207
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/711

Signed-off-by: hagen1778 <roman@victoriametrics.com>

* docs: update changelog

Signed-off-by: hagen1778 <roman@victoriametrics.com>

---------

Signed-off-by: hagen1778 <roman@victoriametrics.com>
2023-07-09 12:30:06 -07:00
Aliaksandr Valialkin
45cec4728c
docs/Single-server-VictoriaMetrics.md: mention how to use Prometheus config file with unsupported options
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4274
2023-07-09 11:28:36 -07:00
Aliaksandr Valialkin
9fb553aafe
docs/vmalert.md: run make docs-sync after 7c8a215a7c 2023-07-09 11:28:02 -07:00
Aliaksandr Valialkin
fe57e99a5b
docs/VictoriaLogs: small clarifications 2023-07-09 11:00:49 -07:00
Zakhar Bessarab
51a9cc9783
docs: make httpAuth.* flags description less ambiguous (#4588)
* docs: make `httpAuth.*` flags description less ambiguous

Currently, it may confuse users whether `httpAuth.*` flags are used by HTTP client or server configuration(see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4586 for example).

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

* docs: fix a typo

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>

---------

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
2023-07-07 13:50:13 +02:00
Max Golionko
759a20d374
ci: fix sandbox update job (#4549)
Prevent sandbox deploy job run if tag name is empty.
2023-07-07 11:49:25 +02:00
Haleygo
20e7db47ee
vmselect: fix result in Prometheus query when time is small (#4578)
vmselect: fix result in Prometheus query when time is small

Co-authored-by: Roman Khavronenko <roman@victoriametrics.com>
2023-07-07 11:48:05 +02:00
Haleygo
bca8ae034f
vmalert:fix query request using rfc3339 format (#4577)
vmalert: consistently use time.RFC3339 format for time in queries

Co-authored-by: hagen1778 <roman@victoriametrics.com>
2023-07-07 10:39:25 +02:00
Aliaksandr Valialkin
1df3e548c1
vendor: run make vendor-update 2023-07-07 00:04:32 -07:00
Artem Navoiev
8f1f80c4f8
update logo width in cluster doc to 300
Signed-off-by: Artem Navoiev <tenmozes@gmail.com>
2023-07-06 23:16:01 -07:00
Aliaksandr Valialkin
d32780de5c
docs/vmgateway.md: update -help output 2023-07-06 23:13:07 -07:00
Aliaksandr Valialkin
5c36935b8b
docs/Cluster-VictoriaMetrics.md: update -help output 2023-07-06 23:13:07 -07:00
Aliaksandr Valialkin
8a45a2e770
docs/vmbackupmanager.md: update -help output 2023-07-06 23:13:06 -07:00
Aliaksandr Valialkin
c6bf60e2cc
docs/vmrestore.md: update -help output 2023-07-06 23:13:06 -07:00
Aliaksandr Valialkin
02a81da3ca
docs/vmbackup.md: update -help output 2023-07-06 23:13:05 -07:00
Aliaksandr Valialkin
81f5f118ce
docs/vmauth.md: update -help output 2023-07-06 23:13:05 -07:00
Aliaksandr Valialkin
9fa8e3895a
docs/vmalert.md: update -help output 2023-07-06 23:13:04 -07:00
Aliaksandr Valialkin
009af1ce90
docs/vmagent.md: update -help output 2023-07-06 23:13:04 -07:00
Aliaksandr Valialkin
d856fa73a2
docs/Single-server-VictoriaMetrics.md: update -help output 2023-07-06 23:13:03 -07:00
Roman Khavronenko
7c8a215a7c
vmalert: allow disabling of step param attached to instant queries (#4574)
vmalert: allow disabling of `step` param attached to instant queries

This might be useful for using vmalert with datasources that to not support this param,
unlike VictoriaMetrics.

See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4573

Signed-off-by: hagen1778 <roman@victoriametrics.com>
2023-07-07 07:44:34 +02:00