Skip to content

Conversation

pmuellr
Copy link
Member

@pmuellr pmuellr commented Aug 29, 2025

Part of elastic/kibana#231200

We realized that when the mappings are updated in a version upgrade, the mappings are in fact updated, but not applied to the current reporting datastream.

To fix this, we'll make a determination in Kibana that we should roll over the data stream if the version in the template does not match the version in the mappings of the datastream. If they match, we don't need to do anything. If they don't match, or the version of the mappings is not in the datastream (from before this PR), we will need to roll over the data stream to apply the new mappings.

To make this happen, we need to add a new field to the mapping _meta, which should match the template version.

references:

To test applying this template over an existing template, you can run Kibana and ES from a local Kibana repo, create a report, then run the ES built from here and the same Kibana. Then roll over the reporting index.

Some details since I was unfamiliar with how to run ES from a local build in this repo:

  • run a build via ./gradlew assemble
  • you'll get distribution/archives/darwin-aarch64-tar/build/distributions/elasticsearch-9.2.0-SNAPSHOT-darwin-aarch64.tar.gz, for example
  • unpack that, and run bin/elasticsearch
  • you'll want to use -E path.data=<path-used-by-previous-ES-run>
  • to use the same config as the ES when run from Kibana's repo, run export ES_PATH_CONF=<path-to-your-kibana-repo/.es/9.2.0/config

Part of elastic/kibana#231200 .

We realized that when the mappings are updated in a version upgrade,
the mappings are in fact updated, but not applied to the current
reporting datastream.

To fix this, we'll make a determination in Kibana that we should roll
over the data stream if the version in the template does not match the
version in the mappings of the datastream.  If they match, we don't need
to do anything.  If they don't match, or the version of the mappings is
not in the datastream (from before this PR), we will need to roll over the
data stream to apply the new mappings.

To make this happen, we need to add a new field to the mapping `_meta`,
which should match the template version.

references:

- https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-meta-field
@pmuellr pmuellr added >non-issue :Data Management/Data streams Data streams and their lifecycles Team:Data Management Meta label for data/management team auto-backport Automatically create backport pull requests when merged v9.1.4 v8.19.4 labels Aug 29, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@pmuellr
Copy link
Member Author

pmuellr commented Sep 2, 2025

@elasticmachine merge upstream

@pmuellr pmuellr merged commit ebb94bd into elastic:main Sep 2, 2025
33 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
9.1 Commit could not be cherrypicked due to conflicts
8.19 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 133846

pmuellr added a commit to pmuellr/elasticsearch that referenced this pull request Sep 2, 2025
…33846)

Part of elastic/kibana#231200 .

We realized that when the mappings are updated in a version upgrade,
the mappings are in fact updated, but not applied to the current
reporting datastream.

To fix this, we'll make a determination in Kibana that we should roll
over the data stream if the version in the template does not match the
version in the mappings of the datastream.  If they match, we don't need
to do anything.  If they don't match, or the version of the mappings is
not in the datastream (from before this PR), we will need to roll over the
data stream to apply the new mappings.

To make this happen, we need to add a new field to the mapping `_meta`,
which should match the template version.

references:

- https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-meta-field

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit ebb94bd)

# Conflicts:
#	x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java
@pmuellr
Copy link
Member Author

pmuellr commented Sep 2, 2025

💚 All backports created successfully

Status Branch Result
9.1
8.19

Questions ?

Please refer to the Backport tool documentation

pmuellr added a commit that referenced this pull request Sep 2, 2025
…134014)

Part of elastic/kibana#231200 .

We realized that when the mappings are updated in a version upgrade,
the mappings are in fact updated, but not applied to the current
reporting datastream.

To fix this, we'll make a determination in Kibana that we should roll
over the data stream if the version in the template does not match the
version in the mappings of the datastream.  If they match, we don't need
to do anything.  If they don't match, or the version of the mappings is
not in the datastream (from before this PR), we will need to roll over the
data stream to apply the new mappings.

To make this happen, we need to add a new field to the mapping `_meta`,
which should match the template version.

references:

- https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-meta-field

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit ebb94bd)

# Conflicts:
#	x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java
pmuellr added a commit that referenced this pull request Sep 3, 2025
…134015)

Part of elastic/kibana#231200 .

We realized that when the mappings are updated in a version upgrade,
the mappings are in fact updated, but not applied to the current
reporting datastream.

To fix this, we'll make a determination in Kibana that we should roll
over the data stream if the version in the template does not match the
version in the mappings of the datastream.  If they match, we don't need
to do anything.  If they don't match, or the version of the mappings is
not in the datastream (from before this PR), we will need to roll over the
data stream to apply the new mappings.

To make this happen, we need to add a new field to the mapping `_meta`,
which should match the template version.

references:

- https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-meta-field

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit ebb94bd)

# Conflicts:
#	x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java
pmuellr added a commit to pmuellr/kibana that referenced this pull request Sep 5, 2025
… changed

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting index template against the `_meta.template_version` value stamped into each backing index's mappings via elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been created with the current index template version, it will roll over the reporting data stream, to ensure future indexing will use the latest mappings.

Startup processing for reporting has changed to apply the current index template mappings to the kibana reporting index, if it exists.  This fixes a problem where a new field added to the index template, however it was not applied, so the field could not reliably used.  The field was `space_id`, which could cause reports in non-default spaces to not appear in the reports list.
pmuellr added a commit to pmuellr/kibana that referenced this pull request Sep 8, 2025
… changed

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting index template against the `_meta.template_version` value stamped into each backing index's mappings via elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been created with the current index template version, it will roll over the reporting data stream, to ensure future indexing will use the latest mappings.

Startup processing for reporting has changed to apply the current index template mappings to the kibana reporting index, if it exists.  This fixes a problem where a new field added to the index template, however it was not applied, so the field could not reliably used.  The field was `space_id`, which could cause reports in non-default spaces to not appear in the reports list.
sarog pushed a commit to portsbuild/elasticsearch that referenced this pull request Sep 11, 2025
…33846) (elastic#134015)

Part of elastic/kibana#231200 .

We realized that when the mappings are updated in a version upgrade,
the mappings are in fact updated, but not applied to the current
reporting datastream.

To fix this, we'll make a determination in Kibana that we should roll
over the data stream if the version in the template does not match the
version in the mappings of the datastream.  If they match, we don't need
to do anything.  If they don't match, or the version of the mappings is
not in the datastream (from before this PR), we will need to roll over the
data stream to apply the new mappings.

To make this happen, we need to add a new field to the mapping `_meta`,
which should match the template version.

references:

- https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-meta-field

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit ebb94bd)

# Conflicts:
#	x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java
pmuellr added a commit to pmuellr/kibana that referenced this pull request Sep 18, 2025
… changed

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting index template against the `_meta.template_version` value stamped into each backing index's mappings via elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been created with the current index template version, it will roll over the reporting data stream, to ensure future indexing will use the latest mappings.

Startup processing for reporting has changed to apply the current index template mappings to the kibana reporting index, if it exists.  This fixes a problem where a new field added to the index template, however it was not applied, so the field could not reliably used.  The field was `space_id`, which could cause reports in non-default spaces to not appear in the reports list.
pmuellr added a commit to pmuellr/kibana that referenced this pull request Sep 18, 2025
… changed

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting index template against the `_meta.template_version` value stamped into each backing index's mappings via elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been created with the current index template version, it will roll over the reporting data stream, to ensure future indexing will use the latest mappings.

Startup processing for reporting has changed to apply the current index template mappings to the kibana reporting index, if it exists.  This fixes a problem where a new field added to the index template, however it was not applied, so the field could not reliably used.  The field was `space_id`, which could cause reports in non-default spaces to not appear in the reports list.
sarog pushed a commit to portsbuild/elasticsearch that referenced this pull request Sep 19, 2025
…33846) (elastic#134015)

Part of elastic/kibana#231200 .

We realized that when the mappings are updated in a version upgrade,
the mappings are in fact updated, but not applied to the current
reporting datastream.

To fix this, we'll make a determination in Kibana that we should roll
over the data stream if the version in the template does not match the
version in the mappings of the datastream.  If they match, we don't need
to do anything.  If they don't match, or the version of the mappings is
not in the datastream (from before this PR), we will need to roll over the
data stream to apply the new mappings.

To make this happen, we need to add a new field to the mapping `_meta`,
which should match the template version.

references:

- https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/mapping-meta-field

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit ebb94bd)

# Conflicts:
#	x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java
pmuellr added a commit to elastic/kibana that referenced this pull request Sep 29, 2025
… changed (#234119)

resolves: #231200

This PR adds code run at startup to check the version in the reporting
index template against the `_meta.template_version` value stamped into
each backing index's mappings via
elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been
created with the current index template version, it will roll over the
reporting data stream, to ensure future indexing will use the latest
mappings. This is done with the "lazy" option, which will perform the
roll over on the next write to the datastream. This will prevent
situations where multiple Kibanas restarting at the same time would roll
over multiple times.

---------

Co-authored-by: Elastic Machine <[email protected]>
niros1 pushed a commit to elastic/kibana that referenced this pull request Sep 30, 2025
… changed (#234119)

resolves: #231200

This PR adds code run at startup to check the version in the reporting
index template against the `_meta.template_version` value stamped into
each backing index's mappings via
elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been
created with the current index template version, it will roll over the
reporting data stream, to ensure future indexing will use the latest
mappings. This is done with the "lazy" option, which will perform the
roll over on the next write to the datastream. This will prevent
situations where multiple Kibanas restarting at the same time would roll
over multiple times.

---------

Co-authored-by: Elastic Machine <[email protected]>
VladimirFilonov pushed a commit to VladimirFilonov/kibana that referenced this pull request Sep 30, 2025
… changed (elastic#234119)

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting
index template against the `_meta.template_version` value stamped into
each backing index's mappings via
elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been
created with the current index template version, it will roll over the
reporting data stream, to ensure future indexing will use the latest
mappings. This is done with the "lazy" option, which will perform the
roll over on the next write to the datastream. This will prevent
situations where multiple Kibanas restarting at the same time would roll
over multiple times.

---------

Co-authored-by: Elastic Machine <[email protected]>
pmuellr added a commit to pmuellr/kibana that referenced this pull request Oct 1, 2025
… changed (elastic#234119)

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting
index template against the `_meta.template_version` value stamped into
each backing index's mappings via
elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been
created with the current index template version, it will roll over the
reporting data stream, to ensure future indexing will use the latest
mappings. This is done with the "lazy" option, which will perform the
roll over on the next write to the datastream. This will prevent
situations where multiple Kibanas restarting at the same time would roll
over multiple times.

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit c89ba82)

# Conflicts:
#	.github/CODEOWNERS
#	x-pack/platform/test/reporting_api_integration/reporting_without_security.config.ts
#	x-pack/platform/test/tsconfig.json
pmuellr added a commit to pmuellr/kibana that referenced this pull request Oct 1, 2025
… changed (elastic#234119)

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting
index template against the `_meta.template_version` value stamped into
each backing index's mappings via
elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been
created with the current index template version, it will roll over the
reporting data stream, to ensure future indexing will use the latest
mappings. This is done with the "lazy" option, which will perform the
roll over on the next write to the datastream. This will prevent
situations where multiple Kibanas restarting at the same time would roll
over multiple times.

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit c89ba82)

# Conflicts:
#	.github/CODEOWNERS
#	x-pack/test/reporting_api_integration/reporting_without_security.config.ts
#	x-pack/test/reporting_api_integration/reporting_without_security/index.ts
#	x-pack/test/reporting_api_integration/reporting_without_security/roll_datastream.ts
#	x-pack/test/tsconfig.json
pmuellr added a commit to pmuellr/kibana that referenced this pull request Oct 1, 2025
… changed (elastic#234119)

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting
index template against the `_meta.template_version` value stamped into
each backing index's mappings via
elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been
created with the current index template version, it will roll over the
reporting data stream, to ensure future indexing will use the latest
mappings. This is done with the "lazy" option, which will perform the
roll over on the next write to the datastream. This will prevent
situations where multiple Kibanas restarting at the same time would roll
over multiple times.

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit c89ba82)

# Conflicts:
#	.github/CODEOWNERS
#	x-pack/platform/test/reporting_api_integration/reporting_without_security.config.ts
#	x-pack/platform/test/tsconfig.json
pmuellr added a commit to pmuellr/kibana that referenced this pull request Oct 1, 2025
… changed (elastic#234119)

resolves: elastic#231200

This PR adds code run at startup to check the version in the reporting
index template against the `_meta.template_version` value stamped into
each backing index's mappings via
elastic/elasticsearch#133846

If it determines there are existing reporting indices that have not been
created with the current index template version, it will roll over the
reporting data stream, to ensure future indexing will use the latest
mappings. This is done with the "lazy" option, which will perform the
roll over on the next write to the datastream. This will prevent
situations where multiple Kibanas restarting at the same time would roll
over multiple times.

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit c89ba82)

# Conflicts:
#	.github/CODEOWNERS
#	x-pack/test/reporting_api_integration/reporting_without_security.config.ts
#	x-pack/test/reporting_api_integration/reporting_without_security/index.ts
#	x-pack/test/reporting_api_integration/reporting_without_security/roll_datastream.ts
#	x-pack/test/tsconfig.json
pmuellr added a commit to elastic/kibana that referenced this pull request Oct 2, 2025
…ate has changed (#234119) (#237115)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Reporting] roll over the reporting data stream when the template has
changed (#234119)](#234119)

<!--- Backport version: 10.0.2 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Patrick
Mueller","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-29T23:06:34Z","message":"[Reporting]
roll over the reporting data stream when the template has changed
(#234119)\n\nresolves:
https://github.com/elastic/kibana/issues/231200\n\nThis PR adds code run
at startup to check the version in the reporting\nindex template against
the `_meta.template_version` value stamped into\neach backing index's
mappings via\nhttps://github.com/elastic/elasticsearch/pull/133846\n\nIf
it determines there are existing reporting indices that have not
been\ncreated with the current index template version, it will roll over
the\nreporting data stream, to ensure future indexing will use the
latest\nmappings. This is done with the \"lazy\" option, which will
perform the\nroll over on the next write to the datastream. This will
prevent\nsituations where multiple Kibanas restarting at the same time
would roll\nover multiple times.\n\n---------\n\nCo-authored-by: Elastic
Machine
<[email protected]>","sha":"c89ba8264f5a43c01d69b42577d79925cb020c04","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","backport
missing","backport:all-open","Feature:Reporting:Framework","v9.2.0"],"title":"[Reporting]
roll over the reporting data stream when the template has
changed","number":234119,"url":"https://github.com/elastic/kibana/pull/234119","mergeCommit":{"message":"[Reporting]
roll over the reporting data stream when the template has changed
(#234119)\n\nresolves:
https://github.com/elastic/kibana/issues/231200\n\nThis PR adds code run
at startup to check the version in the reporting\nindex template against
the `_meta.template_version` value stamped into\neach backing index's
mappings via\nhttps://github.com/elastic/elasticsearch/pull/133846\n\nIf
it determines there are existing reporting indices that have not
been\ncreated with the current index template version, it will roll over
the\nreporting data stream, to ensure future indexing will use the
latest\nmappings. This is done with the \"lazy\" option, which will
perform the\nroll over on the next write to the datastream. This will
prevent\nsituations where multiple Kibanas restarting at the same time
would roll\nover multiple times.\n\n---------\n\nCo-authored-by: Elastic
Machine
<[email protected]>","sha":"c89ba8264f5a43c01d69b42577d79925cb020c04"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/234119","number":234119,"mergeCommit":{"message":"[Reporting]
roll over the reporting data stream when the template has changed
(#234119)\n\nresolves:
https://github.com/elastic/kibana/issues/231200\n\nThis PR adds code run
at startup to check the version in the reporting\nindex template against
the `_meta.template_version` value stamped into\neach backing index's
mappings via\nhttps://github.com/elastic/elasticsearch/pull/133846\n\nIf
it determines there are existing reporting indices that have not
been\ncreated with the current index template version, it will roll over
the\nreporting data stream, to ensure future indexing will use the
latest\nmappings. This is done with the \"lazy\" option, which will
perform the\nroll over on the next write to the datastream. This will
prevent\nsituations where multiple Kibanas restarting at the same time
would roll\nover multiple times.\n\n---------\n\nCo-authored-by: Elastic
Machine
<[email protected]>","sha":"c89ba8264f5a43c01d69b42577d79925cb020c04"}}]}]
BACKPORT-->

---------

Co-authored-by: Elastic Machine <[email protected]>
pmuellr added a commit to elastic/kibana that referenced this pull request Oct 2, 2025
…te has changed (#234119) (#237049)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Reporting] roll over the reporting data stream when the template has
changed (#234119)](#234119)

<!--- Backport version: 10.0.2 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Patrick
Mueller","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-29T23:06:34Z","message":"[Reporting]
roll over the reporting data stream when the template has changed
(#234119)\n\nresolves:
https://github.com/elastic/kibana/issues/231200\n\nThis PR adds code run
at startup to check the version in the reporting\nindex template against
the `_meta.template_version` value stamped into\neach backing index's
mappings via\nhttps://github.com/elastic/elasticsearch/pull/133846\n\nIf
it determines there are existing reporting indices that have not
been\ncreated with the current index template version, it will roll over
the\nreporting data stream, to ensure future indexing will use the
latest\nmappings. This is done with the \"lazy\" option, which will
perform the\nroll over on the next write to the datastream. This will
prevent\nsituations where multiple Kibanas restarting at the same time
would roll\nover multiple times.\n\n---------\n\nCo-authored-by: Elastic
Machine
<[email protected]>","sha":"c89ba8264f5a43c01d69b42577d79925cb020c04","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","backport
missing","backport:all-open","Feature:Reporting:Framework","v9.2.0"],"title":"[Reporting]
roll over the reporting data stream when the template has
changed","number":234119,"url":"https://github.com/elastic/kibana/pull/234119","mergeCommit":{"message":"[Reporting]
roll over the reporting data stream when the template has changed
(#234119)\n\nresolves:
https://github.com/elastic/kibana/issues/231200\n\nThis PR adds code run
at startup to check the version in the reporting\nindex template against
the `_meta.template_version` value stamped into\neach backing index's
mappings via\nhttps://github.com/elastic/elasticsearch/pull/133846\n\nIf
it determines there are existing reporting indices that have not
been\ncreated with the current index template version, it will roll over
the\nreporting data stream, to ensure future indexing will use the
latest\nmappings. This is done with the \"lazy\" option, which will
perform the\nroll over on the next write to the datastream. This will
prevent\nsituations where multiple Kibanas restarting at the same time
would roll\nover multiple times.\n\n---------\n\nCo-authored-by: Elastic
Machine
<[email protected]>","sha":"c89ba8264f5a43c01d69b42577d79925cb020c04"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/234119","number":234119,"mergeCommit":{"message":"[Reporting]
roll over the reporting data stream when the template has changed
(#234119)\n\nresolves:
https://github.com/elastic/kibana/issues/231200\n\nThis PR adds code run
at startup to check the version in the reporting\nindex template against
the `_meta.template_version` value stamped into\neach backing index's
mappings via\nhttps://github.com/elastic/elasticsearch/pull/133846\n\nIf
it determines there are existing reporting indices that have not
been\ncreated with the current index template version, it will roll over
the\nreporting data stream, to ensure future indexing will use the
latest\nmappings. This is done with the \"lazy\" option, which will
perform the\nroll over on the next write to the datastream. This will
prevent\nsituations where multiple Kibanas restarting at the same time
would roll\nover multiple times.\n\n---------\n\nCo-authored-by: Elastic
Machine
<[email protected]>","sha":"c89ba8264f5a43c01d69b42577d79925cb020c04"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged backport pending :Data Management/Data streams Data streams and their lifecycles >non-issue Team:Data Management Meta label for data/management team v8.19.4 v9.1.4 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants