forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for indices before enabling get search profile in serverless (e…
…lastic#201630) Closes [elastic#195342](elastic#195342) ## Summary In serverless, the default query for the search profiler fails if there is not indices. For avoiding this error, when there are no indices present, this PR disabled the "Profile" button and add a tooltip explaining why it is disabled. ### New strings This is the tooltip for string verification @kibana-docs [[Code](https://github.com/elastic/kibana/pull/201630/commits/5832a76683ad0cf55558655ca5981d623f344b72?diff=unified&w=0#diff-bf48cd9834b39a2a1634680225fc63c9a4ddb3ca881d9120f648006ad0277046R154-R1552?diff=unified&w=0#diff-bf48cd9834b39a2a1634680225fc63c9a4ddb3ca881d9120f648006ad0277046R155)]: <img width="460" alt="Screenshot 2024-11-25 at 16 15 08" src="https://github.com/user-attachments/assets/a3395cfb-fc5e-4c22-9dd8-954a60fd1b5d"> ### How to test * Run Kibana in serverless * Go to Index Management and verify you haven't indices (or delete them if you do have indices). * Go to Dev Tools and click the Search Profiler tab. Verify that the button is disabled and the tooltip displayed if you hover over it. * Go back to Index Management and create one or more indices. * Go back to Dev Tools > Search Profiler. Now the button should be enabled and the profile should be created if you click it. ### Demo https://github.com/user-attachments/assets/9bda072e-7897-4418-a906-14807e736c44 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
d438fb2
commit 4af76d8
Showing
8 changed files
with
130 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
*/ | ||
|
||
export { useRequestProfile } from './use_request_profile'; | ||
export { useHasIndices } from './use_has_indices'; |
22 changes: 22 additions & 0 deletions
22
x-pack/plugins/searchprofiler/public/application/hooks/use_has_indices.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { useRequest } from '@kbn/es-ui-shared-plugin/public'; | ||
import { API_BASE_PATH } from '../../../common/constants'; | ||
import { useAppContext } from '../contexts/app_context'; | ||
|
||
interface ReturnValue { | ||
hasIndices: boolean; | ||
} | ||
|
||
export const useHasIndices = () => { | ||
const { http } = useAppContext(); | ||
return useRequest<ReturnValue>(http, { | ||
path: `${API_BASE_PATH}/has_indices`, | ||
method: 'get', | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
x-pack/test/api_integration/apis/management/index_management/searchprofiler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import expect from 'expect'; | ||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
const API_BASE_PATH = '/api/searchprofiler'; | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
|
||
describe('Searchprofiler', function () { | ||
it('Can retrive has indices', async () => { | ||
const { body } = await supertest.get(`${API_BASE_PATH}/has_indices`).expect(200); | ||
expect(body).toStrictEqual({ hasIndices: true }); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters