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

Add inventory locator #183418

Merged
merged 9 commits into from
May 17, 2024

Conversation

jennypavlova
Copy link
Member

@jennypavlova jennypavlova commented May 14, 2024

Relates to #176667

Summary

This PR adds an inventory locator and replaces the old redirect logic in RedirectToInventory

Testing

To simulate the usage of link-to use similar params to what alerts link is using, for example:
/app/metrics/link-to/inventory?customMetric=&metric=(type%3Acpu)&nodeType=pod&timestamp=1715703274459
Compare the pages with the edge cluster to make sure that it looks the same as before

@jennypavlova jennypavlova self-assigned this May 14, 2024
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@jennypavlova jennypavlova added Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting labels May 14, 2024
@jennypavlova jennypavlova marked this pull request as ready for review May 14, 2024 16:21
@jennypavlova jennypavlova requested review from a team as code owners May 14, 2024 16:21
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@jennypavlova
Copy link
Member Author

/ci

Copy link
Contributor

@crespocarlos crespocarlos 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 this PR. I haven't tested it yet.

import { Redirect, RouteComponentProps } from 'react-router-dom';

// FIXME what would be the right way to build this query string?
const QUERY_STRING_TEMPLATE =
Copy link
Contributor

Choose a reason for hiding this comment

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

😮

Comment on lines 86 to 90
return {
app: 'metrics',
path: `/inventory?waffleFilter=${paramsWithDefaults.waffleFilter}&waffleTime=${paramsWithDefaults.waffleTime}&waffleOptions=${paramsWithDefaults.waffleOptions}&customMetrics=${paramsWithDefaults.customMetrics}&customOptions=${paramsWithDefaults.customOptions}&groupBy=${paramsWithDefaults.groupBy}&legend=${paramsWithDefaults.legend}&metric=${paramsWithDefaults.metric}&nodeType=${paramsWithDefaults.nodeType}&region=${paramsWithDefaults.region}&sort=${paramsWithDefaults.sort}&timelineOpen=${paramsWithDefaults.timelineOpen}&view=${paramsWithDefaults.view}`,
state: params.state ? params.state : {},
};
Copy link
Contributor

Choose a reason for hiding this comment

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

would this work?

Suggested change
return {
app: 'metrics',
path: `/inventory?waffleFilter=${paramsWithDefaults.waffleFilter}&waffleTime=${paramsWithDefaults.waffleTime}&waffleOptions=${paramsWithDefaults.waffleOptions}&customMetrics=${paramsWithDefaults.customMetrics}&customOptions=${paramsWithDefaults.customOptions}&groupBy=${paramsWithDefaults.groupBy}&legend=${paramsWithDefaults.legend}&metric=${paramsWithDefaults.metric}&nodeType=${paramsWithDefaults.nodeType}&region=${paramsWithDefaults.region}&sort=${paramsWithDefaults.sort}&timelineOpen=${paramsWithDefaults.timelineOpen}&view=${paramsWithDefaults.view}`,
state: params.state ? params.state : {},
};
const queryStringParams = queryString.stringify(paramsWithDefaults);
return {
app: 'metrics',
path: `/inventory?${queryStringParams}`,
state: params.state ? params.state : {},
};

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, thanks 👍 I started with just 3 params then decided to support more in case we need them 😅

Comment on lines 199 to 211
const waffleFilter = rison.encodeUnknown(params.waffleFilter);
const waffleTime = rison.encodeUnknown(params.waffleTime);
const waffleOptions = rison.encodeUnknown(params.waffleOptions);
const customMetrics = rison.encodeUnknown(params.customMetrics);
const customOptions = rison.encodeUnknown(params.customOptions);
const groupBy = rison.encodeUnknown(params.groupBy);
const legend = rison.encodeUnknown(params.legend);
const metric = params.metric;
const nodeType = rison.encodeUnknown(params.nodeType);
const region = rison.encodeUnknown(params.region);
const sort = rison.encodeUnknown(params.sort);
const timelineOpen = rison.encodeUnknown(params.timelineOpen);
const view = rison.encodeUnknown(params.view);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const waffleFilter = rison.encodeUnknown(params.waffleFilter);
const waffleTime = rison.encodeUnknown(params.waffleTime);
const waffleOptions = rison.encodeUnknown(params.waffleOptions);
const customMetrics = rison.encodeUnknown(params.customMetrics);
const customOptions = rison.encodeUnknown(params.customOptions);
const groupBy = rison.encodeUnknown(params.groupBy);
const legend = rison.encodeUnknown(params.legend);
const metric = params.metric;
const nodeType = rison.encodeUnknown(params.nodeType);
const region = rison.encodeUnknown(params.region);
const sort = rison.encodeUnknown(params.sort);
const timelineOpen = rison.encodeUnknown(params.timelineOpen);
const view = rison.encodeUnknown(params.view);
const expected = Object.keys(params).reduce((acc, key) => {
acc[key] = key === 'metric' ? params[key] : rison.encodeUnknown(params[key]);
return acc;
}, {});

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it makes sense, fixed! Sorry about those I was testing with different things and with/without encoding and forgot to remove and fix that.


expect(app).toBe('metrics');
expect(path).toBe(
`/inventory?waffleFilter=${waffleFilter}&waffleTime=${waffleTime}&waffleOptions=${waffleOptions}&customMetrics=${customMetrics}&customOptions=${customOptions}&groupBy=${groupBy}&legend=${legend}&metric=${metric}&nodeType=${nodeType}&region=${region}&sort=${sort}&timelineOpen=${timelineOpen}&view=${view}`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should also work here

Suggested change
`/inventory?waffleFilter=${waffleFilter}&waffleTime=${waffleTime}&waffleOptions=${waffleOptions}&customMetrics=${customMetrics}&customOptions=${customOptions}&groupBy=${groupBy}&legend=${legend}&metric=${metric}&nodeType=${nodeType}&region=${region}&sort=${sort}&timelineOpen=${timelineOpen}&view=${view}`
`/inventory?queryString.stringify(expected);`


expect(app).toBe('metrics');
expect(path).toBe(
`/inventory?waffleFilter=${waffleFilter}&waffleTime=${waffleTime}&waffleOptions=${waffleOptions}&customMetrics=${customMetrics}&customOptions=${customOptions}&groupBy=${groupBy}&legend=${legend}&metric=${metric}&nodeType=${nodeType}&region=${region}&sort=${sort}&timelineOpen=${timelineOpen}&view=${view}`
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Comment on lines 72 to 73
customMetrics: params.customMetrics || rison.encodeUnknown(''),
customOptions: params.customOptions || rison.encodeUnknown(''),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is needed rison.encodeUnknown('') needed?

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 adds '' (so &customMetrics=''&customOptions='') in the URL otherwise 🤷‍♀️ I think I can just leave the customMetrics: params.customMetrics to avoid that

@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label May 15, 2024
@jennypavlova
Copy link
Member Author

@crespocarlos Thank you for the review! I think I fixed the things you mentioned, thanks for the suggestions. Can you please check it again?

Copy link
Contributor

@crespocarlos crespocarlos left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the changes.

@kibana-ci
Copy link
Collaborator

kibana-ci commented May 17, 2024

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
observabilityShared 199 203 +4

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
observabilityShared 349 350 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
infra 1.5MB 1.5MB -348.0B
observabilityShared 54.9KB 54.9KB +4.0B
total -344.0B

Canvas Sharable Runtime

The Canvas "shareable runtime" is an bundle produced to enable running Canvas workpads outside of Kibana. This bundle is included in third-party webpages that embed canvas and therefor should be as slim as possible.

id before after diff
module count - 5405 +5405
total size - 8.8MB +8.8MB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
infra 105.1KB 105.1KB -2.0B
observabilityShared 64.6KB 67.4KB +2.8KB
total +2.8KB
Unknown metric groups

API count

id before after diff
observabilityShared 354 355 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jennypavlova

@jennypavlova jennypavlova enabled auto-merge (squash) May 17, 2024 10:51
@jennypavlova jennypavlova merged commit 85639f6 into elastic:main May 17, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants