-
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] Honour space when querying TSVB API #36765
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,8 +149,17 @@ export class InfraKibanaBackendFrameworkAdapter implements InfraBackendFramework | |
) { | ||
const internalRequest = req[internalInfraFrameworkRequest]; | ||
const server = internalRequest.server; | ||
|
||
let url = '/api/metrics/vis/data'; | ||
if (server.plugins.spaces) { | ||
const spaceId = server.plugins.spaces.getSpaceId(internalRequest); | ||
if (spaceId !== 'default') { | ||
url = `/s/${spaceId}${url}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the drive-by review, I saw it come across in slack: I don't fully understand this code, but can you use 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. Alternatively, if it's possible to make this request client-side, then you can get space-aware URLs for free there too. This would have the benefit of "just working" when you migrate to the New Platform too, as I don't expect they'll want to expose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are very valid comments, thank you. The issue here is that The request is server-side because we're hiding the functionality behind a GraphQL endpoint. I agree this is something we need to tackle for the new platform, but that's beyond the scope of this bugfix. @simianhacker what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for clarifying @skh, I hadn't considered the server base path being stripped out of the I totally understand that refactoring is out of scope for this PR 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume after the Platform refactor/upgrade we will need to re-evaluate how the internal requests work. I'm sure the platform team will provide guidance on how they expect this to work. |
||
} | ||
} | ||
|
||
const request = { | ||
url: '/api/metrics/vis/data', | ||
url, | ||
method: 'POST', | ||
headers: internalRequest.headers, | ||
payload: { | ||
|
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.
Please note that I don't really know if this is necessary or not, i.e. if there could ever be a situation with the TSVB API not being available anyway when we are. It works without this change now, but requiring it feels cleaner.