From ed5b45883440692fcc45ff781c1a02cfe6d66ce5 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Thu, 12 Nov 2020 13:53:34 -0600 Subject: [PATCH 1/7] docs for data stream mirgration API --- .../data-streams/data-stream-apis.asciidoc | 5 +- .../indices/migrate-to-data-stream.asciidoc | 61 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 docs/reference/indices/migrate-to-data-stream.asciidoc diff --git a/docs/reference/data-streams/data-stream-apis.asciidoc b/docs/reference/data-streams/data-stream-apis.asciidoc index 04a5a281c222c..b18965162670c 100644 --- a/docs/reference/data-streams/data-stream-apis.asciidoc +++ b/docs/reference/data-streams/data-stream-apis.asciidoc @@ -7,6 +7,7 @@ The following APIs are available for managing <>: * <> * <> * <> +* <> * <> For concepts and tutorials, see <>. @@ -17,4 +18,6 @@ include::{es-repo-dir}/indices/delete-data-stream.asciidoc[] include::{es-repo-dir}/indices/get-data-stream.asciidoc[] -include::{es-repo-dir}/indices/data-stream-stats.asciidoc[] \ No newline at end of file +include::{es-repo-dir}/indices/migrate-to-data-stream.asciidoc[] + +include::{es-repo-dir}/indices/data-stream-stats.asciidoc[] diff --git a/docs/reference/indices/migrate-to-data-stream.asciidoc b/docs/reference/indices/migrate-to-data-stream.asciidoc new file mode 100644 index 0000000000000..2ee6636a88e5c --- /dev/null +++ b/docs/reference/indices/migrate-to-data-stream.asciidoc @@ -0,0 +1,61 @@ +[role="xpack"] +[[indices-migrate-to-data-stream]] +=== Migreat to data stream API +++++ +Migrate to data stream +++++ + +Migrates an existing alias with its indices to a new +<>. + +Data streams require a matching <>. +See <>. + +//// +[source,console] +---- +PUT /_index_template/template +{ + "index_patterns": ["my-logs*"], + "data_stream": { } +} +---- +//// + +[source,console] +---- +PUT /_data_stream/_migrate/my-logs +---- +// TEST[continued] + +//// +[source,console] +----------------------------------- +DELETE /_data_stream/my-logs +DELETE /_index_template/template +----------------------------------- +// TEST[continued] +//// + +[[indices-migrate-to-data-stream-request]] +==== {api-request-title} + +`POST /_data_stream/_migrate/` + +[[indices-migrate-to-data-stream-api-path-params]] +==== {api-path-parms-title} + +``:: ++ +-- +(Required, string) Name of the alias to be migrated to a data stream. The +alias's indices will be hidden and converted to backing indices for the +new data stream. The alias will be removed, and the new data stream will +be named ``. + +Aliases must meet the following criteria to be migrated to a data stream: + +- Must have an index defined as the <> +- Must not have any <> +- Must not have any <> +-- From 684e1d4ccd2f2b0fe4f72e5f2faa359877510401 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Thu, 12 Nov 2020 14:09:39 -0600 Subject: [PATCH 2/7] correct PUT to POST --- docs/reference/indices/migrate-to-data-stream.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/indices/migrate-to-data-stream.asciidoc b/docs/reference/indices/migrate-to-data-stream.asciidoc index 2ee6636a88e5c..20e4533b3fb6f 100644 --- a/docs/reference/indices/migrate-to-data-stream.asciidoc +++ b/docs/reference/indices/migrate-to-data-stream.asciidoc @@ -24,7 +24,7 @@ PUT /_index_template/template [source,console] ---- -PUT /_data_stream/_migrate/my-logs +POST /_data_stream/_migrate/my-logs ---- // TEST[continued] From b6935ccf80270a31d37fe86c02d5f86b44261570 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Thu, 12 Nov 2020 14:30:26 -0600 Subject: [PATCH 3/7] add setup for doc tests --- .../indices/migrate-to-data-stream.asciidoc | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/reference/indices/migrate-to-data-stream.asciidoc b/docs/reference/indices/migrate-to-data-stream.asciidoc index 20e4533b3fb6f..f676ff3bf53b4 100644 --- a/docs/reference/indices/migrate-to-data-stream.asciidoc +++ b/docs/reference/indices/migrate-to-data-stream.asciidoc @@ -14,6 +14,37 @@ See <>. //// [source,console] ---- +POST idx1/_doc/ +{ + "message" : "testing", + "@timestamp" : "2020-01-01" +} + +POST idx2/_doc/ +{ + "message" : "testing2", + "@timestamp" : "2020-01-01" +} + +POST /_aliases +{ + "actions": [ + { + "add": { + "index": "idx1", + "alias": "my-logs", + "is_write_index": true + } + }, + { + "add": { + "index": "idx2", + "alias": "my-logs" + } + } + ] +} + PUT /_index_template/template { "index_patterns": ["my-logs*"], From 0ba8e8aee9cc0ea476253008d419d0e14d8c8584 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Thu, 12 Nov 2020 14:45:26 -0600 Subject: [PATCH 4/7] fix typo --- docs/reference/indices/migrate-to-data-stream.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/indices/migrate-to-data-stream.asciidoc b/docs/reference/indices/migrate-to-data-stream.asciidoc index f676ff3bf53b4..c367a48daf5e8 100644 --- a/docs/reference/indices/migrate-to-data-stream.asciidoc +++ b/docs/reference/indices/migrate-to-data-stream.asciidoc @@ -1,6 +1,6 @@ [role="xpack"] [[indices-migrate-to-data-stream]] -=== Migreat to data stream API +=== Migrate to data stream API ++++ Migrate to data stream ++++ From 31c50e821795f60dd518cc5c8b3b3c171bcf9bd8 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Thu, 12 Nov 2020 14:52:48 -0600 Subject: [PATCH 5/7] additional criteria --- docs/reference/indices/migrate-to-data-stream.asciidoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/reference/indices/migrate-to-data-stream.asciidoc b/docs/reference/indices/migrate-to-data-stream.asciidoc index c367a48daf5e8..660fdbd1e0571 100644 --- a/docs/reference/indices/migrate-to-data-stream.asciidoc +++ b/docs/reference/indices/migrate-to-data-stream.asciidoc @@ -87,6 +87,8 @@ be named ``. Aliases must meet the following criteria to be migrated to a data stream: - Must have an index defined as the <> +- All indices associated with the alias must have a mapping for the +`@timestamp` field of type `date` or `date_nanos` - Must not have any <> - Must not have any <> -- From 2569349ed8ae186ea9d1c93130984b1bfcc78bfd Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Fri, 13 Nov 2020 07:49:26 -0600 Subject: [PATCH 6/7] Update docs/reference/indices/migrate-to-data-stream.asciidoc Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com> --- docs/reference/indices/migrate-to-data-stream.asciidoc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/reference/indices/migrate-to-data-stream.asciidoc b/docs/reference/indices/migrate-to-data-stream.asciidoc index 660fdbd1e0571..196ecf932ce98 100644 --- a/docs/reference/indices/migrate-to-data-stream.asciidoc +++ b/docs/reference/indices/migrate-to-data-stream.asciidoc @@ -5,8 +5,7 @@ Migrate to data stream ++++ -Migrates an existing alias with its indices to a new -<>. +Converts an <> to a <>. Data streams require a matching <>. See <>. From 4c07203ef0d00845307c9ce2c3e341eca42f5f29 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Fri, 13 Nov 2020 07:50:30 -0600 Subject: [PATCH 7/7] Update docs/reference/indices/migrate-to-data-stream.asciidoc Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com> --- .../indices/migrate-to-data-stream.asciidoc | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/reference/indices/migrate-to-data-stream.asciidoc b/docs/reference/indices/migrate-to-data-stream.asciidoc index 196ecf932ce98..eee925c1d44d4 100644 --- a/docs/reference/indices/migrate-to-data-stream.asciidoc +++ b/docs/reference/indices/migrate-to-data-stream.asciidoc @@ -78,16 +78,16 @@ DELETE /_index_template/template ``:: + -- -(Required, string) Name of the alias to be migrated to a data stream. The -alias's indices will be hidden and converted to backing indices for the -new data stream. The alias will be removed, and the new data stream will -be named ``. +(Required, string) +Name of the index alias to convert to a data stream. The alias must meet the +following criteria: -Aliases must meet the following criteria to be migrated to a data stream: +- The alias must have a <>. +- All indices for the alias have a `@timestamp` field mapping of a `date` or `date_nanos` field type. +- The alias must not have any <>. +- The alias must not use <>. -- Must have an index defined as the <> -- All indices associated with the alias must have a mapping for the -`@timestamp` field of type `date` or `date_nanos` -- Must not have any <> -- Must not have any <> +If successful, the request removes the alias and creates a data stream with the +same name. The alias's indices become hidden backing indices for the stream. The +alias's write index becomes the stream's write index. --