From 6da5cfa3a8a81d2f2e7e20d3ba92dc8ec898ac48 Mon Sep 17 00:00:00 2001 From: Dmytro Kozlov Date: Thu, 18 May 2023 14:43:35 +0300 Subject: [PATCH] app/vmctl: set default value for --vm-native-step-interval flag (#4327) * app/vmctl: set default value for `--vm-native-step-interval` flag * app/vmctl: update CHANGELOG.md * app/vmctl: update CHANGELOG.md, fix docs * app/vmctl: fix typo * app/vmctl: fix typo --- app/vmctl/README.md | 1 + app/vmctl/flags.go | 1 + app/vmctl/stepper/split_test.go | 49 +++++++++++++++++++++++++++++++++ docs/CHANGELOG.md | 1 + docs/vmctl.md | 1 + 5 files changed, 53 insertions(+) diff --git a/app/vmctl/README.md b/app/vmctl/README.md index 443a63671e..0a5d42fed1 100644 --- a/app/vmctl/README.md +++ b/app/vmctl/README.md @@ -736,6 +736,7 @@ See `./vmctl vm-native --help` for details and full list of flags. Migration in `vm-native` mode takes two steps: 1. Explore the list of the metrics to migrate via `api/v1/label/__name__/values` API; 2. Migrate explored metrics one-by-one. + ``` ./vmctl vm-native \ --vm-native-src-addr=http://127.0.0.1:8481/select/0/prometheus \ # migrate from diff --git a/app/vmctl/flags.go b/app/vmctl/flags.go index 772b02130b..9e6e2d4c65 100644 --- a/app/vmctl/flags.go +++ b/app/vmctl/flags.go @@ -362,6 +362,7 @@ var ( &cli.StringFlag{ Name: vmNativeStepInterval, Usage: fmt.Sprintf("Split export data into chunks. Requires setting --%s. Valid values are '%s','%s','%s','%s'.", vmNativeFilterTimeStart, stepper.StepMonth, stepper.StepDay, stepper.StepHour, stepper.StepMinute), + Value: stepper.StepMonth, }, &cli.BoolFlag{ Name: vmNativeDisableHTTPKeepAlive, diff --git a/app/vmctl/stepper/split_test.go b/app/vmctl/stepper/split_test.go index dec06b18fc..438485d4ae 100644 --- a/app/vmctl/stepper/split_test.go +++ b/app/vmctl/stepper/split_test.go @@ -121,6 +121,55 @@ func Test_splitDateRange(t *testing.T) { }, wantErr: false, }, + { + name: "month chunking with one day time range", + args: args{ + start: "2022-01-03T11:11:11Z", + end: "2022-01-04T12:12:12Z", + granularity: StepMonth, + }, + want: []testTimeRange{ + { + "2022-01-03T11:11:11Z", + "2022-01-04T12:12:12Z", + }, + }, + wantErr: false, + }, + { + name: "month chunking with same day time range", + args: args{ + start: "2022-01-03T11:11:11Z", + end: "2022-01-03T12:12:12Z", + granularity: StepMonth, + }, + want: []testTimeRange{ + { + "2022-01-03T11:11:11Z", + "2022-01-03T12:12:12Z", + }, + }, + wantErr: false, + }, + { + name: "month chunking with one month and two days range", + args: args{ + start: "2022-01-03T11:11:11Z", + end: "2022-02-03T00:00:00Z", + granularity: StepMonth, + }, + want: []testTimeRange{ + { + "2022-01-03T11:11:11Z", + "2022-01-31T23:59:59.999999999Z", + }, + { + "2022-02-01T00:00:00Z", + "2022-02-03T00:00:00Z", + }, + }, + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7b5266ab7a..aaf5bcffdf 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -62,6 +62,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * FEATURE: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): add `created_at` field to the output of `/api/v1/backups` API and `vmbackupmanager backup list` command. See this [doc](https://docs.victoriametrics.com/vmbackupmanager.html#api-methods) for data format details. * FEATURE: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): add commands for locking/unlocking backups against deletion by retention policy. See this [doc](https://docs.victoriametrics.com/vmbackupmanager.html#api-methods) for data format details. * FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): add support for [different time formats](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#timestamp-formats) for `--vm-native-filter-time-start` and `--vm-native-filter-time-end` command-line flags. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4091). +* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): set default value for `--vm-native-step-interval` command-line flag to `month`. This enables [time-based chunking](https://docs.victoriametrics.com/vmctl.html#using-time-based-chunking-of-migration) of data based on monthly step value when using native migration mode. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4309). * BUGFIX: reduce the probability of sudden increase in the number of small parts on systems with small number of CPU cores. * BUGFIX: reduce the possibility of increased CPU usage when data with timestamps older than one hour is ingested into VictoriaMetrics. This reduces spikes for the graph `sum(rate(vm_slow_per_day_index_inserts_total))`. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4258). diff --git a/docs/vmctl.md b/docs/vmctl.md index ccb2f49158..f93057ae1a 100644 --- a/docs/vmctl.md +++ b/docs/vmctl.md @@ -740,6 +740,7 @@ See `./vmctl vm-native --help` for details and full list of flags. Migration in `vm-native` mode takes two steps: 1. Explore the list of the metrics to migrate via `api/v1/label/__name__/values` API; 2. Migrate explored metrics one-by-one. + ``` ./vmctl vm-native \ --vm-native-src-addr=http://127.0.0.1:8481/select/0/prometheus \ # migrate from