Skip to content

[9.1] [Reporting] Fix timestamp override for ES|QL CSV scheduled reports with relative time ranges (#248169)#249052

Merged
kibanamachine merged 2 commits intoelastic:9.1from
kibanamachine:backport/9.1/pr-248169
Jan 14, 2026
Merged

[9.1] [Reporting] Fix timestamp override for ES|QL CSV scheduled reports with relative time ranges (#248169)#249052
kibanamachine merged 2 commits intoelastic:9.1from
kibanamachine:backport/9.1/pr-248169

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.1:

Questions ?

Please refer to the Backport tool documentation

…th relative time ranges (elastic#248169)

Resolves elastic#245281

## Summary

This PR updates the code to generate ES|QL csv reports to use forceNow
for relative time ranges. To do this we added a new locator function to
get the `timeFieldName` from the job params bc the ES|QL time range
filters don't have the meta field populated.

### Checklist

Check the PR satisfies following conditions.

- [ ] [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

### To verify

1. Create a data view on .kibana-event-log*
2. Use the query below in dev tools to create a scheduled report with a
hardcoded relative time range (You can adjust the timerange in the job
params to what you want when you're testing)
3. Verify that the eventual CSV report has data in the correct time
range

<details>
  <summary>
    <b>Query</b>
  </summary>

This scheduled report will run every minute 🙂

  ```
POST kbn:/internal/reporting/schedule/csv_v2
{
  "schedule": {
    "rrule": {
      "freq": 3,
      "interval": 1,
      "byhour": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23
      ],
      "byminute": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        19,
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37,
        38,
        39,
        40,
        41,
        42,
        43,
        44,
        45,
        46,
        47,
        48,
        49,
        50,
        51,
        52,
        53,
        54,
        55,
        56,
        57,
        58,
        59
      ]
    }
  },
"jobParams":
"(browserTimezone:America/Los_Angeles,isEsqlMode:!t,locatorParams:!((id:DISCOVER_APP_LOCATOR,params:(columns:!(),dataViewSpec:(allowHidden:!f,allowNoIndex:!f,fieldFormats:(),id:'1a05eb41b8d4c4075bf8e71e472bc9855314219a15ddb77af59342159e67beb2',managed:!f,name:'.kibana-event-log*',runtimeFieldMap:(),sourceFilters:!(),timeFieldName:'@timestamp',title:'.kibana-event-log*',type:esql),filters:!(),hideChart:!t,interval:auto,query:(esql:'FROM
.kibana-event-log*'),refreshInterval:(pause:!t,value:60000),sort:!(),tab:(id:'203820a6-4f09-4b15-93c4-5d70924f3e52',label:Untitled),timeRange:(from:'2025-12-31T00:00:00.000Z',to:'2026-12-07T00:00:00.000Z')))),objectType:search,title:'Untitled
Discover session',version:'9.4.0')"
}
  ```
</details>

---------

Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
(cherry picked from commit 75954f1)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Jan 14, 2026
@kibanamachine kibanamachine enabled auto-merge (squash) January 14, 2026 15:31
@doakalexi
Copy link
Copy Markdown
Contributor

/ci

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

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
@kbn/generate-csv 28 30 +2
discover 156 158 +2
total +4
Unknown metric groups

API count

id before after diff
@kbn/generate-csv 28 30 +2
discover 207 209 +2
total +4

History

cc @doakalexi

@kibanamachine kibanamachine merged commit 2e819f9 into elastic:9.1 Jan 14, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants