-
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
[Infra UI] Fix Metrics Explorer UI and Server Exceptions #39368
[Infra UI] Fix Metrics Explorer UI and Server Exceptions #39368
Conversation
Pinging @elastic/infra-logs-ui |
…xplorer-timestamp-exception
💔 Build Failed |
…xplorer-timestamp-exception
💚 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.
Not sure if it is related, but I'm seeing this when loading the Metrics Explorer without metricbeat indices:
TypeError: Cannot read property 'series' of undefined
at series (kibana/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/populate_series_with_tsvb_data.ts:75:41)
at process._tickCallback (internal/process/next_tick.js:68:7)
x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx
Outdated
Show resolved
Hide resolved
…xplorer-timestamp-exception
💔 Build Failed |
@weltenwort I was able to reproduce the exception when the Metricbeat indices where missing. I also added a test to ensure both group by and non group by requests work with the missing indices. |
💔 Build Failed |
💔 Build Failed |
retest |
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.
That seems to do it. I checked that the tests would have caught the status code 500 without the latest fix. Great that you added them 👍
I left two questions below, but they are no merge blockers.
@@ -30,6 +30,9 @@ export const initMetricExplorerRoute = (libs: InfraBackendLibs) => { | |||
const options = req.payload; | |||
// First we get the groupings from a composite aggregation | |||
const response = await getGroupings(search, options); | |||
if (response.series.length === 0) { |
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.
If response.series
is an array of length 0
, the map
operation below would be a no-op. Why do we need to explicitly handle that case here?
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 I put that in when I was looking at the group by use case. I can remove it.
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.
FYI: I'm going to remove this, merge master, and push to see how CI does.
@@ -58,6 +58,15 @@ export const populateSeriesWithTSVBData = ( | |||
// Get TSVB results using the model, timerange and filters | |||
const tsvbResults = await framework.makeTSVBRequest(req, model, timerange, filters); | |||
|
|||
// If there is no data `custom` will not exist. | |||
if (!tsvbResults.custom) { |
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.
Out of curiosity, why is this called custom
? It suggests there's something predefined that we override?
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.
It's just a known attribute, it could be anything we want it to be.
💔 Build Failed |
retest |
💔 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.
Apologies to chime in sideways here -- has this been tested with spaces?
@@ -157,6 +157,8 @@ export class InfraKibanaBackendFrameworkAdapter implements InfraBackendFramework | |||
url = `/s/${spaceId}${url}`; | |||
} | |||
} | |||
const basePath = internalRequest.getBasePath(); | |||
url = `${basePath}${url}`; |
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.
Has this been tested with spaces? If I remember correctly, basePath
contains the spaces part already -- see the discussion in #36765
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 point - I don't think I checked that during my review
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.
@skh @weltenwort that other discussion seems to imply that this shouldn't work even without spaces, if there's a base path (because server.inject()
puts the URL after the basepath, so you'd get the basepath in the full URL twice I think?) -- if this does work without spaces, seems like we can use this instead of getting the space ID in other places in this file?
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.
Wasn't the cause for this bug the fact the behavior of server.inject
changed to no include the base path since #39049? 🤔
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.
In that case, it sounds like we can simplify a lot of stuff in this file 🤞@legrego from the other discussion said:
can you use internalRequest.getBasePath() instead of deriving a space-aware URL yourself?
If that works, this should become something like
let url = `${internalRequest.getBasePath()}/api/metrics/vis/data`;
and then you can remove the check for the spaces plugin altogether.
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.
Verifying the spaces use-case now :)
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.
Fixed here: b0a8314
x-pack/legacy/plugins/infra/public/components/metrics_explorer/chart.tsx
Show resolved
Hide resolved
💚 Build Succeeded |
💔 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.
Thanks for checking with spaces.
const basePath = internalRequest.getBasePath(); | ||
url = `${basePath}${url}`; | ||
const url = `${basePath}/api/metrics/vis/data`; |
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.
👍
retest |
💚 Build Succeeded |
…rom PR's (elastic#39368) * Fixing exceptions thrown by missing data and missing basePath * Moving dateFormatter to use useMemo instead of useCallback * Improve no-data handling * Adding tests for no-data scenerio * Return empty series when TSVB returns an empty response; update tests * Removes unnecessary early return * Fixes spaces regression by removing custom space detection
…rom PR's (#39368) (#39830) * Fixing exceptions thrown by missing data and missing basePath * Moving dateFormatter to use useMemo instead of useCallback * Improve no-data handling * Adding tests for no-data scenerio * Return empty series when TSVB returns an empty response; update tests * Removes unnecessary early return * Fixes spaces regression by removing custom space detection
💚 Build Succeeded |
Summary
This PR fixed bugs introduced in #39090 and #39049 that slipped through. The first one only showed up if you loaded the Metrics Explorer without any data. The second one showed up once the first one was fixed and I just couldn't leave it alone because it was an easy fix.
To test this:
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.This was checked for cross-browser compatibility, including a check against IE11Any text added follows EUI's writing guidelines, uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)Documentation was added for features that require explanation or tutorialsUnit or functional tests were updated or added to match the most common scenariosThis was checked for keyboard-only and screenreader accessibility