Skip to content

[Response Ops][Reporting] Report UI should only show reports generated in the current space.#221375

Merged
ymao1 merged 5 commits intoelastic:mainfrom
ymao1:reporting/219881
Jun 6, 2025
Merged

[Response Ops][Reporting] Report UI should only show reports generated in the current space.#221375
ymao1 merged 5 commits intoelastic:mainfrom
ymao1:reporting/219881

Conversation

@ymao1
Copy link
Contributor

@ymao1 ymao1 commented May 23, 2025

Resolves #219881

Summary

  • Saves space_id in the report source document when a report is generated.
  • Updated the list API to filter by space_id (if available). The filter also includes documents where space_id is not populated in order to maintain backwards compatibility with old reports that don't include the space_id field. This is an internal API so this change should be allowed.
  • Associated Elasticsearch PR to add space_id to the report index mapping: Adding space_id field mapping to kibana reporting template elasticsearch#128336

To Verify

  • On main, generate reports in different spaces
  • Switch to this branch and generate more reports in different spaces
  • Verify that you only see the new reports generated in the current space + the old reports generated on main with no space id.
@ymao1 ymao1 changed the title Adding space id to report template May 23, 2025
@ymao1 ymao1 self-assigned this May 23, 2025
@ymao1 ymao1 added release_note:enhancement Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v9.1.0 v8.19.0 Feature:Reporting:Framework Reporting issues pertaining to the overall framework backport:version Backport to applied version labels labels May 23, 2025
@ymao1 ymao1 marked this pull request as ready for review May 23, 2025 16:59
@ymao1 ymao1 requested a review from a team as a code owner May 23, 2025 16:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@ymao1 ymao1 requested review from js-jankisalvi and pmuellr May 23, 2025 16:59

if (spaceId !== DEFAULT_SPACE_ID) {
logger.info(`Request uses Space ID: ${spaceId}`);
logger.debug(`Request uses Space ID: ${spaceId}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is info level. It gets logged every time the Reporting UI is accessed in a different space and there is auto-refresh enabled on that page so it gets logged a lot 🙈

Copy link
Contributor

@js-jankisalvi js-jankisalvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes lgtm 👍

@ymao1
Copy link
Contributor Author

ymao1 commented May 27, 2025

@elasticmachine merge upstream

@ymao1
Copy link
Contributor Author

ymao1 commented May 29, 2025

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/test-suites-xpack 707 708 +1

Total ESLint disabled count

id before after diff
@kbn/test-suites-xpack 729 730 +1

History

cc @ymao1

@ymao1
Copy link
Contributor Author

ymao1 commented Jun 2, 2025

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/test-suites-xpack 707 708 +1

Total ESLint disabled count

id before after diff
@kbn/test-suites-xpack 729 730 +1

History

cc @ymao1

Copy link
Contributor

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM and works as expected.

One thing I don't understand. I'm not running the version of ES with the new space_id field in the reporting mapping. But this still works :-). It's not clear to me how, but seems like we are auto-mapping this field? That seems like a potential problem, in the future.

And I guess we should get that ES PR merged that adds the mapping, before merging this?

@ymao1
Copy link
Contributor Author

ymao1 commented Jun 5, 2025

It's not clear to me how, but seems like we are auto-mapping this field?

@pmuellr It looks like the template doesn't explicitly set dynamic to false or strict, so I believe it defaults to true: https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/dynamic

@ymao1
Copy link
Contributor Author

ymao1 commented Jun 5, 2025

@elasticmachine merge upstream

@pmuellr
Copy link
Contributor

pmuellr commented Jun 5, 2025

It looks like the template doesn't explicitly set dynamic to false or strict, so I believe it defaults to true: https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/dynamic

That's what I figured. Seems like we probably want to tighten this up? I'll add a note to our issue to move the template creation into Kibana ...

@ymao1 ymao1 merged commit a55c72d into elastic:main Jun 6, 2025
10 checks passed
@ymao1 ymao1 deleted the reporting/219881 branch June 6, 2025 13:38
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15491914452

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 221375

Questions ?

Please refer to the Backport tool documentation

@ymao1
Copy link
Contributor Author

ymao1 commented Jun 6, 2025

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

ymao1 added a commit to ymao1/kibana that referenced this pull request Jun 6, 2025
…d in the current space. (elastic#221375)

Resolves elastic#219881

## Summary

* Saves `space_id` in the report source document when a report is
generated.
* Updated the `list` API to filter by `space_id` (if available). The
filter also includes documents where `space_id` is not populated in
order to maintain backwards compatibility with old reports that don't
include the `space_id` field. This is an internal API so this change
should be allowed.
* Associated Elasticsearch PR to add `space_id` to the report index
mapping: elastic/elasticsearch#128336

## To Verify
* On `main`, generate reports in different spaces
* Switch to this branch and generate more reports in different spaces
* Verify that you only see the new reports generated in the current
space + the old reports generated on `main` with no space id.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit a55c72d)

# Conflicts:
#	x-pack/platform/plugins/private/reporting/server/routes/common/jobs/jobs_query.test.ts
ymao1 added a commit that referenced this pull request Jun 6, 2025
…enerated in the current space. (#221375) (#223002)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Response Ops][Reporting] Report UI should only show reports
generated in the current space.
(#221375)](#221375)

<!--- Backport version: 10.0.0 -->

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

<!--BACKPORT [{"author":{"name":"Ying
Mao","email":"ying.mao@elastic.co"},"sourceCommit":{"committedDate":"2025-06-06T13:38:54Z","message":"[Response
Ops][Reporting] Report UI should only show reports generated in the
current space. (#221375)\n\nResolves
https://github.com/elastic/kibana/issues/219881\n\n## Summary\n\n* Saves
`space_id` in the report source document when a report is\ngenerated.\n*
Updated the `list` API to filter by `space_id` (if available).
The\nfilter also includes documents where `space_id` is not populated
in\norder to maintain backwards compatibility with old reports that
don't\ninclude the `space_id` field. This is an internal API so this
change\nshould be allowed.\n* Associated Elasticsearch PR to add
`space_id` to the report index\nmapping:
https://github.com/elastic/elasticsearch/pull/128336\n\n## To Verify\n*
On `main`, generate reports in different spaces\n* Switch to this branch
and generate more reports in different spaces\n* Verify that you only
see the new reports generated in the current\nspace + the old reports
generated on `main` with no space id.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"a55c72d020ae6149813f88261d7dbddf5e719aba","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:ResponseOps","Feature:Reporting:Framework","backport:version","v9.1.0","v8.19.0"],"title":"[Response
Ops][Reporting] Report UI should only show reports generated in the
current
space.","number":221375,"url":"https://github.com/elastic/kibana/pull/221375","mergeCommit":{"message":"[Response
Ops][Reporting] Report UI should only show reports generated in the
current space. (#221375)\n\nResolves
https://github.com/elastic/kibana/issues/219881\n\n## Summary\n\n* Saves
`space_id` in the report source document when a report is\ngenerated.\n*
Updated the `list` API to filter by `space_id` (if available).
The\nfilter also includes documents where `space_id` is not populated
in\norder to maintain backwards compatibility with old reports that
don't\ninclude the `space_id` field. This is an internal API so this
change\nshould be allowed.\n* Associated Elasticsearch PR to add
`space_id` to the report index\nmapping:
https://github.com/elastic/elasticsearch/pull/128336\n\n## To Verify\n*
On `main`, generate reports in different spaces\n* Switch to this branch
and generate more reports in different spaces\n* Verify that you only
see the new reports generated in the current\nspace + the old reports
generated on `main` with no space id.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"a55c72d020ae6149813f88261d7dbddf5e719aba"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/221375","number":221375,"mergeCommit":{"message":"[Response
Ops][Reporting] Report UI should only show reports generated in the
current space. (#221375)\n\nResolves
https://github.com/elastic/kibana/issues/219881\n\n## Summary\n\n* Saves
`space_id` in the report source document when a report is\ngenerated.\n*
Updated the `list` API to filter by `space_id` (if available).
The\nfilter also includes documents where `space_id` is not populated
in\norder to maintain backwards compatibility with old reports that
don't\ninclude the `space_id` field. This is an internal API so this
change\nshould be allowed.\n* Associated Elasticsearch PR to add
`space_id` to the report index\nmapping:
https://github.com/elastic/elasticsearch/pull/128336\n\n## To Verify\n*
On `main`, generate reports in different spaces\n* Switch to this branch
and generate more reports in different spaces\n* Verify that you only
see the new reports generated in the current\nspace + the old reports
generated on `main` with no space id.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"a55c72d020ae6149813f88261d7dbddf5e719aba"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
pmuellr pushed a commit to pmuellr/kibana that referenced this pull request Jun 11, 2025
…d in the current space. (elastic#221375)

Resolves elastic#219881

## Summary

* Saves `space_id` in the report source document when a report is
generated.
* Updated the `list` API to filter by `space_id` (if available). The
filter also includes documents where `space_id` is not populated in
order to maintain backwards compatibility with old reports that don't
include the `space_id` field. This is an internal API so this change
should be allowed.
* Associated Elasticsearch PR to add `space_id` to the report index
mapping: elastic/elasticsearch#128336

## To Verify
* On `main`, generate reports in different spaces
* Switch to this branch and generate more reports in different spaces
* Verify that you only see the new reports generated in the current
space + the old reports generated on `main` with no space id.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
nickpeihl pushed a commit to nickpeihl/kibana that referenced this pull request Jun 12, 2025
…d in the current space. (elastic#221375)

Resolves elastic#219881

## Summary

* Saves `space_id` in the report source document when a report is
generated.
* Updated the `list` API to filter by `space_id` (if available). The
filter also includes documents where `space_id` is not populated in
order to maintain backwards compatibility with old reports that don't
include the `space_id` field. This is an internal API so this change
should be allowed.
* Associated Elasticsearch PR to add `space_id` to the report index
mapping: elastic/elasticsearch#128336

## To Verify
* On `main`, generate reports in different spaces
* Switch to this branch and generate more reports in different spaces
* Verify that you only see the new reports generated in the current
space + the old reports generated on `main` with no space id.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
ymao1 added a commit that referenced this pull request Jul 2, 2025
…om scheduled export (#225669)

## Summary

Noticed during verification that the report document generated during
scheduled exports do not include the `space_id` field. We added it for
single exports in [this
PR](#221375) but forgot to update
the scheduled export feature to pass through the space ID.

## To Verify

1. Create a scheduled export and wait for it to generate a report
2. Look for the doc in `.kibana-reporting`. It should contain the
`space_id` field.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 2, 2025
…om scheduled export (elastic#225669)

## Summary

Noticed during verification that the report document generated during
scheduled exports do not include the `space_id` field. We added it for
single exports in [this
PR](elastic#221375) but forgot to update
the scheduled export feature to pass through the space ID.

## To Verify

1. Create a scheduled export and wait for it to generate a report
2. Look for the doc in `.kibana-reporting`. It should contain the
`space_id` field.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit d43d900)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 2, 2025
…om scheduled export (elastic#225669)

## Summary

Noticed during verification that the report document generated during
scheduled exports do not include the `space_id` field. We added it for
single exports in [this
PR](elastic#221375) but forgot to update
the scheduled export feature to pass through the space ID.

## To Verify

1. Create a scheduled export and wait for it to generate a report
2. Look for the doc in `.kibana-reporting`. It should contain the
`space_id` field.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit d43d900)
kibanamachine added a commit that referenced this pull request Jul 2, 2025
…ated from scheduled export (#225669) (#226171)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Response Ops][Reporting] Store `space_id` in report doc generated
from scheduled export
(#225669)](#225669)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Ying
Mao","email":"ying.mao@elastic.co"},"sourceCommit":{"committedDate":"2025-07-02T11:33:53Z","message":"[Response
Ops][Reporting] Store `space_id` in report doc generated from scheduled
export (#225669)\n\n## Summary\n\nNoticed during verification that the
report document generated during\nscheduled exports do not include the
`space_id` field. We added it for\nsingle exports in
[this\nPR](#221375) but forgot to
update\nthe scheduled export feature to pass through the space ID.\n\n##
To Verify\n\n1. Create a scheduled export and wait for it to generate a
report\n2. Look for the doc in `.kibana-reporting`. It should contain
the\n`space_id` field.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","Feature:Reporting:Framework","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Response
Ops][Reporting] Store `space_id` in report doc generated from scheduled
export","number":225669,"url":"https://github.com/elastic/kibana/pull/225669","mergeCommit":{"message":"[Response
Ops][Reporting] Store `space_id` in report doc generated from scheduled
export (#225669)\n\n## Summary\n\nNoticed during verification that the
report document generated during\nscheduled exports do not include the
`space_id` field. We added it for\nsingle exports in
[this\nPR](#221375) but forgot to
update\nthe scheduled export feature to pass through the space ID.\n\n##
To Verify\n\n1. Create a scheduled export and wait for it to generate a
report\n2. Look for the doc in `.kibana-reporting`. It should contain
the\n`space_id` field.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225669","number":225669,"mergeCommit":{"message":"[Response
Ops][Reporting] Store `space_id` in report doc generated from scheduled
export (#225669)\n\n## Summary\n\nNoticed during verification that the
report document generated during\nscheduled exports do not include the
`space_id` field. We added it for\nsingle exports in
[this\nPR](#221375) but forgot to
update\nthe scheduled export feature to pass through the space ID.\n\n##
To Verify\n\n1. Create a scheduled export and wait for it to generate a
report\n2. Look for the doc in `.kibana-reporting`. It should contain
the\n`space_id` field.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de"}}]}]
BACKPORT-->

Co-authored-by: Ying Mao <ying.mao@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Jul 2, 2025
…ted from scheduled export (#225669) (#226172)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Response Ops][Reporting] Store `space_id` in report doc generated
from scheduled export
(#225669)](#225669)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Ying
Mao","email":"ying.mao@elastic.co"},"sourceCommit":{"committedDate":"2025-07-02T11:33:53Z","message":"[Response
Ops][Reporting] Store `space_id` in report doc generated from scheduled
export (#225669)\n\n## Summary\n\nNoticed during verification that the
report document generated during\nscheduled exports do not include the
`space_id` field. We added it for\nsingle exports in
[this\nPR](#221375) but forgot to
update\nthe scheduled export feature to pass through the space ID.\n\n##
To Verify\n\n1. Create a scheduled export and wait for it to generate a
report\n2. Look for the doc in `.kibana-reporting`. It should contain
the\n`space_id` field.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","Feature:Reporting:Framework","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Response
Ops][Reporting] Store `space_id` in report doc generated from scheduled
export","number":225669,"url":"https://github.com/elastic/kibana/pull/225669","mergeCommit":{"message":"[Response
Ops][Reporting] Store `space_id` in report doc generated from scheduled
export (#225669)\n\n## Summary\n\nNoticed during verification that the
report document generated during\nscheduled exports do not include the
`space_id` field. We added it for\nsingle exports in
[this\nPR](#221375) but forgot to
update\nthe scheduled export feature to pass through the space ID.\n\n##
To Verify\n\n1. Create a scheduled export and wait for it to generate a
report\n2. Look for the doc in `.kibana-reporting`. It should contain
the\n`space_id` field.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225669","number":225669,"mergeCommit":{"message":"[Response
Ops][Reporting] Store `space_id` in report doc generated from scheduled
export (#225669)\n\n## Summary\n\nNoticed during verification that the
report document generated during\nscheduled exports do not include the
`space_id` field. We added it for\nsingle exports in
[this\nPR](#221375) but forgot to
update\nthe scheduled export feature to pass through the space ID.\n\n##
To Verify\n\n1. Create a scheduled export and wait for it to generate a
report\n2. Look for the doc in `.kibana-reporting`. It should contain
the\n`space_id` field.\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de"}}]}]
BACKPORT-->

Co-authored-by: Ying Mao <ying.mao@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
…om scheduled export (elastic#225669)

## Summary

Noticed during verification that the report document generated during
scheduled exports do not include the `space_id` field. We added it for
single exports in [this
PR](elastic#221375) but forgot to update
the scheduled export feature to pass through the space ID.

## To Verify

1. Create a scheduled export and wait for it to generate a report
2. Look for the doc in `.kibana-reporting`. It should contain the
`space_id` field.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels Feature:Reporting:Framework Reporting issues pertaining to the overall framework release_note:enhancement Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.19.0 v9.1.0

5 participants