Skip to content

Adhere to user selected time range for CSV exports#255005

Merged
eokoneyo merged 10 commits intoelastic:mainfrom
eokoneyo:chore/resolve-216605
Apr 29, 2026
Merged

Adhere to user selected time range for CSV exports#255005
eokoneyo merged 10 commits intoelastic:mainfrom
eokoneyo:chore/resolve-216605

Conversation

@eokoneyo
Copy link
Copy Markdown
Contributor

@eokoneyo eokoneyo commented Feb 25, 2026

Summary

Closes #216605

This PR adds implementation such that when generating a CSV export within Kibana from the discover app the absolute time range for the current session is used, whilst for retain the currently behaviour for the generated POST URL, this ensures that the export the user gets correlates one to one with the exact content the user is currently viewing.

Implementation

A new property absoluteTimeRange is now being passed to the sharing data for the discover app, this property is then used whilst generating a CSV export within Kibana, POST URL retains it's normal behavior of having the value the user selected in the UI, see (#255005 (comment)) for the rationale behind this decision.

Visual

There is no visual change to the user.

@eokoneyo eokoneyo self-assigned this Feb 25, 2026
@eokoneyo eokoneyo added Team:SharedUX Platform AppEx-SharedUX (formerly Global Experience) t// backport:all-open Backport to all branches that could still receive a release labels Feb 25, 2026
@eokoneyo eokoneyo force-pushed the chore/resolve-216605 branch from 7e38623 to 3277864 Compare February 25, 2026 20:42
@eokoneyo

This comment was marked as outdated.

@eokoneyo eokoneyo force-pushed the chore/resolve-216605 branch from 3277864 to 62a97b8 Compare February 26, 2026 09:40
@eokoneyo
Copy link
Copy Markdown
Contributor Author

/ci

@eokoneyo eokoneyo force-pushed the chore/resolve-216605 branch from df05c05 to e0601c3 Compare February 26, 2026 11:23
@eokoneyo
Copy link
Copy Markdown
Contributor Author

/ci

@eokoneyo eokoneyo changed the title CSV export should use the currently selected time range Provide option to specify time range configuration to be used when performing CSV exports Feb 26, 2026
@eokoneyo eokoneyo marked this pull request as ready for review February 26, 2026 13:12
@eokoneyo eokoneyo requested review from a team as code owners February 26, 2026 13:12
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@eokoneyo eokoneyo added the release_note:skip Skip the PR/issue when compiling release notes label Feb 26, 2026
@pmuellr
Copy link
Copy Markdown
Contributor

pmuellr commented Feb 27, 2026

Wow, I'm kinda surprised by this issue - has it not been reported before? I just tried with a non-ES|QL discover, just use a time range BEFORE current time (obviously), and you'll see the generated CSV seems to cover the same time duration, but anchored on NOW as the end.

As such, it seems weird we'd even give folks the option to have a "relative" time here, we should just always pass the time range in.

@tsullivan any thoughts?

@davismcphee davismcphee requested a review from jughosta March 3, 2026 03:46
@davismcphee
Copy link
Copy Markdown
Contributor

@jughosta could you please review this one?

@eokoneyo
Copy link
Copy Markdown
Contributor Author

eokoneyo commented Mar 3, 2026

@elasticmachine merge upstream

@elasticmachine

This comment was marked as outdated.

@eokoneyo eokoneyo force-pushed the chore/resolve-216605 branch from e0601c3 to d491e8b Compare March 3, 2026 04:03
Comment thread src/platform/plugins/shared/discover/server/locator/resolve_time_field_name.ts Outdated
@tsullivan
Copy link
Copy Markdown
Member

tsullivan commented Mar 4, 2026

As such, it seems weird we'd even give folks the option to have a "relative" time here, we should just always pass the time range in.

@pmuellr I tend to agree. My understanding is that the job params for CSV are created with an awareness of what the time picker is set to. If the time picker uses a relative range then a relative range should be put into job params.

I recall some work to support this before, and that it had to be revisited a few time. I dug up a few commits that worked on this:

bdac77d3203c 2024-04-24 Julia Rechkunova [Discover] Fix time range filters for CSV when a relative time filter is specified in UI (#181067)
deb7099b28b4 2022-03-16 Dmitry Tomashevich [Discover] Fix csv export with relative time filter from discover main view (#123206)
7bb19d209e0e 2019-07-09 Tim Sullivan Fix Relative Date format in CSV export (#40544)

I guess the problem is unique to ES|QL mode because there is no timepicker?

cc @eokoneyo

@jughosta
Copy link
Copy Markdown
Contributor

jughosta commented Mar 5, 2026

Some customers rely on a relative time range for POST URL. For the reporting we could make it absolute by default but users should still have a possibility to opt for a relative time range for POST URL.

A related comment from the issue discussion #216605 (comment):

Reopening this issue because the fix for it in #216792 ended up causing a bug with CSV Post URLs that we decided had a higher impact: #223171.
Instead the @elastic/appex-sharedux team has indicated they will work with us to provide a more robust solution for both cases. Possibly a way to specify separate URLs for CSV exports vs Post URLs, or a UX toggle that allows users to indicate if they want to use an absolute or relative time range, similar to #218056.

@eokoneyo
Copy link
Copy Markdown
Contributor Author

eokoneyo commented Mar 6, 2026

Some customers rely on a relative time range for POST URL. For the reporting we could make it absolute by default but users should still have a possibility to opt for a relative time range for POST URL.

A related comment from the issue discussion #216605 (comment):

Reopening this issue because the fix for it in #216792 ended up causing a bug with CSV Post URLs that we decided had a higher impact: #223171.
Instead the @elastic/appex-sharedux team has indicated they will work with us to provide a more robust solution for both cases. Possibly a way to specify separate URLs for CSV exports vs Post URLs, or a UX toggle that allows users to indicate if they want to use an absolute or relative time range, similar to #218056.

I agree this conclusion would be in line with how it should work, I suppose we'd need to change the messaging so users know the switch applies only to the POST URL, @florent-leborgne could you help suggest an improvement to the copy, we want to inform users that toggling the switch only applies to the POST URL, thanks.

@eokoneyo
Copy link
Copy Markdown
Contributor Author

eokoneyo commented Mar 6, 2026

@elasticmachine merge upstream

Copy link
Copy Markdown
Member

@kowalczyk-krzysztof kowalczyk-krzysztof left a comment

Choose a reason for hiding this comment

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

The code changes are fine, approving to unblock. Make sure to align on the business logic.

@eokoneyo eokoneyo force-pushed the chore/resolve-216605 branch from cb3b80c to 506e087 Compare April 23, 2026 10:28
Copy link
Copy Markdown
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Data Discovery changes LGTM 👍

@eokoneyo eokoneyo force-pushed the chore/resolve-216605 branch from 506e087 to 5fd32b4 Compare April 23, 2026 13:03
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Investigations - Security Solution Cypress Tests #8 / Event Rendered View "before each" hook for "should show Event Summary column correctly" "before each" hook for "should show Event Summary column correctly"

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
share 97 102 +5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 1.9MB 1.9MB +97.0B
reporting 144.8KB 145.5KB +740.0B
total +837.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
share 56.6KB 56.9KB +298.0B
Unknown metric groups

API count

id before after diff
share 163 169 +6

History

cc @eokoneyo

@eokoneyo
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] affected Scout: [ security / security_solution ] plugin / local-stateful-classic - Attacks navigation - updates side nav based on attacks alignment advanced setting
  • [job] [logs] affected Scout: [ observability / synthetics ] plugin / local-stateful-classic - FilterMonitors - filters monitors by tags with AND/OR logic

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
share 97 102 +5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 1.9MB 1.9MB +97.0B
reporting 144.8KB 145.5KB +740.0B
total +837.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
share 56.6KB 56.9KB +298.0B
Unknown metric groups

API count

id before after diff
share 163 169 +6

cc @eokoneyo

Copy link
Copy Markdown
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.

ResponseOps changes LGTM

@eokoneyo eokoneyo merged commit dd1ca76 into elastic:main Apr 29, 2026
19 checks passed
@eokoneyo eokoneyo deleted the chore/resolve-216605 branch April 29, 2026 07:00
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19, 9.2, 9.3, 9.4

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

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.19:
- [CI] Jest through moon (#259075)
9.2 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.2:
- [CI] Jest through moon (#259075)
9.3 Backport failed because of merge conflicts
9.4 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 255005

Questions ?

Please refer to the Backport tool documentation

@eokoneyo
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
9.4
9.3

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

Questions ?

Please refer to the Backport tool documentation

eokoneyo added a commit to eokoneyo/kibana that referenced this pull request Apr 30, 2026
## Summary

Closes elastic#216605

This PR adds implementation such that when generating a CSV export
within Kibana from the discover app the absolute time range for the
current session is used, whilst for retain the currently behaviour for
the generated POST URL, this ensures that the export the user gets
correlates one to one with the exact content the user is currently
viewing.

## Implementation

A new property `absoluteTimeRange` is now being passed to the sharing
data for the discover app, this property is then used whilst generating
a CSV export within Kibana, POST URL retains it's normal behavior of
having the value the user selected in the UI, see
(elastic#255005 (comment))
for the rationale behind this decision.

### Visual

There is no visual change to the user.

<!--
### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

-->

---------

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

# Conflicts:
#	packages/kbn-optimizer/limits.yml
#	src/platform/packages/private/kbn-reporting/public/share/integrations/csv/csv_export_config.tsx
#	src/platform/plugins/shared/discover/moon.yml
#	src/platform/plugins/shared/discover/public/application/main/components/top_nav/app_menu_actions/get_share.tsx
#	src/platform/plugins/shared/discover/tsconfig.json
#	src/platform/plugins/shared/share/public/components/export_integrations/export_integrations.tsx
#	src/platform/plugins/shared/share/public/components/export_integrations/index.ts
#	src/platform/plugins/shared/share/public/services/share_menu_manager.tsx
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Apr 30, 2026
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @eokoneyo

eokoneyo added a commit that referenced this pull request Apr 30, 2026
…266277)

# Backport

This will backport the following commits from `main` to `9.4`:
- [Adhere to user selected time range for CSV exports
(#255005)](#255005)

<!--- Backport version: 11.0.2 -->

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

<!--BACKPORT [{"author":{"name":"Eyo O.
Eyo","email":"7893459+eokoneyo@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-29T07:00:22Z","message":"Adhere
to user selected time range for CSV exports (#255005)\n\n##
Summary\n\nCloses #216605\n\nThis PR adds implementation such that when
generating a CSV export\nwithin Kibana from the discover app the
absolute time range for the\ncurrent session is used, whilst for retain
the currently behaviour for\nthe generated POST URL, this ensures that
the export the user gets\ncorrelates one to one with the exact content
the user is currently\nviewing.\n\n## Implementation\n\nA new property
`absoluteTimeRange` is now being passed to the sharing\ndata for the
discover app, this property is then used whilst generating\na CSV export
within Kibana, POST URL retains it's normal behavior of\nhaving the
value the user selected in the UI,
see\n(https://github.com/elastic/kibana/pull/255005#issuecomment-4084863736)\nfor
the rationale behind this decision.\n\n### Visual\n\nThere is no visual
change to the user.\n\n\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"dd1ca76250164ccf9ccdce0b0738bd94667bb4e2","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:SharedUX","backport:all-open","v9.5.0"],"title":"Adhere
to user selected time range for CSV
exports","number":255005,"url":"https://github.com/elastic/kibana/pull/255005","mergeCommit":{"message":"Adhere
to user selected time range for CSV exports (#255005)\n\n##
Summary\n\nCloses #216605\n\nThis PR adds implementation such that when
generating a CSV export\nwithin Kibana from the discover app the
absolute time range for the\ncurrent session is used, whilst for retain
the currently behaviour for\nthe generated POST URL, this ensures that
the export the user gets\ncorrelates one to one with the exact content
the user is currently\nviewing.\n\n## Implementation\n\nA new property
`absoluteTimeRange` is now being passed to the sharing\ndata for the
discover app, this property is then used whilst generating\na CSV export
within Kibana, POST URL retains it's normal behavior of\nhaving the
value the user selected in the UI,
see\n(https://github.com/elastic/kibana/pull/255005#issuecomment-4084863736)\nfor
the rationale behind this decision.\n\n### Visual\n\nThere is no visual
change to the user.\n\n\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"dd1ca76250164ccf9ccdce0b0738bd94667bb4e2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/255005","number":255005,"mergeCommit":{"message":"Adhere
to user selected time range for CSV exports (#255005)\n\n##
Summary\n\nCloses #216605\n\nThis PR adds implementation such that when
generating a CSV export\nwithin Kibana from the discover app the
absolute time range for the\ncurrent session is used, whilst for retain
the currently behaviour for\nthe generated POST URL, this ensures that
the export the user gets\ncorrelates one to one with the exact content
the user is currently\nviewing.\n\n## Implementation\n\nA new property
`absoluteTimeRange` is now being passed to the sharing\ndata for the
discover app, this property is then used whilst generating\na CSV export
within Kibana, POST URL retains it's normal behavior of\nhaving the
value the user selected in the UI,
see\n(https://github.com/elastic/kibana/pull/255005#issuecomment-4084863736)\nfor
the rationale behind this decision.\n\n### Visual\n\nThere is no visual
change to the user.\n\n\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"dd1ca76250164ccf9ccdce0b0738bd94667bb4e2"}}]}]
BACKPORT-->
eokoneyo added a commit that referenced this pull request Apr 30, 2026
…266429)

# Backport

This will backport the following commits from `main` to `9.3`:
- [Adhere to user selected time range for CSV exports
(#255005)](#255005)

<!--- Backport version: 11.0.2 -->

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

<!--BACKPORT [{"author":{"name":"Eyo O.
Eyo","email":"7893459+eokoneyo@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-29T07:00:22Z","message":"Adhere
to user selected time range for CSV exports (#255005)\n\n##
Summary\n\nCloses #216605\n\nThis PR adds implementation such that when
generating a CSV export\nwithin Kibana from the discover app the
absolute time range for the\ncurrent session is used, whilst for retain
the currently behaviour for\nthe generated POST URL, this ensures that
the export the user gets\ncorrelates one to one with the exact content
the user is currently\nviewing.\n\n## Implementation\n\nA new property
`absoluteTimeRange` is now being passed to the sharing\ndata for the
discover app, this property is then used whilst generating\na CSV export
within Kibana, POST URL retains it's normal behavior of\nhaving the
value the user selected in the UI,
see\n(https://github.com/elastic/kibana/pull/255005#issuecomment-4084863736)\nfor
the rationale behind this decision.\n\n### Visual\n\nThere is no visual
change to the user.\n\n\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"dd1ca76250164ccf9ccdce0b0738bd94667bb4e2","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:SharedUX","backport:all-open","v9.5.0"],"title":"Adhere
to user selected time range for CSV
exports","number":255005,"url":"https://github.com/elastic/kibana/pull/255005","mergeCommit":{"message":"Adhere
to user selected time range for CSV exports (#255005)\n\n##
Summary\n\nCloses #216605\n\nThis PR adds implementation such that when
generating a CSV export\nwithin Kibana from the discover app the
absolute time range for the\ncurrent session is used, whilst for retain
the currently behaviour for\nthe generated POST URL, this ensures that
the export the user gets\ncorrelates one to one with the exact content
the user is currently\nviewing.\n\n## Implementation\n\nA new property
`absoluteTimeRange` is now being passed to the sharing\ndata for the
discover app, this property is then used whilst generating\na CSV export
within Kibana, POST URL retains it's normal behavior of\nhaving the
value the user selected in the UI,
see\n(https://github.com/elastic/kibana/pull/255005#issuecomment-4084863736)\nfor
the rationale behind this decision.\n\n### Visual\n\nThere is no visual
change to the user.\n\n\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"dd1ca76250164ccf9ccdce0b0738bd94667bb4e2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/255005","number":255005,"mergeCommit":{"message":"Adhere
to user selected time range for CSV exports (#255005)\n\n##
Summary\n\nCloses #216605\n\nThis PR adds implementation such that when
generating a CSV export\nwithin Kibana from the discover app the
absolute time range for the\ncurrent session is used, whilst for retain
the currently behaviour for\nthe generated POST URL, this ensures that
the export the user gets\ncorrelates one to one with the exact content
the user is currently\nviewing.\n\n## Implementation\n\nA new property
`absoluteTimeRange` is now being passed to the sharing\ndata for the
discover app, this property is then used whilst generating\na CSV export
within Kibana, POST URL retains it's normal behavior of\nhaving the
value the user selected in the UI,
see\n(https://github.com/elastic/kibana/pull/255005#issuecomment-4084863736)\nfor
the rationale behind this decision.\n\n### Visual\n\nThere is no visual
change to the user.\n\n\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"dd1ca76250164ccf9ccdce0b0738bd94667bb4e2"}}]}]
BACKPORT-->
@kibanamachine kibanamachine added v9.4.0 v9.3.4 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Apr 30, 2026
@Ikuni17 Ikuni17 added v9.3.5 and removed v9.3.4 labels May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:all-open Backport to all branches that could still receive a release release_note:fix Team:SharedUX Platform AppEx-SharedUX (formerly Global Experience) t// v9.3.5 v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discover][ES|QL] CSV export should use the currently selected time range