[Logs / Metrics] New Platform migration (full cutover)#54583
[Logs / Metrics] New Platform migration (full cutover)#54583Kerry350 merged 162 commits intoelastic:masterfrom
Conversation
- Introduces legacy singletons so that we can use core.http.fetch in the same fashion as kfetch - Migrates to homePlugin.featureCatalogue.register for feature registration - Accesses the data plugin for autocompletion via context - Migrate saved objects client usage to context - At this stage the only 'ui/' imports left are at the top level shim, prior to moving to the NP directory
…ules for public/server imports within common /common code should be refactored in a followup. Common is not for other plugins to import from, just our own internal infra code.
…inal cherry-pick commit)
Co-Authored-By: John Schulz <github.com@jfsiii.org>
…ocations from log categories merge
weltenwort
left a comment
There was a problem hiding this comment.
I've now completed a full review pass. The major outstanding problem is the breakage of the configuration schema. Aside from that most improvements can be handled in follow-up PRs with low risk.
I'm so grateful that you're handling this very complicated migration for us. 👏 This PR gives NP-hard and NP-complete new meanings.
x-pack/test/functional/apps/infra/feature_controls/infrastructure_spaces.ts
Show resolved
Hide resolved
|
Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui) |
jasonrhodes
left a comment
There was a problem hiding this comment.
Looks great to me, thanks again for all your hard work Kerry!
...egacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx
Show resolved
Hide resolved
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
|
Thanks everyone for the reviews, help with implementation, answers to Platform questions etc. If there are any (tricky) conflicts that arise from this please reach out to me if I can help. Tomorrow I'll start writing up the meta followup ticket to this, and will link all individual followup tickets within that so that nothing gets lost / forgotten. It's been emotional NP ❤️ |
* Fully migrates metrics and logs to the NP Co-authored-by: Jason Rhodes <jason.matthew.rhodes@gmail.com> Co-authored-by: John Schulz <github.com@jfsiii.org> Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
|
All followups can now be found and tracked at #58003. |
* Fully migrates metrics and logs to the NP Co-authored-by: Jason Rhodes <jason.matthew.rhodes@gmail.com> Co-authored-by: John Schulz <github.com@jfsiii.org> Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com> Co-authored-by: Jason Rhodes <jason.matthew.rhodes@gmail.com> Co-authored-by: John Schulz <github.com@jfsiii.org> Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Summary
This PR migrates our remaining
ui/new_platformimports on the client side, and then performs the full cutover fromx-pack/legacy/pluginstox-pack/plugins. Whilst a large portion of this PR is just file renames from moving directories, there have been some larger changes.Note: There are some files showing as new files, rather than renames, under "Files changed". Everything was committed as a rename, but some anomalies seem to have snuck in. Things can be verified (as to whether it's actually new code) against the version in
masterwithin thelegacydirectory. Or feel free to ask me.Notable changes
The two most notable changes, and the ones which have the most scope to have introduced subtle bugs or problems are:
Routing has switched from hash based routing to proper browser based routing, the same as Endpoint. Logs and Metrics also have two independent App Ids and App routes now. E.g.
/app/metricsand/app/logs, there is no more/app/infra. A legacy redirect layer has been setup to redirect oldapp/infra#routes to their new locations. This can be removed in 8.0.0 (as a breaking change).Logs and Metrics now have their own independent routers in preparation for the introduction of
ScopedHistorytocore(72641b2).We are now using the Kibana version of
lodash, whereas previously we were using our ownlodash/fpmodule. This is, unfortunately, a really old (v3) version oflodashand some behaviour differs between the two modules. Parameter order is also different for some functions, and we lose the immutability / currying offered bylodash/fp. For the most part parameters have just been moved around, but some gross changes like ed6e5a7 have also been made (in that instanceminandmaxused to returnundefinedfor an empty array, notInfinity).Less notable changes
These changes shouldn't have introduced any quirky behaviour, but are worth mentioning:
We've moved from the legacy Kibana URL utils to the
QueryStringmodule for our query string parsing / encoding. The only behaviour this should have changed is that ordering of params is different now, and therefore a few tests were changed to reflect this.The Obervability telemetry hooks have moved from
infrato the sharedobservabilityplugin (f5f41d7). (useTrackMetric,useTrackPageviewetc). APM uses have also been changed.Shared typings that existed in
x-pack/legacy/commonhave been moved to the shared Observability plugin atx-pack/plugins/observability/public/typings. Right now they are duplicated in both places due toimportrestrictions,x-pack/legacy/commoncan be deleted when all plugins have fully migrated. (3e1547e).Followups
We have tried to be pragmatic with the migration work, getting things working rather than perfect. These are things that should be followed up on down the line:
Right now a
legacyversion of theinfraplugin still exists, this is only to facilitatesavedObjectMappingswhilst they're unavailable in the new platform. OncesavedObjectMappingssupport is fully migrated to NP, we can delete thelegacyfolder in it's entirety.legacy_singletons(d805286) have been added to allow certain portions of code to gain access to new platform features (similar toimport xyz from 'ui/new_platform) where using theuseKibanahook (for proper access tocoreandplugins) would have been hard / time consuming. These uses are all in logs code (none in metrics) and revolve around thecore.http.fetchfunction. These uses should be refactored away over time. We should not add new uses of this going forward. Below is an example of why this was needed, and why refactoring certain areas would have taken longer:legacy_singletons example
==============
legacy_singletonsexample:This example is the log entry rate results hook:
Here's the hook
It uses the
useTrackedPromisehook - and if it were the internals ofuseTrackedPromiseitself that managed the creation of the promise and the actual request initiation it would be fine, as we could just useuseKibanainside ofuseTrackedPromise, but it's not.We could also call
useKibanaat thisuseLogEntryRateResultslevel and pass it as a parameter, but that's not ideal. Instead, we have thecreatePromiseoption. In this instance it calls out tocallGetLogEntryRateAPI.This is
callGetLogEntryRateAPI.Just an
asyncfunction, it's here thathttp.fetchis imported. We're not in any sort of context we can read from hooks here.Metrics doesn't have this issue as the
useHTTPRequesthook is used, which wrapsuseTrackedPromise, and thus access touseKibanais simple.Moving forward logs can either migrate to also using the
useHTTPRequesthook, or some other solution.I do actually like the idea of options for an API call (the path, the body formatting etc) being in separate files. So another idea may be to keep these
callGetLogEntryRateAPIstyle functions, but rather than being responsible for creating a promise and kicking off the request, they could just return an options object, that gets handed off touseHTTPRequest.==============
serverandclientfolders, you may only import from the top level index (i.e. code that is in a contract to share with others). However, this rule also applies to our owncommonfolder. For now// eslint-disable-next-line @kbn/eslint/no-restricted-pathsrules have been added to all the locations where files in ourcommonfolder import fromserverorclient. This isn't 100% ideal as theoretically another plugin could come along and import from here now, however we should be okay as ourcommonfolder is justcommoncode for us. Moving forward we should refactor these uses - code that lives withincommonshouldn't be importing fromclientorserveras it no longer makes itcommon. We should move towards this being for strictlycommoncode (things like HTTP API types). As an example - we currently have React components living withincommon, these should definitely move topublicand so on.Testing
Unfortunately this is one of those cases where changes are far reaching and potentially could have broken anything. Any help with just navigating around, clicking things, filtering, opening sidemenus etc would be appreciated. Basically "just" using the apps 😅
For the testing of the legacy routing redirect layer below is a set of real old style URLs:
Old style URLs
/app/infra#
/app/infra#/home
/app/infra#/infrastructure
/app/infra#/infrastructure/inventory
/app/infra#/infrastructure/metrics-explorer?metricsExplorer=(chartOptions:(stack:!t,type:area,yAxisMode:fromZero),options:(aggregation:max,filterQuery:'',metrics:!((aggregation:max,color:color0,field:system.cpu.user.pct),(aggregation:max,color:color1,field:kubernetes.pod.cpu.usage.node.pct),(aggregation:max,color:color2,field:docker.cpu.total.pct))),timerange:(from:'2020-02-04T07:53:44.588Z',interval:%3E%3D10s,to:'2020-02-04T13:04:22.857Z'))
/app/infra#/infrastructure/settings
/app/infra#/logs
/app/infra#/logs/stream
/app/infra#/logs/stream?flyoutOptions=(flyoutId:!n,flyoutVisibility:hidden,surroundingLogsId:!n)&logPosition=(position:(tiebreaker:82069226,time:1580989944000),streamLive:!f)&logTextview=(textScale:large,wrap:!t)
/app/infra#/logs/log-rate?autoRefresh=(interval:30000,isPaused:!f)&timeRange=(endTime:now,startTime:now-2w)
/app/infra#/logs/log-categories?autoRefresh=(interval:60000,isPaused:!f)&timeRange=(endTime:now,startTime:now-2w)
/app/infra#/logs/settings
/app/infra#/infrastructure/metrics/host/gke-observability-8--observability-8--bc1afd95-cwh3?metricTime=(autoReload:!f,time:(from:'2020-02-06T10:51:04.103Z',interval:%3E%3D1m,to:'2020-02-06T11:51:04.103Z'))
/app/infra#/infrastructure/inventory?waffleFilter=(expression:'host.ip%20%3A%2010.8.2.249',kind:kuery)
/app/infra#/logs?logFilter=(expression:'host.ip%20%3A%2010.8.2.249',kind:kuery)
TODOs
Things that are needed before we can merge:
Fixkueryautocomplete suggestions (WIP)"Application not found" message briefly flashes: Platform Applications flashes "Application Not Found" UI when loading #56409Metrics <-> Logs navigationERROR x-pack/test failed src/plugins/kibana_utils/public/state_management/state_encoder/encode_decode_state.ts:20:35 - error TS7016: Could not find a declaration file for module 'rison-node'.As it's close to being merged utilise Move kuery_autocomplete ⇒ NP #56607, and revert the temporary f44415d fix.Fix routing with new App IDs (metricsandlogs).Log column drag and drop reordering doesn't work(Will be addressed in a separate ticket - [Logs UI] Drag and drop column reordering doesn't always work #57207)Space selector doesn't render (looking into this with Platform)Known problems
These are known issues that we should merge around regardless:
metricsorlogsapp, and then try to click the same app again within the Kibana side navigation, the route will not re-render (so if you were on the/metrics/explorerpage and clicked theMetricsicon in the Kibana navigation the/metricsroute won't render). This is due to [Bug] Possible bugs due to different instances of history in NP apps #53692 and will be fixed with Add ScopedHistory to AppMountParams #56705.