-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Reporting] Fix Generating Reports with long jobParams
RISON
#45603
[Reporting] Fix Generating Reports with long jobParams
RISON
#45603
Conversation
Pinging @elastic/kibana-stack-services |
💔 Build Failed |
💚 Build Succeeded |
💔 Build Failed |
💔 Build Failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question is whether we want to update the docs. Getting the post url places job params in the query string. Do we need a section here, or in troubleshooting, explaining how jobParams can be put in the body if the URL is too long?
lgtm with green CI
code review, tested in chrome
jobParams
RISON
Thanks Nathan! Yes updating the docs is an open and legitimate checkbox for this PR. |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
I think it would be fine to write the documentation in a followup PR, that way I can focus on running the docs server against the changes to make sure formatting looks good. In case it's someone other than me that has to write the documentation, this is my draft: https://www.elastic.co/guide/en/kibana/current/automating-report-generation.html#_using_watcher
https://www.elastic.co/guide/en/kibana/current/automating-report-generation.html#_using_a_script
TODO: how to get the rison |
💔 Build Failed |
💚 Build Succeeded |
@@ -25,13 +26,45 @@ export function registerGenerate( | |||
server.route({ | |||
path: `${BASE_GENERATE}/{exportType}`, | |||
method: 'POST', | |||
config: getRouteConfig(request => request.params.exportType), | |||
config: { | |||
...getRouteConfig(request => request.params.exportType), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice I like this method better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have an unrelated small fix I can make to validate the exportType param is registered in the exportTypesRegistry as an ID of one of the types
@@ -158,3 +158,27 @@ export const CSV_RESULT_NANOS = `date,message,"_id" | |||
"2015-01-01T12:10:30.123456789Z","Hello 2", | |||
"2015-01-01T12:10:30","Hello 1", | |||
`; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could use something like the backtick operator with dedent
? I've seen that lib used for our dockerfiles and elsewhere. Just a bit more pleasant to work on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const JOB_PARAMS_IN_QUERYSTRING =
dedent`(conflictedTypesFields:!(),fields:!(%27@timestamp%27,clientip,extens
ion),indexPatternId:%27logstash-*%27,metaFields:!(_source,_id,_type,_index,_scor
e),searchRequest:(body:(_source:(excludes:!(),includes:!(%27@timestamp%27,client
ip,extension)),docvalue_fields:!(),query:(bool:(filter:!((match_all:()),(range:(
%27@timestamp%27:(gte:%272015-09-20T10:19:40.307Z%27,lt:%272015-09-20T10:26:56.2
21Z%27))),(range:(%27@timestamp%27:(format:strict_date_optional_time,gte:%272004
-09-17T21:19:34.213Z%27,lte:%272019-09-17T21:19:34.213Z%27)))),must:!(),must_not
:!(),should:!())),script_fields:(),sort:!((%27@timestamp%27:(order:desc,unmapped
_type:boolean))),stored_fields:!(%27@timestamp%27,clientip,extension),version:!t
),index:%27logstash-*%27),title:%27A%20Saved%20Search%20With%20a%20DATE%20FILTER
%27,type:search)`;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! It turns out dedent
still retains the line breaks, so I added in a short little function to act as the template for the string.
I also realized there does not need to be 2 consts here, because the query string one is just the same rison, just URI-encoded.
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Small comment about using dedent
vs string-concatenation for those larger rison URLs
💚 Build Succeeded |
@elasticmachine merge upstream |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Canvas changes look good 👍
…ic#45603) * Rename route file for consistency * Generate via jobParams allows post payload * jobParams as post body * [Reporting] Skip failing test * fix types * canvas pdf generation to use post payload * api test * tests * fix a typescript * fix fn test * fix tests * fix tests * run esArchiver fewer times * return rison that came in invalid
… (#46404) * Rename route file for consistency * Generate via jobParams allows post payload * jobParams as post body * [Reporting] Skip failing test * fix types * canvas pdf generation to use post payload * api test * tests * fix a typescript * fix fn test * fix tests * fix tests * run esArchiver fewer times * return rison that came in invalid
Summary
Closes #20037
This solves the problem with URLs having long query string being too long to use as a Reportingt POST URL. This uses the same jobParams data as before, but includes it as POST payload data rather than the query string. This fixes the issues because there are fewer limits in network environments around long strings in POST payload versus long strings as a URL query string.
This fix changes a central area of code that all the export types use. In other words, it fixes the bug for:
The generation API now works either way, but the UI's new behavior is the more optimal flow of including jobParams as a field of POST payload data.
Release note: Fixed a bug with Reporting where it would fail to create a job with a large state in the parameters.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials