Skip to content
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

Merged

Conversation

simianhacker
Copy link
Member

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:

  • Load everything in master
  • See the metrics explorer fail along with a metrics detail page
  • Load this PR
  • Everything should be working as expected

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

@simianhacker simianhacker added bug Fixes for quality problems that affect the customer experience review Feature:Metrics UI Metrics UI feature v8.0.0 Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services release_note:skip Skip the PR/issue when compiling release notes v7.3.0 labels Jun 20, 2019
@simianhacker simianhacker requested a review from a team June 20, 2019 18:28
@simianhacker simianhacker self-assigned this Jun 20, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/infra-logs-ui

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@weltenwort weltenwort requested review from weltenwort and removed request for a team June 21, 2019 09:42
Copy link
Member

@weltenwort weltenwort left a 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)

@simianhacker simianhacker requested a review from a team as a code owner June 21, 2019 13:37
@elasticmachine
Copy link
Contributor

💔 Build Failed

@simianhacker simianhacker requested a review from weltenwort June 21, 2019 15:11
@simianhacker
Copy link
Member Author

@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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@simianhacker
Copy link
Member Author

retest

Copy link
Member

@weltenwort weltenwort left a 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) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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) {
Copy link
Member

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?

Copy link
Member Author

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@simianhacker
Copy link
Member Author

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@skh skh left a 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}`;
Copy link
Contributor

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

Copy link
Member

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

Copy link
Member

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?

Copy link
Member

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? 🤔

Copy link
Member

@jasonrhodes jasonrhodes Jun 24, 2019

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.

Copy link
Member

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 :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: b0a8314

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@skh skh left a 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`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jasonrhodes
Copy link
Member

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@jasonrhodes jasonrhodes merged commit 16ae71d into elastic:master Jun 25, 2019
jasonrhodes pushed a commit to jasonrhodes/kibana that referenced this pull request Jun 27, 2019
…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
jasonrhodes added a commit that referenced this pull request Jun 28, 2019
…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
@jasonrhodes jasonrhodes changed the title [Infra UI] Fix Metrics Explorer UI and Server Exceptions introduced from PR's [Infra UI] Fix Metrics Explorer UI and Server Exceptions Jul 5, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@simianhacker simianhacker deleted the fix-metrics-explorer-timestamp-exception branch April 17, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Metrics UI Metrics UI feature release_note:skip Skip the PR/issue when compiling release notes review Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.3.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants