Skip to content

Commit

Permalink
Merge branch 'main' into flaky-test-runner-exceptions-entry-and_rule_…
Browse files Browse the repository at this point in the history
…details_flow
  • Loading branch information
jpdjere authored Oct 23, 2023
2 parents fe33b95 + 2384636 commit b814183
Show file tree
Hide file tree
Showing 25 changed files with 414 additions and 207 deletions.
11 changes: 11 additions & 0 deletions docs/api/uptime-api.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[uptime-apis]]
== Uptime APIs

The following APIs are available for Uptime.

* <<get-settings-api, Get settings API>> to get a settings

* <<update-settings-api, Update settings API>> to update the attributes for existing settings

include::uptime/get-settings.asciidoc[leveloffset=+1]
include::uptime/update-settings.asciidoc[leveloffset=+1]
39 changes: 39 additions & 0 deletions docs/api/uptime/get-settings.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[[get-settings-api]]
== Get settings API
++++
<titleabbrev>Get settings</titleabbrev>
++++

Retrieve uptime settings existing settings.

[[get-settings-api-request]]
=== {api-request-title}

`GET <kibana host>:<port>/api/uptime/settings`

`GET <kibana host>:<port>/s/<space_id>/api/uptime/settings`

=== {api-prereq-title}

You must have `read` privileges for the *uptime* feature in *{observability}* section of the
<<kibana-feature-privileges,{kib} feature privileges>>.

The API returns the following:

[source,sh]
--------------------------------------------------
{
"heartbeatIndices": "heartbeat-8*",
"certExpirationThreshold": 30,
"certAgeThreshold": 730,
"defaultConnectors": [
"08990f40-09c5-11ee-97ae-912b222b13d4",
"db25f830-2318-11ee-9391-6b0c030836d6"
],
"defaultEmail": {
"to": [],
"cc": [],
"bcc": []
}
}
--------------------------------------------------
117 changes: 117 additions & 0 deletions docs/api/uptime/update-settings.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
[[update-settings-api]]
== Update settings API
++++
<titleabbrev>Update settings</titleabbrev>
++++

Updates uptime settings attributes like heartbeatIndices, certExpirationThreshold, certAgeThreshold, defaultConnectors or defaultEmail

=== {api-request-title}

`PUT <kibana host>:<port>/api/uptime/settings`

`PUT <kibana host>:<port>/s/<space_id>/api/uptime/settings`

=== {api-prereq-title}

You must have `all` privileges for the *uptime* feature in *{observability}* section of the
<<kibana-feature-privileges,{kib} feature privileges>>.

[[settings-api-update-path-params]]
==== Path parameters

`space_id`::
(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used.

[[api-update-request-body]]
==== Request body

A partial update is supported, provided settings keys will be merged with existing settings.

`heartbeatIndices`::
(Optional, string) index pattern string to be used within uptime app/alerts to query heartbeat data. Defaults to `heartbeat-*`.


`certExpirationThreshold`::
(Optional, number) Number of days before a certificate expires to trigger an alert. Defaults to `30`.

`certAgeThreshold`::
(Optional, number) Number of days after a certificate is created to trigger an alert. Defaults to `730`.

`defaultConnectors`::
(Optional, array) List of connector IDs to be used as default connectors for new alerts. Defaults to `[]`.

`defaultEmail`::
(Optional, object) Default email configuration for new alerts. Defaults to `{"to": [], "cc": [], "bcc": []}`.

[[settings-api-update-example]]
==== Example

[source,sh]
--------------------------------------------------
PUT api/uptime/settings
{
"heartbeatIndices": "heartbeat-8*",
"certExpirationThreshold": 30,
"certAgeThreshold": 730,
"defaultConnectors": [
"08990f40-09c5-11ee-97ae-912b222b13d4",
"db25f830-2318-11ee-9391-6b0c030836d6"
],
"defaultEmail": {
"to": [],
"cc": [],
"bcc": []
}
}
--------------------------------------------------

The API returns the following:

[source,json]
--------------------------------------------------
{
"heartbeatIndices": "heartbeat-8*",
"certExpirationThreshold": 30,
"certAgeThreshold": 730,
"defaultConnectors": [
"08990f40-09c5-11ee-97ae-912b222b13d4",
"db25f830-2318-11ee-9391-6b0c030836d6"
],
"defaultEmail": {
"to": [],
"cc": [],
"bcc": []
}
}
--------------------------------------------------
[[settings-api-partial-update-example]]
==== Partial update example

[source,sh]
--------------------------------------------------
PUT api/uptime/settings
{
"heartbeatIndices": "heartbeat-8*",
}
--------------------------------------------------

The API returns the following:

[source,json]
--------------------------------------------------
{
"heartbeatIndices": "heartbeat-8*",
"certExpirationThreshold": 30,
"certAgeThreshold": 730,
"defaultConnectors": [
"08990f40-09c5-11ee-97ae-912b222b13d4",
"db25f830-2318-11ee-9391-6b0c030836d6"
],
"defaultEmail": {
"to": [],
"cc": [],
"bcc": []
}
}
--------------------------------------------------
1 change: 1 addition & 0 deletions docs/user/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ include::{kib-repo-dir}/api/osquery-manager.asciidoc[]
include::{kib-repo-dir}/api/short-urls.asciidoc[]
include::{kib-repo-dir}/api/task-manager/health.asciidoc[]
include::{kib-repo-dir}/api/upgrade-assistant.asciidoc[]
include::{kib-repo-dir}/api/uptime-api.asciidoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { createTestServers } from '@kbn/core-test-helpers-kbn-server';
import { MIGRATION_CLIENT_OPTIONS } from '@kbn/core-saved-objects-migration-server-internal';
import { runActionTestSuite } from './actions_test_suite';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export const runActionTestSuite = ({
{ _source: { title: 'doc 3' } },
{ _source: { title: 'saved object 4', type: 'another_unused_type' } },
{ _source: { title: 'f-agent-event 5', type: 'f_agent_event' } },
{ _source: { title: new Array(1000).fill('a').join(), type: 'large' } }, // "large" saved object
{
_source: { title: new Array(1000).fill('a').join(), type: 'large' },
}, // "large" saved objects
] as unknown as SavedObjectsRawDoc[];
await bulkOverwriteTransformedDocuments({
client,
Expand All @@ -113,6 +115,27 @@ export const runActionTestSuite = ({
refresh: 'wait_for',
})();

await createIndex({
client,
indexName: 'existing_index_with_100k_docs',
aliases: ['existing_index_with_100k_docs_alias'],
esCapabilities,
mappings: {
dynamic: true,
properties: {},
},
})();
const docs100k = new Array(100000).fill({
_source: { title: new Array(1000).fill('a').join(), type: 'large' },
}) as unknown as SavedObjectsRawDoc[]; // 100k "large" saved objects

await bulkOverwriteTransformedDocuments({
client,
index: 'existing_index_with_100k_docs',
operations: docs100k.map((doc) => createBulkIndexOperationTuple(doc)),
refresh: 'wait_for',
})();

await createIndex({
client,
indexName: 'existing_index_2',
Expand Down Expand Up @@ -756,8 +779,7 @@ export const runActionTestSuite = ({

// Reindex doesn't return any errors on it's own, so we have to test
// together with waitForReindexTask
// Failing: See https://github.com/elastic/kibana/issues/166190
describe.skip('reindex & waitForReindexTask', () => {
describe('reindex & waitForReindexTask', () => {
it('resolves right when reindex succeeds without reindex script', async () => {
const res = (await reindex({
client,
Expand Down Expand Up @@ -1122,15 +1144,16 @@ export const runActionTestSuite = ({
it('resolves left wait_for_task_completion_timeout when the task does not finish within the timeout', async () => {
const readyTaskRes = await waitForIndexStatus({
client,
index: 'existing_index_with_docs',
index: 'existing_index_with_100k_docs',
status: 'yellow',
timeout: '300s',
})();

expect(Either.isRight(readyTaskRes)).toBe(true);

const res = (await reindex({
client,
sourceIndex: 'existing_index_with_docs',
sourceIndex: 'existing_index_with_100k_docs',
targetIndex: 'reindex_target',
reindexScript: Option.none,
requireAlias: false,
Expand Down Expand Up @@ -1428,8 +1451,7 @@ export const runActionTestSuite = ({
});
});

// Failing: See https://github.com/elastic/kibana/issues/166199
describe.skip('waitForPickupUpdatedMappingsTask', () => {
describe('waitForPickupUpdatedMappingsTask', () => {
it('rejects if there are failures', async () => {
const res = (await pickupUpdatedMappings(
client,
Expand Down Expand Up @@ -1469,7 +1491,7 @@ export const runActionTestSuite = ({
it('resolves left wait_for_task_completion_timeout when the task does not complete within the timeout', async () => {
const res = (await pickupUpdatedMappings(
client,
'existing_index_with_docs',
'existing_index_with_100k_docs',
1000
)()) as Either.Right<UpdateByQueryResponse>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/

import {
AI_SEARCH_PLUGIN,
ANALYTICS_PLUGIN,
APP_SEARCH_PLUGIN,
WORKPLACE_SEARCH_PLUGIN,
ENTERPRISE_SEARCH_CONTENT_PLUGIN,
SEARCH_EXPERIENCES_PLUGIN,
SEARCH_PRODUCT_NAME,
AI_SEARCH_PLUGIN,
VECTOR_SEARCH_PLUGIN,
WORKPLACE_SEARCH_PLUGIN,
} from '../../../../common/constants';

/**
Expand Down Expand Up @@ -53,3 +54,6 @@ export const aiSearchTitle = (page: Title = []) => generateTitle([...page, AI_SE

export const vectorSearchTitle = (page: Title = []) =>
generateTitle([...page, VECTOR_SEARCH_PLUGIN.NAME]);

export const enterpriseSearchContentTitle = (page: Title = []) =>
generateTitle([...page, ENTERPRISE_SEARCH_CONTENT_PLUGIN.NAME]);
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ import {
useVectorSearchBreadcrumbs,
} from './generate_breadcrumbs';
import {
searchTitle,
aiSearchTitle,
analyticsTitle,
elasticsearchTitle,
appSearchTitle,
workplaceSearchTitle,
elasticsearchTitle,
enterpriseSearchContentTitle,
searchExperiencesTitle,
aiSearchTitle,
searchTitle,
vectorSearchTitle,
workplaceSearchTitle,
} from './generate_title';

/**
Expand Down Expand Up @@ -163,7 +164,7 @@ export const SetEnterpriseSearchContentChrome: React.FC<SetChromeProps> = ({ tra
const { setBreadcrumbs, setDocTitle } = useValues(KibanaLogic);

const title = reverseArray(trail);
const docTitle = appSearchTitle(title);
const docTitle = enterpriseSearchContentTitle(title);

const crumbs = useGenerateBreadcrumbs(trail);
const breadcrumbs = useEnterpriseSearchContentBreadcrumbs(crumbs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,15 @@ export const UPDATE_PANEL_GO_TO_DISMISS = i18n.translate(
export const getMaxSpaceTitle = (maxSpaces: number) =>
i18n.translate('xpack.securitySolution.riskScore.maxSpacePanel.title', {
defaultMessage:
'Entity Risk Scoring in the current version can run in {maxSpaces, plural, =1 {# Kibana space} other {# Kibana spaces}}',
'You cannot enable entity risk scoring in more than {maxSpaces, plural, =1 {# Kibana space} other {# Kibana spaces}}.',
values: { maxSpaces },
});

export const MAX_SPACE_PANEL_MESSAGE = i18n.translate(
'xpack.securitySolution.riskScore.maxSpacePanel.message',
{
defaultMessage: 'Please disable a currently running engine before enabling it here.',
defaultMessage:
'You can disable entity risk scoring in the space it is currently enabled before enabling it in this space',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ export enum SYNTHETICS_API_URLS {
SYNTHETICS_MONITORS_PROJECT_UPDATE = '/api/synthetics/project/{projectName}/monitors/_bulk_update',
SYNTHETICS_MONITORS_PROJECT_DELETE = '/api/synthetics/project/{projectName}/monitors/_bulk_delete',

DYNAMIC_SETTINGS = `/internal/uptime/dynamic_settings`,
DYNAMIC_SETTINGS = `/api/uptime/settings`,
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ journey('OverviewScrolling', async ({ page, params }) => {
const listOfRequests: string[] = [];
const expected = [
'http://localhost:5620/internal/synthetics/service/enablement',
'http://localhost:5620/internal/uptime/dynamic_settings',
'http://localhost:5620/internal/synthetics/monitor/filters',
'http://localhost:5620/internal/uptime/service/locations',
'http://localhost:5620/internal/synthetics/overview?sortField=status&sortOrder=asc&',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,29 @@ import {
import { SYNTHETICS_API_URLS } from '../../../../../common/constants';
import { LocationMonitor } from '.';

const apiPath = SYNTHETICS_API_URLS.DYNAMIC_SETTINGS;

interface SaveApiRequest {
settings: DynamicSettings;
}

export const getDynamicSettings = async (): Promise<DynamicSettings> => {
return await apiService.get(apiPath, undefined, DynamicSettingsCodec);
return await apiService.get(
SYNTHETICS_API_URLS.DYNAMIC_SETTINGS,
{ version: '2023-10-31' },
DynamicSettingsCodec
);
};

export const setDynamicSettings = async ({
settings,
}: SaveApiRequest): Promise<DynamicSettingsSaveResponse> => {
return await apiService.post(apiPath, settings, DynamicSettingsSaveCodec);
return await apiService.put(
SYNTHETICS_API_URLS.DYNAMIC_SETTINGS,
settings,
DynamicSettingsSaveCodec,
{
version: '2023-10-31',
}
);
};

export const fetchLocationMonitors = async (): Promise<LocationMonitor[]> => {
Expand Down
Loading

0 comments on commit b814183

Please sign in to comment.