-
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
[Rollups] Server NP migration #55606
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
aa7356c
to
ed8e4e9
Compare
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.
TSVB and Visualize integrations still working fine 👍
usageCollection, | ||
metrics, | ||
__LEGACY: { | ||
route: server.route.bind(server), |
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.
Is this used anywhere? couldn't find a reference.
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.
Good catch. You're right, it's not needed anymore.
const requests = request.body.map(({ index, query }: { index: string; query: any }) => | ||
callWithRequest('rollup.search', { | ||
index, | ||
rest_total_hits_as_int: true, |
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.
Just as a side note - AFAIK rest_total_hits_as_int
will get deprecated with 8.0, so this has to be handled differently in future.
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.
Thanks for the heads up! Do you know if there is an issue open somewhere to track this?
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.
This seems to be the main one: #26356
@elasticmachine merge upstream |
return elasticsearchService.createClient('rollup', config); | ||
}); | ||
|
||
export const callWithRequestFactory = ( |
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.
Do we need this factory? In my PR, I've used it directly from the router context
https://github.com/elastic/kibana/pull/56829/files#diff-178c0726cd4b1e7299f257e5069b4a42R28
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.
Thanks for sharing! I'm going to leave as is for now, but will consider changing this in my next PR.
import { LICENSE_STATUS_VALID } from '../../../../../common/constants/license_status'; | ||
import { ServerShim } from '../../types'; | ||
|
||
export const licensePreRoutingFactory = ( |
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 wonder if we should first agree on the solution for this or if we should merge this PR and change it later.
I would think it would be good to first agree on a common pattern (probably a class exposed) to avoid copy/pasting this code + the tests in all our apps.
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 think that is a fair point. The logic for isEsError
could probably be moved to a shared space too.
I don't think we need to block this PR though. This work will need to be updated again when the licensing
plugin is used and then it can just use the new pattern we have adopted.
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 agree with @jloleysens. I'd prefer not to block this PR and address when I finish the migration for rollups and adopt the NP licensing plugin.
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.
Code
Left non-blocker comments.
UX/UI
I tested CRUD of rollups and that seemed to work. Not sure how to test integration with Index Patterns?
Overall everything worked as expected!
import { LICENSE_STATUS_VALID } from '../../../../../common/constants/license_status'; | ||
import { ServerShim } from '../../types'; | ||
|
||
export const licensePreRoutingFactory = ( |
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 think that is a fair point. The logic for isEsError
could probably be moved to a shared space too.
I don't think we need to block this PR though. This work will need to be updated again when the licensing
plugin is used and then it can just use the new pattern we have adopted.
) => | ||
class RollupSearchStrategy extends AbstractSearchStrategy { | ||
name = 'rollup'; | ||
|
||
constructor(server) { | ||
constructor(server: ElasticsearchServiceSetup) { |
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.
Nit, we should consider renaming server
to something else. Perhaps elasticsearchService
, just to clean up what looks like a legacy reference.
deps.router.get( | ||
{ | ||
path: '/api/index_patterns/rollup/_fields_for_wildcard', | ||
validate: { |
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.
Nit; If you would like to re-use the type information of the query validations you can move this object to outside of the register function:
import { TypeOf } from '@kbn/config-schema';
const queryValidation = schema.object({...});
type RouteQuery = TypeOf<typeof queryValidation>;
...
const handler: RequestHandler<unknown, RouteQuery> = ...
...
validate: { query: queryValidation },
...
try { | ||
parsedFields = parseMetaFields(metaFields); | ||
} catch (error) { | ||
return response.badRequest(); |
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.
Does the above error
have useful information we can send back in the response body?
this.log = initializerContext.logger.get(); | ||
} | ||
|
||
async setup( |
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.
@rudolf informed me that async setup
is going to be deprecated, so everything in setup phase for plugins should be synchronous. Not sure it is worth making the changes here though, just wanted to flag this.
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.
Leaving as is for now.
@elasticmachine merge upstream |
@elasticsearchmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…t-state * upstream/master: (96 commits) top nav ts arg support (elastic#56984) [SIEM][detection engine] Limit network rules to filebeat source semantics (elastic#57130) Add docs for alerting and action settings (elastic#57035) Add Test to Verify Endpoint App Landing Page (elastic#57129) Update `markdown-to-jsx` (`6.9.3` → `6.11.0`) and `url-parse` (`1.4.4` → `1.4.7`) dependencies. (elastic#57126) chore(NA): removes use of parallel option in the terser minimizer (elastic#57077) [ML] New Platform server shim: update file data visualizer routes to use new platform router (elastic#56972) Specifying valid licenses for the Graph feature (elastic#55911) [APM][docs] Add troubleshooting for non-indexed fields (elastic#54948) [ML] DF Analytics creation: update schema definition for create route (elastic#56979) Remove Kibana a11y guide in favor of EUI (elastic#57021) [Logs UI] Set streamLive false in URL state when arriving from link-to (elastic#56329) [docs] Fix spaces api example json (elastic#50411) Add new config for filebeat index name (elastic#56920) [Metrics-UI] Fix toolbar popover for metrics table row (elastic#56796) Saved Objects testing (elastic#56965) Disabled categorization stats validation (elastic#57087) [Rollups] Server NP migration (elastic#55606) [Metrics UI] Limit group by selector to only 2 fields (elastic#56800) fix auto closing new vis modal when navigating to lens or when navigating away with browser history (elastic#56998) ...
* master: (96 commits) top nav ts arg support (elastic#56984) [SIEM][detection engine] Limit network rules to filebeat source semantics (elastic#57130) Add docs for alerting and action settings (elastic#57035) Add Test to Verify Endpoint App Landing Page (elastic#57129) Update `markdown-to-jsx` (`6.9.3` → `6.11.0`) and `url-parse` (`1.4.4` → `1.4.7`) dependencies. (elastic#57126) chore(NA): removes use of parallel option in the terser minimizer (elastic#57077) [ML] New Platform server shim: update file data visualizer routes to use new platform router (elastic#56972) Specifying valid licenses for the Graph feature (elastic#55911) [APM][docs] Add troubleshooting for non-indexed fields (elastic#54948) [ML] DF Analytics creation: update schema definition for create route (elastic#56979) Remove Kibana a11y guide in favor of EUI (elastic#57021) [Logs UI] Set streamLive false in URL state when arriving from link-to (elastic#56329) [docs] Fix spaces api example json (elastic#50411) Add new config for filebeat index name (elastic#56920) [Metrics-UI] Fix toolbar popover for metrics table row (elastic#56796) Saved Objects testing (elastic#56965) Disabled categorization stats validation (elastic#57087) [Rollups] Server NP migration (elastic#55606) [Metrics UI] Limit group by selector to only 2 fields (elastic#56800) fix auto closing new vis modal when navigating to lens or when navigating away with browser history (elastic#56998) ...
This PR starts the NP migration of the rollup jobs server code. It also converts the server code to TS.
Things to note:
index_patterns
route was usingserver.inject()
. I removed this and pulled inIndexPatternsFetcher
directly from theindex_patterns
plugin.What to test
What's left in order to migrate out of legacy