Skip to content

Commit

Permalink
[7.x] Include date in data stream backing index names (elastic#66307)
Browse files Browse the repository at this point in the history
  • Loading branch information
danhermann authored Dec 15, 2020
1 parent 4c8c01d commit 39c09f9
Show file tree
Hide file tree
Showing 49 changed files with 557 additions and 340 deletions.
27 changes: 15 additions & 12 deletions docs/reference/data-streams/change-mappings-and-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,9 @@ The following get data stream API request retrieves information about
GET /_data_stream/my-data-stream
----

The API returns the following response. Note the `indices` property contains an
array of the stream's current backing indices. The first item in the array
contains information about the stream's oldest backing index,
`.ds-my-data-stream-000001`.
The response's `indices` property contains an array of the stream's current
backing indices. The first item in the array contains information about the
stream's oldest backing index.

[source,console-result]
----
Expand All @@ -562,11 +561,11 @@ contains information about the stream's oldest backing index,
},
"indices": [
{
"index_name": ".ds-my-data-stream-000001", <1>
"index_name": ".ds-my-data-stream-2099.03.07-000001", <1>
"index_uuid": "Gpdiyq8sRuK9WuthvAdFbw"
},
{
"index_name": ".ds-my-data-stream-000002",
"index_name": ".ds-my-data-stream-2099.03.08-000002",
"index_uuid": "_eEfRrFHS9OyhqWntkgHAQ"
}
],
Expand All @@ -580,29 +579,33 @@ contains information about the stream's oldest backing index,
----
// TESTRESPONSE[s/"index_uuid": "Gpdiyq8sRuK9WuthvAdFbw"/"index_uuid": $body.data_streams.0.indices.0.index_uuid/]
// TESTRESPONSE[s/"index_uuid": "_eEfRrFHS9OyhqWntkgHAQ"/"index_uuid": $body.data_streams.0.indices.1.index_uuid/]
// TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.07-000001"/"index_name": $body.data_streams.0.indices.0.index_name/]
// TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.08-000002"/"index_name": $body.data_streams.0.indices.1.index_name/]
// TESTRESPONSE[s/"status": "GREEN"/"status": "YELLOW"/]

<1> First item in the `indices` array for `my-data-stream`. This
item contains information about the stream's oldest backing index,
`.ds-my-data-stream-000001`.
<1> First item in the `indices` array for `my-data-stream`. This item contains
information about the stream's oldest backing index,
`.ds-my-data-stream-2099.03.07-000001`.

The following <<docs-reindex,reindex API>> request copies documents from
`.ds-my-data-stream-000001` to `new-data-stream`. Note the request's `op_type`
is `create`.
`.ds-my-data-stream-2099.03.07-000001` to `new-data-stream`. The request's
`op_type` is `create`.

[source,console]
----
POST /_reindex
{
"source": {
"index": ".ds-my-data-stream-000001"
"index": ".ds-my-data-stream-2099.03.07-000001"
},
"dest": {
"index": "new-data-stream",
"op_type": "create"
}
}
----
// TEST[setup:my_index]
// TEST[s/.ds-my-data-stream-2099.03.07-000001/my-index-000001/]
--
+
You can also use a query to reindex only a subset of documents with each
Expand Down
9 changes: 5 additions & 4 deletions docs/reference/data-streams/data-streams.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ convention:

[source,text]
----
.ds-<data-stream>-<generation>
.ds-<data-stream>-<yyyy.MM.dd>-<generation>
----

Backing indices with a higher generation contain more recent data. For example,
the `web-server-logs` data stream has a generation of `34`. The stream's most
recent backing index is named `.ds-web-server-logs-000034`.
`<yyyy.MM.dd>` is the backing index's creation date. Backing indices with a
higher generation contain more recent data. For example, the `web-server-logs`
data stream has a generation of `34`. The stream's most recent backing index,
created on 7 March 2099, is named `.ds-web-server-logs-2099.03.07-000034`.

Some operations, such as a <<indices-shrink-index,shrink>> or
<<snapshots-restore-snapshot,restore>>, can change a backing index's name.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/data-streams/set-up-a-data-stream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ name must match one of your template's index patterns.
----
POST /my-data-stream/_doc/
{
"@timestamp": "2020-12-06T11:04:05.000Z",
"@timestamp": "2099-03-07T11:04:05.000Z",
"user": {
"id": "vlb44hny"
},
Expand Down
47 changes: 30 additions & 17 deletions docs/reference/data-streams/use-a-data-stream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ POST /my-data-stream/_rollover/
PUT /my-data-stream/_create/bfspvnIBr7VVZlfp2lqX?refresh=wait_for
{
"@timestamp": "2020-12-07T11:06:07.000Z",
"@timestamp": "2099-03-08T11:06:07.000Z",
"user": {
"id": "yWIumJd7"
},
Expand Down Expand Up @@ -61,7 +61,7 @@ To add an individual document, use the <<docs-index_,index API>>.
----
POST /my-data-stream/_doc/
{
"@timestamp": "2020-12-07T11:06:07.000Z",
"@timestamp": "2099-03-08T11:06:07.000Z",
"user": {
"id": "8a4f500d"
},
Expand All @@ -81,11 +81,11 @@ Only `create` actions are supported.
----
PUT /my-data-stream/_bulk?refresh
{"create":{ }}
{ "@timestamp": "2020-12-08T11:04:05.000Z", "user": { "id": "vlb44hny" }, "message": "Login attempt failed" }
{ "@timestamp": "2099-03-08T11:04:05.000Z", "user": { "id": "vlb44hny" }, "message": "Login attempt failed" }
{"create":{ }}
{ "@timestamp": "2020-12-08T11:06:07.000Z", "user": { "id": "8a4f500d" }, "message": "Login successful" }
{ "@timestamp": "2099-03-08T11:06:07.000Z", "user": { "id": "8a4f500d" }, "message": "Login successful" }
{"create":{ }}
{ "@timestamp": "2020-12-09T11:07:08.000Z", "user": { "id": "l7gk7f82" }, "message": "Logout successful" }
{ "@timestamp": "2099-03-09T11:07:08.000Z", "user": { "id": "l7gk7f82" }, "message": "Logout successful" }
----

[discrete]
Expand Down Expand Up @@ -137,8 +137,10 @@ index API request>> directly to the index:

[source,console]
----
POST /.ds-my-data-stream-000001/_open/
POST /.ds-my-data-stream-2099.03.07-000001/_open/
----
// TEST[setup:my_index]
// TEST[s/.ds-my-data-stream-2099.03.07-000001/my-index-000001/]

To re-open all closed backing indices for a data stream, submit an open index
API request to the stream:
Expand All @@ -163,13 +165,13 @@ stream.
----
PUT /_bulk?refresh=wait_for
{"create":{"_index" : "archive_1"}}
{ "@timestamp": "2020-12-08T11:04:05.000Z" }
{ "@timestamp": "2099-03-08T11:04:05.000Z" }
{"create":{"_index" : "archive_2"}}
{ "@timestamp": "2020-12-08T11:06:07.000Z" }
{ "@timestamp": "2099-03-08T11:06:07.000Z" }
{"create":{"_index" : "archive_2"}}
{ "@timestamp": "2020-12-09T11:07:08.000Z" }
{ "@timestamp": "2099-03-09T11:07:08.000Z" }
{"create":{"_index" : "archive_2"}}
{ "@timestamp": "2020-12-09T11:07:08.000Z" }
{ "@timestamp": "2099-03-09T11:07:08.000Z" }
POST /_aliases
{
Expand Down Expand Up @@ -288,14 +290,14 @@ Response:
"max_score": 0.2876821,
"hits": [
{
"_index": ".ds-my-data-stream-000003", <1>
"_index": ".ds-my-data-stream-2099.03.08-000003", <1>
"_type": "_doc",
"_id": "bfspvnIBr7VVZlfp2lqX", <2>
"_seq_no": 0, <3>
"_primary_term": 1, <4>
"_score": 0.2876821,
"_source": {
"@timestamp": "2020-12-07T11:06:07.000Z",
"@timestamp": "2099-03-08T11:06:07.000Z",
"user": {
"id": "yWIumJd7"
},
Expand All @@ -308,6 +310,7 @@ Response:
----
// TESTRESPONSE[s/"took": 20/"took": $body.took/]
// TESTRESPONSE[s/"max_score": 0.2876821/"max_score": $body.hits.max_score/]
// TESTRESPONSE[s/"_index": ".ds-my-data-stream-2099.03.08-000003"/"_index": $body.hits.hits.0._index/]
// TESTRESPONSE[s/"_score": 0.2876821/"_score": $body.hits.hits.0._score/]

<1> Backing index containing the matching document
Expand All @@ -320,22 +323,29 @@ To update the document, use an <<docs-index_,index API>> request with valid

[source,console]
----
PUT /.ds-my-data-stream-000003/_doc/bfspvnIBr7VVZlfp2lqX?if_seq_no=0&if_primary_term=1
PUT /.ds-my-data-stream-2099-03-08-000003/_doc/bfspvnIBr7VVZlfp2lqX?if_seq_no=0&if_primary_term=1
{
"@timestamp": "2020-12-07T11:06:07.000Z",
"@timestamp": "2099-03-08T11:06:07.000Z",
"user": {
"id": "8a4f500d"
},
"message": "Login successful"
}
----
// TEST[setup:my_index]
// TEST[s/.ds-my-data-stream-2099.03.08-000003/my-index-000001/]
// TEST[s/bfspvnIBr7VVZlfp2lqX/1/]
// TEST[s/if_seq_no=0/if_seq_no=1/]

To delete the document, use the <<docs-delete,delete API>>:

[source,console]
----
DELETE /.ds-my-data-stream-000003/_doc/bfspvnIBr7VVZlfp2lqX
DELETE /.ds-my-data-stream-2099.03.08-000003/_doc/bfspvnIBr7VVZlfp2lqX
----
// TEST[setup:my_index]
// TEST[s/.ds-my-data-stream-2099.03.08-000003/my-index-000001/]
// TEST[s/bfspvnIBr7VVZlfp2lqX/1/]

To delete or update multiple documents with a single request, use the
<<docs-bulk,bulk API>>'s `delete`, `index`, and `update` actions. For `index`
Expand All @@ -345,7 +355,10 @@ actions, include valid <<bulk-optimistic-concurrency-control,`if_seq_no` and
[source,console]
----
PUT /_bulk?refresh
{ "index": { "_index": ".ds-my-data-stream-000003", "_id": "bfspvnIBr7VVZlfp2lqX", "if_seq_no": 0, "if_primary_term": 1 } }
{ "@timestamp": "2020-12-07T11:06:07.000Z", "user": { "id": "8a4f500d" }, "message": "Login successful" }
{ "index": { "_index": ".ds-my-data-stream-2099.03.08-000003", "_id": "bfspvnIBr7VVZlfp2lqX", "if_seq_no": 0, "if_primary_term": 1 } }
{ "@timestamp": "2099-03-08T11:06:07.000Z", "user": { "id": "8a4f500d" }, "message": "Login successful" }
----
// TEST[setup:my_index]
// TEST[s/.ds-my-data-stream-2099.03.08-000003/my-index-000001/]
// TEST[s/bfspvnIBr7VVZlfp2lqX/1/]

33 changes: 18 additions & 15 deletions docs/reference/ilm/ilm-tutorial.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ indices.
. <<ilm-gs-check-progress, Verify indices are moving through the lifecycle phases>>
as expected.

For an introduction to rolling indices, see <<index-rollover>>.
For an introduction to rolling indices, see <<index-rollover>>.

IMPORTANT: When you enable {ilm} for {beats} or the {ls} {es} output plugin,
lifecycle policies are set up automatically.
Expand All @@ -46,17 +46,17 @@ or the {ilm-init} APIs.

A lifecycle policy specifies the phases in the index lifecycle
and the actions to perform in each phase. A lifecycle can have up to four phases:
`hot`, `warm`, `cold`, and `delete`.
`hot`, `warm`, `cold`, and `delete`.

For example, you might define a `timeseries_policy` that has two phases:
* A `hot` phase that defines a rollover action to specify that an index rolls over when it

* A `hot` phase that defines a rollover action to specify that an index rolls over when it
reaches either a `max_size` of 50 gigabytes or a `max_age` of 30 days.
* A `delete` phase that sets `min_age` to remove the index 90 days after rollover.
Note that this value is relative to the rollover time, not the index creation time.
Note that this value is relative to the rollover time, not the index creation time.

You can create the policy through {kib} or with the
<<ilm-put-lifecycle, put policy>> API.
You can create the policy through {kib} or with the
<<ilm-put-lifecycle, put policy>> API.
To create the policy from {kib}, open the menu and go to *Stack Management >
Index Lifecycle Policies*. Click *Index Lifecycle Policies*.

Expand Down Expand Up @@ -154,8 +154,8 @@ request automatically creates a corresponding data stream with a single backing
{es} automatically indexes the request's documents into this backing index, which also
acts as the stream's <<data-stream-write-index,write index>>.

For example, the following request creates the `timeseries` data stream and the first generation
backing index called `.ds-timeseries-000001`.
For example, the following request creates the `timeseries` data stream and the
first generation backing index called `.ds-timeseries-2099.03.08-000001`.

[source,console]
-----------------------
Expand All @@ -170,10 +170,13 @@ POST timeseries/_doc

When a rollover condition in the lifecycle policy is met, the `rollover` action:

* Creates the second generation backing index, named `.ds-timeseries-000002`.
Because it is a backing index of the `timeseries` data stream, the configuration from the `timeseries_template` index template is applied to the new index.
* As it is the latest generation index of the `timeseries` data stream, the newly created
backing index `.ds-timeseries-000002` becomes the data stream's write index.
* Creates the second generation backing index, named
`.ds-timeseries-2099.03.08-000002`. Because it is a backing index of the
`timeseries` data stream, the configuration from the `timeseries_template` index
template is applied to the new index.
* As it is the latest generation index of the `timeseries` data stream, the
newly created backing index `.ds-timeseries-2099.03.08-000002` becomes the data
stream's write index.

This process repeats each time a rollover condition is met.
You can search across all of the data stream's backing indices, managed by the `timeseries_policy`,
Expand Down Expand Up @@ -211,8 +214,8 @@ is met.
--------------------------------------------------
{
"indices": {
".ds-timeseries-000001": {
"index": ".ds-timeseries-000001",
".ds-timeseries-2099.03.07-000001": {
"index": ".ds-timeseries-2099.03.07-000001",
"managed": true,
"policy": "timeseries_policy", <1>
"lifecycle_date_millis": 1538475653281,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/reference/indices/forcemerge.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ its shards can be force-merged to a single segment.

[source,console]
--------------------------------------------------
POST /.ds-logs-000001/_forcemerge?max_num_segments=1
POST /.ds-my-data-stream-2099.03.07-000001/_forcemerge?max_num_segments=1
--------------------------------------------------
// TEST[setup:my_index]
// TEST[s/.ds-logs-000001/my-index-000001/]
// TEST[s/.ds-my-data-stream-2099.03.07-000001/my-index-000001/]

This can be a good idea because single-segment shards can sometimes use simpler
and more efficient data structures to perform searches.
13 changes: 8 additions & 5 deletions docs/reference/indices/get-data-stream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ PUT /_data_stream/my-data-stream
POST /my-data-stream/_rollover
PUT /_data_stream/my-data-stream_two
PUT /_data_stream/my-data-stream-two
----
// TESTSETUP
////
Expand Down Expand Up @@ -207,11 +207,11 @@ The API returns the following response:
},
"indices": [
{
"index_name": ".ds-my-data-stream-000001",
"index_name": ".ds-my-data-stream-2099.03.07-000001",
"index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"
},
{
"index_name": ".ds-my-data-stream-000002",
"index_name": ".ds-my-data-stream-2099.03.08-000002",
"index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"
}
],
Expand All @@ -225,13 +225,13 @@ The API returns the following response:
"hidden": false
},
{
"name": "my-data-stream_two",
"name": "my-data-stream-two",
"timestamp_field": {
"name": "@timestamp"
},
"indices": [
{
"index_name": ".ds-my-data-stream_two-000001",
"index_name": ".ds-my-data-stream-two-2099.03.08-000001",
"index_uuid": "3liBu2SYS5axasRt6fUIpA"
}
],
Expand All @@ -247,7 +247,10 @@ The API returns the following response:
]
}
----
// TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.07-000001"/"index_name": $body.data_streams.0.indices.0.index_name/]
// TESTRESPONSE[s/"index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"/"index_uuid": $body.data_streams.0.indices.0.index_uuid/]
// TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.08-000002"/"index_name": $body.data_streams.0.indices.1.index_name/]
// TESTRESPONSE[s/"index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"/"index_uuid": $body.data_streams.0.indices.1.index_uuid/]
// TESTRESPONSE[s/"index_name": ".ds-my-data-stream-two-2099.03.08-000001"/"index_name": $body.data_streams.1.indices.0.index_name/]
// TESTRESPONSE[s/"index_uuid": "3liBu2SYS5axasRt6fUIpA"/"index_uuid": $body.data_streams.1.indices.0.index_uuid/]
// TESTRESPONSE[s/"status": "GREEN"/"status": "YELLOW"/]
4 changes: 3 additions & 1 deletion docs/reference/indices/resolve.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ The API returns the following response:
{
"name": "foo",
"backing_indices": [
".ds-foo-000001"
".ds-foo-2099.03.07-000001"
],
"timestamp_field": "@timestamp"
}
]
}
----
// TESTRESPONSE[s/remoteCluster1:/remotecluster-/]
// TESTRESPONSE[s/.ds-foo-2099.03.07-000001/$body.data_streams.0.backing_indices.0/]

<1> All indices matching the supplied names or expressions
<2> All aliases matching the supplied names or expressions
<3> All data streams matching the supplied names or expressions
Loading

0 comments on commit 39c09f9

Please sign in to comment.