@@ -97,7 +92,7 @@ export const ConnectorSyncRules: React.FC = () => {
})}
-
+
{i18n.translate(
'xpack.enterpriseSearch.index.connector.syncRules.syncRulesLabel',
{
@@ -191,7 +186,7 @@ export const ConnectorSyncRules: React.FC = () => {
)}
-
+
{i18n.translate(
'xpack.enterpriseSearch.content.index.connector.syncRules.advancedFiltersLinkTitle',
{
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/sync_rules/edit_sync_rules_flyout.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/sync_rules/edit_sync_rules_flyout.tsx
index 779c3ec9e8bee..d1e10d21a5421 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/sync_rules/edit_sync_rules_flyout.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/sync_rules/edit_sync_rules_flyout.tsx
@@ -25,8 +25,6 @@ import { i18n } from '@kbn/i18n';
import { FilteringValidation } from '@kbn/search-connectors';
-import { BetaCallOut } from '../../../../../shared/beta/beta_callout';
-
import { AdvancedSyncRules } from './advanced_sync_rules';
import { EditSyncRulesTab } from './edit_sync_rules_tab';
import { SyncRulesTable } from './editable_basic_rules_table';
@@ -106,16 +104,6 @@ export const EditSyncRulesFlyout: React.FC = ({
-
-
{i18n.translate(
'xpack.enterpriseSearch.content.index.connector.syncRules.flyout.description',
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/sync_rules/editable_basic_rules_table.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/sync_rules/editable_basic_rules_table.tsx
index 7aebd9de94df4..5cd4dc00ee916 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/sync_rules/editable_basic_rules_table.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/connector/sync_rules/editable_basic_rules_table.tsx
@@ -80,7 +80,7 @@ export const SyncRulesTable: React.FC = () => {
values: { indexName },
})}
-
+
{i18n.translate('xpack.enterpriseSearch.content.index.connector.syncRules.link', {
defaultMessage: 'Learn more about customizing your sync rules.',
})}
diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json
index 95c9f5501e39a..dde0b0f63fd56 100644
--- a/x-pack/plugins/translations/translations/fr-FR.json
+++ b/x-pack/plugins/translations/translations/fr-FR.json
@@ -15267,7 +15267,6 @@
"xpack.enterpriseSearch.content.index.connector.syncRules.basicRulesDescription": "Ces règles s'appliquent aux documents pendant la phrase de filtrage de l'intégration.",
"xpack.enterpriseSearch.content.index.connector.syncRules.basicRulesTitle": "Règles de base",
"xpack.enterpriseSearch.content.index.connector.syncRules.basicTabTitle": "Règles de base",
- "xpack.enterpriseSearch.content.index.connector.syncRules.flyout.betaDescription": "Les règles de synchronisation sont une fonctionnalité en version bêta. Les fonctionnalités bêta sont susceptibles d'être modifiées et ne sont pas couvertes par l'accord de niveau de service (SLA) des fonctionnalités de la version générale (GA). Elastic prévoit de faire passer cette fonctionnalité en disponibilité générale dans une prochaine version.",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.description": "Planifiez et modifiez les règles ici avant de les appliquer à la prochaine synchronisation.",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.revertButtonTitle": "Revenir aux règles actives",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.title": "Ébauches de règles",
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index c12da993ba5ed..4705c43ac0166 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -15245,7 +15245,6 @@
"xpack.enterpriseSearch.content.index.connector.syncRules.basicRulesDescription": "これらのルールは、統合フィルタリングフェーズ中にドキュメントに適用されます。",
"xpack.enterpriseSearch.content.index.connector.syncRules.basicRulesTitle": "基本ルール",
"xpack.enterpriseSearch.content.index.connector.syncRules.basicTabTitle": "基本ルール",
- "xpack.enterpriseSearch.content.index.connector.syncRules.flyout.betaDescription": "同期ルールはベータ機能です。ベータ版の機能は変更される可能性があり、一般リリース(GA)機能のサポートSLAではカバーされません。Elasticは将来のリリースでこの機能をGAに昇格させる予定です。",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.description": "次回の同期に適用する前に、ここでルールを計画して編集してください。",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.revertButtonTitle": "アクティブなルールに戻す",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.title": "ドラフトルール",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 4921de9a5b61c..af6c1e6110591 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -15272,7 +15272,6 @@
"xpack.enterpriseSearch.content.index.connector.syncRules.basicRulesDescription": "在集成筛选阶段,这些规则适用于文档。",
"xpack.enterpriseSearch.content.index.connector.syncRules.basicRulesTitle": "基本规则",
"xpack.enterpriseSearch.content.index.connector.syncRules.basicTabTitle": "基本规则",
- "xpack.enterpriseSearch.content.index.connector.syncRules.flyout.betaDescription": "同步规则为公测版功能。公测版功能可能会有所更改,并且不受公开发行版 (GA) 功能支持 SLA 的约束。Elastic 计划在未来版本中将此功能提升到 GA 版本。",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.description": "在此规划和编辑规则,然后将其应用到下次同步。",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.revertButtonTitle": "恢复为活动规则",
"xpack.enterpriseSearch.content.index.connector.syncRules.flyout.title": "起草规则",
From 720fb66b398c8d74d5fb9f3a2e21cd84e952935b Mon Sep 17 00:00:00 2001
From: Ersin Erdal <92688503+ersin-erdal@users.noreply.github.com>
Date: Thu, 18 Apr 2024 18:27:01 +0200
Subject: [PATCH 11/69] Use recoveredCurrent and activeCurrent to determine how
to update old alerts (#180934)
Fixes: #180797
This PR removes execution.uuid from the alert update payload, so the
recovered alerts from previous executions would not be reported again
after their initial execution.
## To verify
Create a rule and let it run at least one time.
Then make one of the alerts recovered and let it run for at least 2
times,
the recovered alert should not be in the message after the first
notification.
would be good to test the scenario in the following issue as well:
https://github.com/elastic/kibana/issues/164739
---
.../server/alerts_client/alerts_client.test.ts | 2 +-
.../server/alerts_client/alerts_client.ts | 8 ++++----
.../lib/build_updated_recovered_alert.test.ts | 3 +++
.../lib/build_updated_recovered_alert.ts | 14 ++++++++++++--
.../alerts_client/lib/format_alert.test.ts | 16 ++++++++++++++++
.../server/alerts_client/lib/format_alert.ts | 8 +++++---
.../group4/alerts_as_data/alerts_as_data.ts | 8 ++++++--
7 files changed, 47 insertions(+), 12 deletions(-)
diff --git a/x-pack/plugins/alerting/server/alerts_client/alerts_client.test.ts b/x-pack/plugins/alerting/server/alerts_client/alerts_client.test.ts
index 60e0889d9aec6..36dc3761185ff 100644
--- a/x-pack/plugins/alerting/server/alerts_client/alerts_client.test.ts
+++ b/x-pack/plugins/alerting/server/alerts_client/alerts_client.test.ts
@@ -764,7 +764,7 @@ describe('Alerts Client', () => {
expect(spy).toHaveBeenCalledTimes(2);
expect(spy).toHaveBeenNthCalledWith(1, 'active');
- expect(spy).toHaveBeenNthCalledWith(2, 'recovered');
+ expect(spy).toHaveBeenNthCalledWith(2, 'recoveredCurrent');
expect(logger.error).toHaveBeenCalledWith(
"Error writing alert(2) to .alerts-test.alerts-default - alert(2) doesn't exist in active alerts"
diff --git a/x-pack/plugins/alerting/server/alerts_client/alerts_client.ts b/x-pack/plugins/alerting/server/alerts_client/alerts_client.ts
index 4fab0825354b7..ff656f64be4e4 100644
--- a/x-pack/plugins/alerting/server/alerts_client/alerts_client.ts
+++ b/x-pack/plugins/alerting/server/alerts_client/alerts_client.ts
@@ -413,7 +413,7 @@ export class AlertsClient<
this.legacyAlertsClient.getAlertsToSerialize(false);
const activeAlerts = this.legacyAlertsClient.getProcessedAlerts('active');
- const recoveredAlerts = this.legacyAlertsClient.getProcessedAlerts('recovered');
+ const currentRecoveredAlerts = this.legacyAlertsClient.getProcessedAlerts('recoveredCurrent');
// TODO - Lifecycle alerts set some other fields based on alert status
// Example: workflow status - default to 'open' if not set
@@ -478,7 +478,7 @@ export class AlertsClient<
// If there is not, log an error because there should be
if (this.fetchedAlerts.data.hasOwnProperty(id)) {
recoveredAlertsToIndex.push(
- recoveredAlerts[id]
+ currentRecoveredAlerts[id]
? buildRecoveredAlert<
AlertData,
LegacyState,
@@ -487,7 +487,7 @@ export class AlertsClient<
RecoveryActionGroupId
>({
alert: this.fetchedAlerts.data[id],
- legacyAlert: recoveredAlerts[id],
+ legacyAlert: currentRecoveredAlerts[id],
rule: this.rule,
timestamp: currentTime,
payload: this.reportedAlerts[id],
@@ -503,7 +503,7 @@ export class AlertsClient<
);
} else {
this.options.logger.debug(
- `Could not find alert document to update for recovered alert with id ${id} and uuid ${recoveredAlerts[
+ `Could not find alert document to update for recovered alert with id ${id} and uuid ${currentRecoveredAlerts[
id
].getUuid()}`
);
diff --git a/x-pack/plugins/alerting/server/alerts_client/lib/build_updated_recovered_alert.test.ts b/x-pack/plugins/alerting/server/alerts_client/lib/build_updated_recovered_alert.test.ts
index 1c646f08d7828..93ea493bee9cc 100644
--- a/x-pack/plugins/alerting/server/alerts_client/lib/build_updated_recovered_alert.test.ts
+++ b/x-pack/plugins/alerting/server/alerts_client/lib/build_updated_recovered_alert.test.ts
@@ -25,6 +25,7 @@ import {
VERSION,
ALERT_TIME_RANGE,
ALERT_END,
+ ALERT_CONSECUTIVE_MATCHES,
} from '@kbn/rule-data-utils';
import {
alertRule,
@@ -76,6 +77,7 @@ describe('buildUpdatedRecoveredAlert', () => {
[SPACE_IDS]: ['default'],
[VERSION]: '8.8.1',
[TAGS]: ['rule-', '-tags'],
+ [ALERT_CONSECUTIVE_MATCHES]: 0,
});
});
@@ -125,6 +127,7 @@ describe('buildUpdatedRecoveredAlert', () => {
lte: '2023-03-30T12:27:28.159Z',
},
uuid: 'abcdefg',
+ consecutive_matches: 0,
},
version: '8.8.1',
},
diff --git a/x-pack/plugins/alerting/server/alerts_client/lib/build_updated_recovered_alert.ts b/x-pack/plugins/alerting/server/alerts_client/lib/build_updated_recovered_alert.ts
index 59c9a5cb35874..e02999eac950d 100644
--- a/x-pack/plugins/alerting/server/alerts_client/lib/build_updated_recovered_alert.ts
+++ b/x-pack/plugins/alerting/server/alerts_client/lib/build_updated_recovered_alert.ts
@@ -7,8 +7,14 @@
import deepmerge from 'deepmerge';
import type { Alert } from '@kbn/alerts-as-data-utils';
-import { ALERT_FLAPPING, ALERT_FLAPPING_HISTORY, TIMESTAMP } from '@kbn/rule-data-utils';
+import {
+ ALERT_FLAPPING,
+ ALERT_FLAPPING_HISTORY,
+ ALERT_RULE_EXECUTION_UUID,
+ TIMESTAMP,
+} from '@kbn/rule-data-utils';
import { RawAlertInstance } from '@kbn/alerting-state-types';
+import { get } from 'lodash';
import { RuleAlertData } from '../../types';
import { AlertRule } from '../types';
import { removeUnflattenedFieldsFromAlert, replaceRefreshableAlertFields } from './format_alert';
@@ -31,7 +37,7 @@ export const buildUpdatedRecoveredAlert = ({
rule,
timestamp,
}: BuildUpdatedRecoveredAlertOpts): Alert & AlertData => {
- // Make sure that any alert fields that are updateable are flattened.
+ // Make sure that any alert fields that are updatable are flattened.
const refreshableAlertFields = replaceRefreshableAlertFields(alert);
const alertUpdates = {
@@ -43,6 +49,10 @@ export const buildUpdatedRecoveredAlert = ({
[ALERT_FLAPPING]: legacyRawAlert.meta?.flapping,
// Set latest flapping history
[ALERT_FLAPPING_HISTORY]: legacyRawAlert.meta?.flappingHistory,
+ // For an "ongoing recovered" alert, we do not want to update the execution UUID to the current one so it does
+ // not get returned for summary alerts. In the future, we may want to restore this and add another field to the
+ // alert doc indicating that this is an ongoing recovered alert that can be used for querying.
+ [ALERT_RULE_EXECUTION_UUID]: get(alert, ALERT_RULE_EXECUTION_UUID),
};
// Clean the existing alert document so any nested fields that will be updated
diff --git a/x-pack/plugins/alerting/server/alerts_client/lib/format_alert.test.ts b/x-pack/plugins/alerting/server/alerts_client/lib/format_alert.test.ts
index a96cfb715d559..b39dc744d41a7 100644
--- a/x-pack/plugins/alerting/server/alerts_client/lib/format_alert.test.ts
+++ b/x-pack/plugins/alerting/server/alerts_client/lib/format_alert.test.ts
@@ -254,4 +254,20 @@ describe('compactObject', () => {
expect(
compactObject({ 'kibana.alert.rule.execution': {}, 'kibana.alert.nested_field': ['a', 'b'] })
).toEqual({ 'kibana.alert.nested_field': ['a', 'b'] });
+
+ test('should not filter out the fileds with primitive values', () => {
+ expect(
+ compactObject({
+ 'kibana.alert.rule.execution': 1,
+ 'kibana.alert.rule.zero': 0,
+ 'kibana.alert.bool_field': false,
+ 'kibana.alert.null_field': null,
+ })
+ ).toEqual({
+ 'kibana.alert.rule.execution': 1,
+ 'kibana.alert.rule.zero': 0,
+ 'kibana.alert.bool_field': false,
+ 'kibana.alert.null_field': null,
+ });
+ });
});
diff --git a/x-pack/plugins/alerting/server/alerts_client/lib/format_alert.ts b/x-pack/plugins/alerting/server/alerts_client/lib/format_alert.ts
index a81bdb35ce175..45043bf334be6 100644
--- a/x-pack/plugins/alerting/server/alerts_client/lib/format_alert.ts
+++ b/x-pack/plugins/alerting/server/alerts_client/lib/format_alert.ts
@@ -5,7 +5,7 @@
* 2.0.
*/
-import { cloneDeep, get, isEmpty, merge, omit } from 'lodash';
+import { cloneDeep, get, isEmpty, isNull, isUndefined, merge, omit } from 'lodash';
import type { Alert } from '@kbn/alerts-as-data-utils';
import { RuleAlertData } from '../../types';
import { REFRESH_FIELDS_ALL } from './alert_conflict_resolver';
@@ -35,15 +35,17 @@ export const compactObject = (obj: Obj) => {
// just filter out empty objects
// keep any primitives or arrays, even empty arrays
return (
- !!obj[key] &&
+ !isUndefined(obj[key]) &&
(Array.isArray(obj[key]) ||
typeof obj[key] !== 'object' ||
- (typeof obj[key] === 'object' && !isEmpty(obj[key])))
+ (typeof obj[key] === 'object' && (!isEmpty(obj[key]) || obj[key] === null)))
);
})
.reduce((acc, curr) => {
if (typeof obj[curr] !== 'object' || Array.isArray(obj[curr])) {
acc[curr] = obj[curr];
+ } else if (isNull(obj[curr])) {
+ acc[curr] = null;
} else {
const compacted = compactObject(obj[curr] as Obj);
if (!isEmpty(compacted)) {
diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data/alerts_as_data.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data/alerts_as_data.ts
index bd79f1dc4a569..7221e8bb4190a 100644
--- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data/alerts_as_data.ts
+++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data/alerts_as_data.ts
@@ -395,8 +395,12 @@ export default function createAlertsAsDataInstallResourcesTest({ getService }: F
expect(omit(alertBDocRun3, fieldsToOmitInComparison)).to.eql(
omit(alertBDocRun2, fieldsToOmitInComparison)
);
- // execution uuid should be current one
- expect(alertBDocRun3[ALERT_RULE_EXECUTION_UUID]).to.equal(executionUuid);
+
+ // execution uuid should be overwritten
+ expect(alertBDocRun3[ALERT_RULE_EXECUTION_UUID]).to.eql(
+ alertBDocRun2[ALERT_RULE_EXECUTION_UUID]
+ );
+
// flapping history should be history from prior run with additional entry
expect(alertBDocRun3[ALERT_FLAPPING_HISTORY]).to.eql([
...alertBDocRun2[ALERT_FLAPPING_HISTORY]!,
From e2fc61501181d5f7a96f916548fd3d80d14f2c46 Mon Sep 17 00:00:00 2001
From: Joe McElroy
Date: Thu, 18 Apr 2024 17:27:40 +0100
Subject: [PATCH 12/69] [Search] [Playground] fix code formatting (#181142)
Fixing the code formatting in the view code section. Also labelling the
examples as OpenAI as we now introduced more model options (Azure and
Bedrock + more) which we dont have support for yet in view_code.
In future these code examples will be moved to notebooks in
elasticsearch-labs so they can inherit the formatting / automated test
coverage / updates and no longer managed in strings.
![image](https://github.com/elastic/kibana/assets/49480/67865378-61c5-4b40-9985-fbc419f82578)
---
.../py_lang_client.test.tsx.snap | 48 +++++++++----------
.../py_langchain_python.test.tsx.snap | 23 +++++----
.../view_code/examples/py_lang_client.tsx | 46 +++++++-----------
.../examples/py_langchain_python.tsx | 33 +++++--------
.../components/view_code/examples/utils.ts | 21 ++++++++
.../components/view_code/view_code_flyout.tsx | 6 +--
6 files changed, 90 insertions(+), 87 deletions(-)
create mode 100644 x-pack/plugins/search_playground/public/components/view_code/examples/utils.ts
diff --git a/x-pack/plugins/search_playground/public/components/view_code/examples/__snapshots__/py_lang_client.test.tsx.snap b/x-pack/plugins/search_playground/public/components/view_code/examples/__snapshots__/py_lang_client.test.tsx.snap
index 25d1f6cce4b61..8506071050eb8 100644
--- a/x-pack/plugins/search_playground/public/components/view_code/examples/__snapshots__/py_lang_client.test.tsx.snap
+++ b/x-pack/plugins/search_playground/public/components/view_code/examples/__snapshots__/py_lang_client.test.tsx.snap
@@ -10,7 +10,7 @@ from openai import OpenAI
es_client = Elasticsearch(
- http://my-local-cloud-instance,
+ \\"http://my-local-cloud-instance\\",
api_key=os.environ[\\"ES_API_KEY\\"]
)
@@ -19,16 +19,7 @@ openai_client = OpenAI(
api_key=os.environ[\\"OPENAI_API_KEY\\"],
)
-def get_elasticsearch_results(query):
- es_query = {}
-
- result = es.search(index=\\"index1,index2\\", query=es_query, size=10)
- return result[\\"hits\\"][\\"hits\\"]
-
-def create_openai_prompt(question, results):
-
- context = \\"\\"
- index_source_fields = {
+index_source_fields = {
\\"index1\\": [
\\"field1\\"
],
@@ -36,11 +27,22 @@ def create_openai_prompt(question, results):
\\"field2\\"
]
}
+
+def get_elasticsearch_results(query):
+ es_query = {
+ \\"query\\": {},
+ \\"size\\": 10
+ }
+
+ result = es.search(index=\\"index1,index2\\", body=es_query)
+ return result[\\"hits\\"][\\"hits\\"]
+
+def create_openai_prompt(question, results):
+ context = \\"\\"
for hit in results:
source_field = index_source_fields.get(hit[\\"_index\\"])[0]
hit_context = hit[\\"_source\\"][source_field]
- context += f\\"{hit_context}
-\\"
+ context += f\\"{hit_context}\\\\n\\"
prompt = f\\"\\"\\"
Instructions:
@@ -64,25 +66,21 @@ def create_openai_prompt(question, results):
def generate_openai_completion(user_prompt):
response = openai_client.chat.completions.create(
- model=\\"Your-new-model\\",
+ model=\\"gpt-3.5-turbo\\",
messages=[
- {\\"role\\": \\"system\\", \\"content\\": \\"You are an assistant for question-answering tasks.\\"},
- {\\"role\\": \\"user\\", \\"content\\": user_prompt},
+ {\\"role\\": \\"system\\", \\"content\\": \\"You are an assistant for question-answering tasks.\\"},
+ {\\"role\\": \\"user\\", \\"content\\": user_prompt},
]
)
return response.choices[0].message.content
if __name__ == \\"__main__\\":
- question = \\"my question\\"
-
- elasticsearch_results = get_elasticsearch_results(question)
-
- context_prompt = create_openai_prompt(question, elasticsearch_results)
-
- openai_completion = generate_openai_completion(context_prompt)
-
- print(openai_completion)
+ question = \\"my question\\"
+ elasticsearch_results = get_elasticsearch_results(question)
+ context_prompt = create_openai_prompt(question, elasticsearch_results)
+ openai_completion = generate_openai_completion(context_prompt)
+ print(openai_completion)
"
`;
diff --git a/x-pack/plugins/search_playground/public/components/view_code/examples/__snapshots__/py_langchain_python.test.tsx.snap b/x-pack/plugins/search_playground/public/components/view_code/examples/__snapshots__/py_langchain_python.test.tsx.snap
index 7474cbe8b64d4..e6735a416e52c 100644
--- a/x-pack/plugins/search_playground/public/components/view_code/examples/__snapshots__/py_langchain_python.test.tsx.snap
+++ b/x-pack/plugins/search_playground/public/components/view_code/examples/__snapshots__/py_langchain_python.test.tsx.snap
@@ -13,30 +13,37 @@ from langchain_core.prompts import format_document
from langchain.prompts.prompt import PromptTemplate
import os
-
es_client = Elasticsearch(
- http://my-local-cloud-instance,
+ \\"http://my-local-cloud-instance\\",
api_key=os.environ[\\"ES_API_KEY\\"]
)
def build_query(query):
return {
- \\"query\\": {}
+ \\"query\\": {}
+ }
+
+index_source_fields = {
+ \\"index1\\": [
+ \\"field1\\"
+ ],
+ \\"index2\\": [
+ \\"field2\\"
+ ]
}
retriever = ElasticsearchRetriever(
- index_name=\\"{formValues.indices.join(',')}\\",
+ index_name=\\"index1,index2\\",
body_func=build_query,
- content_field=\\"text\\",
+ content_field=index_source_fields,
es_client=es_client
)
-model = ChatOpenAI(openai_api_key=os.environ[\\"OPENAI_API_KEY\\"], model_name=\\"Your-new-model\\")
-
+model = ChatOpenAI(openai_api_key=os.environ[\\"OPENAI_API_KEY\\"], model_name=\\"gpt-3.5-turbo\\")
ANSWER_PROMPT = ChatPromptTemplate.from_template(
- f\\"\\"\\"
+ f\\"\\"\\"
Instructions:
- Your prompt
diff --git a/x-pack/plugins/search_playground/public/components/view_code/examples/py_lang_client.tsx b/x-pack/plugins/search_playground/public/components/view_code/examples/py_lang_client.tsx
index 4ade9c59724ae..6f78f72795299 100644
--- a/x-pack/plugins/search_playground/public/components/view_code/examples/py_lang_client.tsx
+++ b/x-pack/plugins/search_playground/public/components/view_code/examples/py_lang_client.tsx
@@ -9,16 +9,7 @@ import { EuiCodeBlock } from '@elastic/eui';
import React from 'react';
import { ChatForm } from '../../../types';
import { Prompt } from '../../../../common/prompt';
-
-const getESQuery = (query: any) => {
- try {
- return JSON.stringify(query, null, 2).replace('"${query}"', 'f"${query}"');
- } catch (e) {
- // eslint-disable-next-line no-console
- console.error('Error parsing ES query', e);
- return '{}';
- }
-};
+import { getESQuery } from './utils';
export const PY_LANG_CLIENT = (formValues: ChatForm, clientDetails: string) => (
@@ -35,22 +26,23 @@ openai_client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"],
)
+index_source_fields = ${JSON.stringify(formValues.source_fields, null, 2)}
+
def get_elasticsearch_results(query):
- es_query = ${getESQuery(formValues.elasticsearch_query.query)}
+ es_query = ${getESQuery({
+ ...formValues.elasticsearch_query,
+ size: formValues.doc_size,
+ })}
- result = es.search(index="${formValues.indices.join(',')}", query=es_query, size=${
- formValues.doc_size
- })
+ result = es.search(index="${formValues.indices.join(',')}", body=es_query)
return result["hits"]["hits"]
def create_openai_prompt(question, results):
-
context = ""
- index_source_fields = ${JSON.stringify(formValues.source_fields, null, 2)}
for hit in results:
source_field = index_source_fields.get(hit["_index"])[0]
hit_context = hit["_source"][source_field]
- context += f"{hit_context}\n"
+ context += f"{hit_context}\\n"
prompt = f"""${Prompt(formValues.prompt, {
context: true,
@@ -62,25 +54,21 @@ def create_openai_prompt(question, results):
def generate_openai_completion(user_prompt):
response = openai_client.chat.completions.create(
- model="${formValues.summarization_model}",
+ model="gpt-3.5-turbo",
messages=[
- {"role": "system", "content": "You are an assistant for question-answering tasks."},
- {"role": "user", "content": user_prompt},
+ {"role": "system", "content": "You are an assistant for question-answering tasks."},
+ {"role": "user", "content": user_prompt},
]
)
return response.choices[0].message.content
if __name__ == "__main__":
- question = "my question"
-
- elasticsearch_results = get_elasticsearch_results(question)
-
- context_prompt = create_openai_prompt(question, elasticsearch_results)
-
- openai_completion = generate_openai_completion(context_prompt)
-
- print(openai_completion)
+ question = "my question"
+ elasticsearch_results = get_elasticsearch_results(question)
+ context_prompt = create_openai_prompt(question, elasticsearch_results)
+ openai_completion = generate_openai_completion(context_prompt)
+ print(openai_completion)
`}
diff --git a/x-pack/plugins/search_playground/public/components/view_code/examples/py_langchain_python.tsx b/x-pack/plugins/search_playground/public/components/view_code/examples/py_langchain_python.tsx
index cd02395c9c165..127d3786bcaf5 100644
--- a/x-pack/plugins/search_playground/public/components/view_code/examples/py_langchain_python.tsx
+++ b/x-pack/plugins/search_playground/public/components/view_code/examples/py_langchain_python.tsx
@@ -9,16 +9,7 @@ import { EuiCodeBlock } from '@elastic/eui';
import React from 'react';
import { ChatForm } from '../../../types';
import { Prompt } from '../../../../common/prompt';
-
-const getESQuery = (query: any) => {
- try {
- return JSON.stringify(query, null, 2).replace('"${query}"', 'f"${query}"');
- } catch (e) {
- // eslint-disable-next-line no-console
- console.error('Error parsing ES query', e);
- return '{}';
- }
-};
+import { getESQuery } from './utils';
export const LANGCHAIN_PYTHON = (formValues: ChatForm, clientDetails: string) => (
@@ -33,30 +24,28 @@ from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import format_document
from langchain.prompts.prompt import PromptTemplate
import os
-
${clientDetails}
def build_query(query):
return ${getESQuery(formValues.elasticsearch_query)}
+index_source_fields = ${JSON.stringify(formValues.source_fields, null, 2)}
+
retriever = ElasticsearchRetriever(
- index_name="{formValues.indices.join(',')}",
+ index_name="${formValues.indices.join(',')}",
body_func=build_query,
- content_field="text",
+ content_field=index_source_fields,
es_client=es_client
)
-model = ChatOpenAI(openai_api_key=os.environ["OPENAI_API_KEY"], model_name="${
- formValues.summarization_model
- }")
-
+model = ChatOpenAI(openai_api_key=os.environ["OPENAI_API_KEY"], model_name="gpt-3.5-turbo")
ANSWER_PROMPT = ChatPromptTemplate.from_template(
- f"""${Prompt(formValues.prompt, {
- context: true,
- citations: formValues.citations,
- type: 'openai',
- })}"""
+ f"""${Prompt(formValues.prompt, {
+ context: true,
+ citations: formValues.citations,
+ type: 'openai',
+ })}"""
)
DEFAULT_DOCUMENT_PROMPT = PromptTemplate.from_template(template="{page_content}")
diff --git a/x-pack/plugins/search_playground/public/components/view_code/examples/utils.ts b/x-pack/plugins/search_playground/public/components/view_code/examples/utils.ts
new file mode 100644
index 0000000000000..6d44442f588a2
--- /dev/null
+++ b/x-pack/plugins/search_playground/public/components/view_code/examples/utils.ts
@@ -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.
+ */
+
+export const getESQuery = (query: any) => {
+ try {
+ return JSON.stringify(query, null, 2)
+ .replace('"{query}"', 'query')
+ .split('\n')
+ .map((line) => ` ${line}`)
+ .join('\n')
+ .trim();
+ } catch (e) {
+ // eslint-disable-next-line no-console
+ console.error('Error parsing ES query', e);
+ return '{}';
+ }
+};
diff --git a/x-pack/plugins/search_playground/public/components/view_code/view_code_flyout.tsx b/x-pack/plugins/search_playground/public/components/view_code/view_code_flyout.tsx
index a914da997d276..9b65da674f3c3 100644
--- a/x-pack/plugins/search_playground/public/components/view_code/view_code_flyout.tsx
+++ b/x-pack/plugins/search_playground/public/components/view_code/view_code_flyout.tsx
@@ -35,7 +35,7 @@ export const ES_CLIENT_DETAILS = (cloud: CloudSetup | undefined) => {
if (cloud) {
return `
es_client = Elasticsearch(
- ${cloud.elasticsearchUrl},
+ "${cloud.elasticsearchUrl}",
api_key=os.environ["ES_API_KEY"]
)
`;
@@ -91,8 +91,8 @@ export const ViewCodeFlyout: React.FC = ({ onClose }) => {
setSelectedLanguage(e.target.value)}
value={selectedLanguage}
From aef197b243a7f604e963a07ab9124608ff0d1402 Mon Sep 17 00:00:00 2001
From: Tiago Costa
Date: Thu, 18 Apr 2024 18:35:47 +0100
Subject: [PATCH 13/69] fix(NA): do not change default encoding when using vfs
to copy files (#181174)
Closes https://github.com/elastic/kibana/issues/180067
When we upgraded into vinyl-fs@4.0.0 there was a missing breaking change
into their changelog related to encodings that was only added last
february. Because of that we missed a couple places where file
encondings were being changed from the default ones and in some cases
corrupting those files.
This PR fixes those problems.
---
packages/kbn-plugin-generator/src/render_template.ts | 1 +
.../kbn-plugin-helpers/src/tasks/brotli_compress_bundles.ts | 2 +-
packages/kbn-plugin-helpers/src/tasks/write_public_assets.ts | 1 +
packages/kbn-plugin-helpers/src/tasks/write_server_files.ts | 1 +
4 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/packages/kbn-plugin-generator/src/render_template.ts b/packages/kbn-plugin-generator/src/render_template.ts
index f2cb8c18a88d4..ad9b4cbc8d845 100644
--- a/packages/kbn-plugin-generator/src/render_template.ts
+++ b/packages/kbn-plugin-generator/src/render_template.ts
@@ -79,6 +79,7 @@ export async function renderTemplates({
buffer: true,
nodir: true,
cwd: Path.resolve(__dirname, '../template'),
+ encoding: false,
}),
// exclude files from the template based on selected options, patterns
diff --git a/packages/kbn-plugin-helpers/src/tasks/brotli_compress_bundles.ts b/packages/kbn-plugin-helpers/src/tasks/brotli_compress_bundles.ts
index ef03cb86c7aa0..ef9d3ac7d71f8 100644
--- a/packages/kbn-plugin-helpers/src/tasks/brotli_compress_bundles.ts
+++ b/packages/kbn-plugin-helpers/src/tasks/brotli_compress_bundles.ts
@@ -34,7 +34,7 @@ export async function brotliCompressBundles({ buildDir, log, plugin }: TaskConte
try {
await del(['**/*.br'], { cwd: compressDir });
await asyncPipeline(
- vfs.src(['**/*.{js,css}'], { cwd: compressDir }),
+ vfs.src(['**/*.{js,css}'], { cwd: compressDir, encoding: false }),
gulpBrotli({
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
diff --git a/packages/kbn-plugin-helpers/src/tasks/write_public_assets.ts b/packages/kbn-plugin-helpers/src/tasks/write_public_assets.ts
index 7fa6d157f4639..d43062018626f 100644
--- a/packages/kbn-plugin-helpers/src/tasks/write_public_assets.ts
+++ b/packages/kbn-plugin-helpers/src/tasks/write_public_assets.ts
@@ -28,6 +28,7 @@ export async function writePublicAssets({ log, plugin, sourceDir, buildDir }: Ta
base: sourceDir,
buffer: true,
allowEmpty: true,
+ encoding: false,
}),
vfs.dest(buildDir)
);
diff --git a/packages/kbn-plugin-helpers/src/tasks/write_server_files.ts b/packages/kbn-plugin-helpers/src/tasks/write_server_files.ts
index 2ba2686796487..362ef171cd9da 100644
--- a/packages/kbn-plugin-helpers/src/tasks/write_server_files.ts
+++ b/packages/kbn-plugin-helpers/src/tasks/write_server_files.ts
@@ -53,6 +53,7 @@ export async function writeServerFiles({
'**/*.{test,test.mocks,mock,mocks}.*',
],
allowEmpty: true,
+ encoding: false,
}
),
From d61b53fea522c648f4e023e643b52cf6ae6e930d Mon Sep 17 00:00:00 2001
From: Alexi Doak <109488926+doakalexi@users.noreply.github.com>
Date: Thu, 18 Apr 2024 10:48:46 -0700
Subject: [PATCH 14/69] [Response Ops][Task Manager] TM status affected by
capacity estimation which is based on a best estimate of number of Kibana
instances (#179982)
Resolves https://github.com/elastic/kibana/issues/176152
## Summary
This PR sets task manager status to `OK` if the required throughput is
greater than the capacity, but logs a warning to help indicate that Task
Manager can not keep up with the workload.
We decided to do this bc the `assumedKibanaInstances` metric is a best
estimate that could potentially set the task manager status to degraded
.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
---
.../monitoring/capacity_estimation.test.ts | 19 ++-
.../server/monitoring/capacity_estimation.ts | 16 ++-
.../task_manager/server/routes/health.test.ts | 136 +++++++++++++++---
3 files changed, 141 insertions(+), 30 deletions(-)
diff --git a/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.test.ts b/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.test.ts
index a171b06903bbc..263f2e9987b7c 100644
--- a/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.test.ts
+++ b/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.test.ts
@@ -12,7 +12,7 @@ import { mockLogger } from '../test_utils';
describe('estimateCapacity', () => {
const logger = mockLogger();
- beforeAll(() => {
+ beforeEach(() => {
jest.resetAllMocks();
});
@@ -568,6 +568,9 @@ describe('estimateCapacity', () => {
timestamp: expect.any(String),
value: expect.any(Object),
});
+ expect(logger.debug).toHaveBeenCalledWith(
+ 'Task Manager is healthy, the assumedRequiredThroughputPerMinutePerKibana (190) < capacityPerMinutePerKibana (200)'
+ );
});
test('marks estimated capacity as Warning state when capacity is insufficient for recent spikes of non-recurring workload, but sufficient for the recurring workload', async () => {
@@ -626,10 +629,13 @@ describe('estimateCapacity', () => {
)
)
).toMatchObject({
- status: 'warn',
+ status: 'OK',
timestamp: expect.any(String),
value: expect.any(Object),
});
+ expect(logger.warn).toHaveBeenCalledWith(
+ 'Task Manager is unhealthy, the assumedAverageRecurringRequiredThroughputPerMinutePerKibana (175) < capacityPerMinutePerKibana (200)'
+ );
});
test('marks estimated capacity as Error state when workload and load suggest capacity is insufficient', async () => {
@@ -688,10 +694,13 @@ describe('estimateCapacity', () => {
)
)
).toMatchObject({
- status: 'error',
+ status: 'OK',
timestamp: expect.any(String),
value: expect.any(Object),
});
+ expect(logger.warn).toHaveBeenCalledWith(
+ 'Task Manager is unhealthy, the assumedRequiredThroughputPerMinutePerKibana (250) >= capacityPerMinutePerKibana (200) AND assumedAverageRecurringRequiredThroughputPerMinutePerKibana (210) >= capacityPerMinutePerKibana (200)'
+ );
});
test('recommmends a 20% increase in kibana when a spike in non-recurring tasks forces recurring task capacity to zero', async () => {
@@ -749,7 +758,7 @@ describe('estimateCapacity', () => {
)
)
).toMatchObject({
- status: 'warn',
+ status: 'OK',
timestamp: expect.any(String),
value: {
observed: {
@@ -825,7 +834,7 @@ describe('estimateCapacity', () => {
)
)
).toMatchObject({
- status: 'error',
+ status: 'OK',
timestamp: expect.any(String),
value: {
observed: {
diff --git a/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.ts b/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.ts
index e03a9c6337090..b12382f16e27b 100644
--- a/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.ts
+++ b/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.ts
@@ -242,18 +242,20 @@ function getHealthStatus(
capacityPerMinutePerKibana,
} = params;
if (assumedRequiredThroughputPerMinutePerKibana < capacityPerMinutePerKibana) {
- return { status: HealthStatus.OK };
+ const reason = `Task Manager is healthy, the assumedRequiredThroughputPerMinutePerKibana (${assumedRequiredThroughputPerMinutePerKibana}) < capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
+ logger.debug(reason);
+ return { status: HealthStatus.OK, reason };
}
if (assumedAverageRecurringRequiredThroughputPerMinutePerKibana < capacityPerMinutePerKibana) {
- const reason = `setting HealthStatus.Warning because assumedAverageRecurringRequiredThroughputPerMinutePerKibana (${assumedAverageRecurringRequiredThroughputPerMinutePerKibana}) < capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
- logger.debug(reason);
- return { status: HealthStatus.Warning, reason };
+ const reason = `Task Manager is unhealthy, the assumedAverageRecurringRequiredThroughputPerMinutePerKibana (${assumedAverageRecurringRequiredThroughputPerMinutePerKibana}) < capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
+ logger.warn(reason);
+ return { status: HealthStatus.OK, reason };
}
- const reason = `setting HealthStatus.Error because assumedRequiredThroughputPerMinutePerKibana (${assumedRequiredThroughputPerMinutePerKibana}) >= capacityPerMinutePerKibana (${capacityPerMinutePerKibana}) AND assumedAverageRecurringRequiredThroughputPerMinutePerKibana (${assumedAverageRecurringRequiredThroughputPerMinutePerKibana}) >= capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
- logger.debug(reason);
- return { status: HealthStatus.Error, reason };
+ const reason = `Task Manager is unhealthy, the assumedRequiredThroughputPerMinutePerKibana (${assumedRequiredThroughputPerMinutePerKibana}) >= capacityPerMinutePerKibana (${capacityPerMinutePerKibana}) AND assumedAverageRecurringRequiredThroughputPerMinutePerKibana (${assumedAverageRecurringRequiredThroughputPerMinutePerKibana}) >= capacityPerMinutePerKibana (${capacityPerMinutePerKibana})`;
+ logger.warn(reason);
+ return { status: HealthStatus.OK, reason };
}
export function withCapacityEstimate(
diff --git a/x-pack/plugins/task_manager/server/routes/health.test.ts b/x-pack/plugins/task_manager/server/routes/health.test.ts
index de84a2bd4aa1c..a97d99079bc58 100644
--- a/x-pack/plugins/task_manager/server/routes/health.test.ts
+++ b/x-pack/plugins/task_manager/server/routes/health.test.ts
@@ -14,15 +14,25 @@ import { mockHandlerArguments } from './_mock_handler_arguments';
import { sleep } from '../test_utils';
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock';
-import { MonitoringStats, RawMonitoringStats, summarizeMonitoringStats } from '../monitoring';
-import { ServiceStatusLevels, Logger } from '@kbn/core/server';
+import { MonitoringStats, RawMonitoringStats } from '../monitoring';
+import { ServiceStatusLevels } from '@kbn/core/server';
import { configSchema, TaskManagerConfig } from '../config';
import { FillPoolResult } from '../lib/fill_pool';
+jest.mock('../monitoring', () => {
+ const monitoring = jest.requireActual('../monitoring');
+ return {
+ ...monitoring,
+ summarizeMonitoringStats: jest.fn(),
+ };
+});
+
jest.mock('../lib/log_health_metrics', () => ({
logHealthMetrics: jest.fn(),
}));
+const { summarizeMonitoringStats } = jest.requireMock('../monitoring');
+
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
@@ -38,12 +48,29 @@ const createMockClusterClient = (response: any) => {
return { mockClusterClient, mockScopedClusterClient };
};
+const timestamp = new Date().toISOString();
+
describe('healthRoute', () => {
const logger = loggingSystemMock.create().get();
const docLinks = docLinksServiceMock.create().setup();
-
beforeEach(() => {
jest.resetAllMocks();
+
+ summarizeMonitoringStats.mockReturnValue({
+ last_update: timestamp,
+ stats: {
+ workload: {
+ timestamp,
+ value: {},
+ status: 'OK',
+ },
+ capacity_estimation: {
+ status: 'OK',
+ timestamp,
+ value: {},
+ },
+ },
+ });
});
it('registers the route', async () => {
@@ -245,6 +272,24 @@ describe('healthRoute', () => {
it(`logs at a warn level if the status is warning`, async () => {
const router = httpServiceMock.createRouter();
const { logHealthMetrics } = jest.requireMock('../lib/log_health_metrics');
+ const reason =
+ 'setting HealthStatus.Warning because assumedAverageRecurringRequiredThroughputPerMinutePerKibana (78.28472222222223) < capacityPerMinutePerKibana (200)';
+ summarizeMonitoringStats.mockReturnValue({
+ last_update: timestamp,
+ stats: {
+ workload: {
+ timestamp,
+ value: {},
+ status: 'OK',
+ },
+ capacity_estimation: {
+ status: 'warn',
+ reason,
+ timestamp,
+ value: {},
+ },
+ },
+ });
const warnRuntimeStat = mockHealthStats();
const warnConfigurationStat = mockHealthStats();
@@ -288,8 +333,7 @@ describe('healthRoute', () => {
expect(await serviceStatus).toMatchObject({
level: ServiceStatusLevels.degraded,
- summary:
- 'Task Manager is unhealthy - Reason: setting HealthStatus.Warning because assumedAverageRecurringRequiredThroughputPerMinutePerKibana (78.28472222222223) < capacityPerMinutePerKibana (200)',
+ summary: `Task Manager is unhealthy - Reason: ${reason}`,
});
expect(logHealthMetrics).toBeCalledTimes(4);
@@ -330,6 +374,24 @@ describe('healthRoute', () => {
it(`logs at an error level if the status is error`, async () => {
const router = httpServiceMock.createRouter();
const { logHealthMetrics } = jest.requireMock('../lib/log_health_metrics');
+ const reason =
+ 'setting HealthStatus.Warning because assumedAverageRecurringRequiredThroughputPerMinutePerKibana (78.28472222222223) < capacityPerMinutePerKibana (200)';
+ summarizeMonitoringStats.mockReturnValue({
+ last_update: timestamp,
+ stats: {
+ workload: {
+ timestamp,
+ value: {},
+ status: 'OK',
+ },
+ capacity_estimation: {
+ status: 'error',
+ reason,
+ timestamp,
+ value: {},
+ },
+ },
+ });
const errorRuntimeStat = mockHealthStats();
const errorConfigurationStat = mockHealthStats();
@@ -373,8 +435,7 @@ describe('healthRoute', () => {
expect(await serviceStatus).toMatchObject({
level: ServiceStatusLevels.degraded,
- summary:
- 'Task Manager is unhealthy - Reason: setting HealthStatus.Warning because assumedAverageRecurringRequiredThroughputPerMinutePerKibana (78.28472222222223) < capacityPerMinutePerKibana (200)',
+ summary: `Task Manager is unhealthy - Reason: ${reason}`,
});
expect(logHealthMetrics).toBeCalledTimes(4);
@@ -414,6 +475,22 @@ describe('healthRoute', () => {
it('returns a error status if the overall stats have not been updated within the required hot freshness', async () => {
const router = httpServiceMock.createRouter();
+ const coldTimestamp = new Date(Date.now() - 3001).toISOString();
+ summarizeMonitoringStats.mockReturnValue({
+ last_update: coldTimestamp,
+ stats: {
+ workload: {
+ timestamp: coldTimestamp,
+ value: {},
+ status: 'OK',
+ },
+ capacity_estimation: {
+ status: 'OK',
+ timestamp: coldTimestamp,
+ value: {},
+ },
+ },
+ });
const stats$ = new Subject();
@@ -444,7 +521,7 @@ describe('healthRoute', () => {
stats$.next(
mockHealthStats({
- last_update: new Date(Date.now() - 3001).toISOString(),
+ last_update: coldTimestamp,
})
);
@@ -487,17 +564,26 @@ describe('healthRoute', () => {
summary:
'Task Manager is unhealthy - Reason: setting HealthStatus.Error because of expired hot timestamps',
});
- const warnCalls = (logger as jest.Mocked).debug.mock.calls as string[][];
- const warnMessage =
- /^setting HealthStatus.Warning because assumedAverageRecurringRequiredThroughputPerMinutePerKibana/;
- const found = warnCalls
- .map((arr) => arr[0])
- .find((message) => message.match(warnMessage) != null);
- expect(found).toMatch(warnMessage);
});
it('returns a error status if the workload stats have not been updated within the required cold freshness', async () => {
+ const coldTimestamp = new Date(Date.now() - 120000).toISOString();
const router = httpServiceMock.createRouter();
+ summarizeMonitoringStats.mockReturnValue({
+ last_update: timestamp,
+ stats: {
+ workload: {
+ timestamp: coldTimestamp,
+ value: {},
+ status: 'OK',
+ },
+ capacity_estimation: {
+ status: 'OK',
+ timestamp,
+ value: {},
+ },
+ },
+ });
const stats$ = new Subject();
@@ -522,12 +608,11 @@ describe('healthRoute', () => {
await sleep(0);
- const lastUpdateOfWorkload = new Date(Date.now() - 120000).toISOString();
stats$.next(
mockHealthStats({
stats: {
workload: {
- timestamp: lastUpdateOfWorkload,
+ timestamp: coldTimestamp,
},
},
})
@@ -663,7 +748,23 @@ describe('healthRoute', () => {
});
it('returns a OK status for empty if shouldRunTasks is false', async () => {
+ const lastUpdate = new Date().toISOString();
const router = httpServiceMock.createRouter();
+ summarizeMonitoringStats.mockReturnValue({
+ last_update: lastUpdate,
+ stats: {
+ workload: {
+ timestamp: lastUpdate,
+ value: {},
+ status: 'OK',
+ },
+ capacity_estimation: {
+ status: 'OK',
+ timestamp: lastUpdate,
+ value: {},
+ },
+ },
+ });
const stats$ = new Subject();
const { serviceStatus$ } = healthRoute({
@@ -685,7 +786,6 @@ describe('healthRoute', () => {
const serviceStatus = firstValueFrom(serviceStatus$);
await sleep(0);
- const lastUpdate = new Date().toISOString();
stats$.next({
last_update: lastUpdate,
stats: {},
From cfee0fafb6e4bf272e547a3fa569ac390038fff3 Mon Sep 17 00:00:00 2001
From: Philippe Oberti
Date: Thu, 18 Apr 2024 13:18:17 -0500
Subject: [PATCH 15/69] [Security Solution][Alert details] - update telemetry
property to better reflect where the flyout is opened from (#180984)
---
x-pack/plugins/security_solution/public/cases/pages/index.tsx | 2 +-
.../common/components/control_columns/row_action/index.tsx | 2 +-
.../common/lib/telemetry/events/document_details/index.ts | 4 ++--
.../common/lib/telemetry/events/document_details/types.ts | 4 ++--
.../public/flyout/document_details/left/index.tsx | 2 +-
.../public/flyout/document_details/left/tabs/insights_tab.tsx | 2 +-
.../document_details/right/components/alert_description.tsx | 2 +-
.../flyout/document_details/right/components/reason.tsx | 2 +-
.../public/flyout/document_details/right/index.tsx | 2 +-
.../public/flyout/document_details/right/navigation.tsx | 2 +-
10 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/x-pack/plugins/security_solution/public/cases/pages/index.tsx b/x-pack/plugins/security_solution/public/cases/pages/index.tsx
index 2a7f92076fa97..a4d43043b49e9 100644
--- a/x-pack/plugins/security_solution/public/cases/pages/index.tsx
+++ b/x-pack/plugins/security_solution/public/cases/pages/index.tsx
@@ -83,7 +83,7 @@ const CaseContainerComponent: React.FC = () => {
},
});
telemetry.reportDetailsFlyoutOpened({
- tableId: TimelineId.casePage,
+ location: TimelineId.casePage,
panel: 'right',
});
}
diff --git a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx
index 1ba141ffb5fc2..7454db7c1e484 100644
--- a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx
+++ b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx
@@ -122,7 +122,7 @@ const RowActionComponent = ({
},
});
telemetry.reportDetailsFlyoutOpened({
- tableId,
+ location: tableId,
panel: 'right',
});
}
diff --git a/x-pack/plugins/security_solution/public/common/lib/telemetry/events/document_details/index.ts b/x-pack/plugins/security_solution/public/common/lib/telemetry/events/document_details/index.ts
index 5f036ec164936..ba59cf5130dc2 100644
--- a/x-pack/plugins/security_solution/public/common/lib/telemetry/events/document_details/index.ts
+++ b/x-pack/plugins/security_solution/public/common/lib/telemetry/events/document_details/index.ts
@@ -11,7 +11,7 @@ import { TelemetryEventTypes } from '../../constants';
export const DocumentDetailsFlyoutOpenedEvent: TelemetryEvent = {
eventType: TelemetryEventTypes.DetailsFlyoutOpened,
schema: {
- tableId: {
+ location: {
type: 'text',
_meta: {
description: 'Table ID',
@@ -31,7 +31,7 @@ export const DocumentDetailsFlyoutOpenedEvent: TelemetryEvent = {
export const DocumentDetailsTabClickedEvent: TelemetryEvent = {
eventType: TelemetryEventTypes.DetailsFlyoutTabClicked,
schema: {
- tableId: {
+ location: {
type: 'text',
_meta: {
description: 'Table ID',
diff --git a/x-pack/plugins/security_solution/public/common/lib/telemetry/events/document_details/types.ts b/x-pack/plugins/security_solution/public/common/lib/telemetry/events/document_details/types.ts
index 04efb6544deb2..a090686c91267 100644
--- a/x-pack/plugins/security_solution/public/common/lib/telemetry/events/document_details/types.ts
+++ b/x-pack/plugins/security_solution/public/common/lib/telemetry/events/document_details/types.ts
@@ -9,12 +9,12 @@ import type { RootSchema } from '@kbn/analytics-client';
import type { TelemetryEventTypes } from '../../constants';
export interface ReportDetailsFlyoutOpenedParams {
- tableId: string;
+ location: string;
panel: 'left' | 'right' | 'preview';
}
export interface ReportDetailsFlyoutTabClickedParams {
- tableId: string;
+ location: string;
panel: 'left' | 'right';
tabId: string;
}
diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx
index 5a2851b57c1a1..25b076eaa3d4a 100644
--- a/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx
+++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx
@@ -69,7 +69,7 @@ export const LeftPanel: FC> = memo(({ path }) => {
},
});
telemetry.reportDetailsFlyoutTabClicked({
- tableId: scopeId,
+ location: scopeId,
panel: 'left',
tabId,
});
diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/insights_tab.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/insights_tab.tsx
index f73791849c4fc..d47631f4de98d 100644
--- a/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/insights_tab.tsx
+++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/insights_tab.tsx
@@ -117,7 +117,7 @@ export const InsightsTab: React.FC = memo(() => {
},
});
telemetry.reportDetailsFlyoutTabClicked({
- tableId: scopeId,
+ location: scopeId,
panel: 'left',
tabId: optionId,
});
diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.tsx
index 494ddac21f6a4..b3c4ac7a2ce6b 100644
--- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.tsx
+++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.tsx
@@ -59,7 +59,7 @@ export const AlertDescription: FC = () => {
},
});
telemetry.reportDetailsFlyoutOpened({
- tableId: scopeId,
+ location: scopeId,
panel: 'preview',
});
}, [eventId, openPreviewPanel, indexName, scopeId, ruleId, telemetry]);
diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.tsx
index 7b4ba1ced829f..0ac7e5f0eb2ff 100644
--- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.tsx
+++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.tsx
@@ -55,7 +55,7 @@ export const Reason: FC = () => {
},
});
telemetry.reportDetailsFlyoutOpened({
- tableId: scopeId,
+ location: scopeId,
panel: 'preview',
});
}, [eventId, openPreviewPanel, indexName, scopeId, telemetry]);
diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/index.tsx
index 0b4fcb4c6ba02..f1cbd4fbc9685 100644
--- a/x-pack/plugins/security_solution/public/flyout/document_details/right/index.tsx
+++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/index.tsx
@@ -65,7 +65,7 @@ export const RightPanel: FC> = memo(({ path }) => {
storage.set(FLYOUT_STORAGE_KEYS.RIGHT_PANEL_SELECTED_TABS, tabId);
telemetry.reportDetailsFlyoutTabClicked({
- tableId: scopeId,
+ location: scopeId,
panel: 'right',
tabId,
});
diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx
index b2879dcbaae44..d484e2e2a0204 100644
--- a/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx
+++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx
@@ -36,7 +36,7 @@ export const PanelNavigation: FC = memo(({ flyoutIsExpanda
},
});
telemetry.reportDetailsFlyoutOpened({
- tableId: scopeId,
+ location: scopeId,
panel: 'left',
});
}, [eventId, openLeftPanel, indexName, scopeId, telemetry]);
From 89609fe596d79b7d2eb4f209c5388824f9b279c1 Mon Sep 17 00:00:00 2001
From: Andrew Macri
Date: Thu, 18 Apr 2024 15:01:27 -0400
Subject: [PATCH 16/69] [Security Solution] [AI Insights] Enable LangSmith
tracing in cloud deployments (#181159)
## [Security Solution] [AI Insights] Enable LangSmith tracing in cloud deployments
### Summary
This PR enables LangSmith tracing for the [AI Insights](https://github.com/elastic/kibana/pull/180611) feature in cloud deployments.
LangSmith project names and API keys are specified using the same UI and patterns introduced by @spong in
### Details
To enable LangSmith tracing in cloud deployments, configure the following `xpack.securitySolution.enableExperimental` feature flags:
```
xpack.securitySolution.enableExperimental: ['assistantModelEvaluation', 'assistantAlertsInsights']
```
- The `assistantModelEvaluation` feature flag enables the `Evaluation` settings category in the assistant. The LangSmith project name and API key are configured here
- The `assistantAlertsInsights` feature flag enables the AI Insights feature, which is off by default at the time of this writing
After enabling the feature flags above:
1) Click the `AI Assistant` button anywhere in the Security Solution to launch the assistant
2) Click the settings gear in the assistant
3) Click the `Evaluation` settings category
4) Click `Show Trace Options (for internal use only)`
5) Specify a `LangSmith Project` and `LangSmith API Key` per the screenshot below:
![langsmith_settings](https://github.com/elastic/kibana/assets/4459398/896c8155-3a06-4381-becf-b846b5aba426)
---
.../impl/llm/actions_client_llm.ts | 11 +++++++---
.../impl/llm/types.ts | 10 +++++++++
.../alerts/post_alerts_insights_route.gen.ts | 2 ++
.../post_alerts_insights_route.schema.yaml | 4 ++++
.../insights/alerts/post_alerts_insights.ts | 22 ++++++++++++++++++-
.../public/ai_insights/use_insights/index.tsx | 11 +++++++++-
6 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/x-pack/packages/kbn-elastic-assistant-common/impl/llm/actions_client_llm.ts b/x-pack/packages/kbn-elastic-assistant-common/impl/llm/actions_client_llm.ts
index ab77e90c1c3f4..8df4c60817c6c 100644
--- a/x-pack/packages/kbn-elastic-assistant-common/impl/llm/actions_client_llm.ts
+++ b/x-pack/packages/kbn-elastic-assistant-common/impl/llm/actions_client_llm.ts
@@ -5,13 +5,14 @@
* 2.0.
*/
-import { v4 as uuidv4 } from 'uuid';
-import { KibanaRequest, Logger } from '@kbn/core/server';
import type { PluginStartContract as ActionsPluginStart } from '@kbn/actions-plugin/server';
+import { KibanaRequest, Logger } from '@kbn/core/server';
import { LLM } from '@langchain/core/language_models/llms';
import { get } from 'lodash/fp';
+import { v4 as uuidv4 } from 'uuid';
import { getMessageContentAndRole } from './helpers';
+import { TraceOptions } from './types';
const LLM_TYPE = 'ActionsClientLlm';
@@ -27,6 +28,7 @@ interface ActionsClientLlmParams {
model?: string;
temperature?: number;
traceId?: string;
+ traceOptions?: TraceOptions;
}
export class ActionsClientLlm extends LLM {
@@ -52,8 +54,11 @@ export class ActionsClientLlm extends LLM {
model,
request,
temperature,
+ traceOptions,
}: ActionsClientLlmParams) {
- super({});
+ super({
+ callbacks: [...(traceOptions?.tracers ?? [])],
+ });
this.#actions = actions;
this.#connectorId = connectorId;
diff --git a/x-pack/packages/kbn-elastic-assistant-common/impl/llm/types.ts b/x-pack/packages/kbn-elastic-assistant-common/impl/llm/types.ts
index 85c970b1b948a..5fd08e6ee4e2d 100644
--- a/x-pack/packages/kbn-elastic-assistant-common/impl/llm/types.ts
+++ b/x-pack/packages/kbn-elastic-assistant-common/impl/llm/types.ts
@@ -5,6 +5,7 @@
* 2.0.
*/
+import { LangChainTracer } from '@langchain/core/tracers/tracer_langchain';
import {
ChatCompletionContentPart,
ChatCompletionCreateParamsNonStreaming,
@@ -38,3 +39,12 @@ export interface InvokeAIActionParamsSchema {
functions?: ChatCompletionCreateParamsNonStreaming['functions'];
signal?: AbortSignal;
}
+
+export interface TraceOptions {
+ evaluationId?: string;
+ exampleId?: string;
+ projectName?: string;
+ runName?: string;
+ tags?: string[];
+ tracers?: LangChainTracer[];
+}
diff --git a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/insights/alerts/post_alerts_insights_route.gen.ts b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/insights/alerts/post_alerts_insights_route.gen.ts
index 2f64f3c6e521d..cfae1a004a54d 100644
--- a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/insights/alerts/post_alerts_insights_route.gen.ts
+++ b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/insights/alerts/post_alerts_insights_route.gen.ts
@@ -56,6 +56,8 @@ export const AlertsInsightsPostRequestBody = z.object({
anonymizationFields: z.array(AnonymizationFieldResponse),
connectorId: z.string(),
actionTypeId: z.string(),
+ langSmithProject: z.string().optional(),
+ langSmithApiKey: z.string().optional(),
model: z.string().optional(),
replacements: Replacements.optional(),
size: z.number(),
diff --git a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/insights/alerts/post_alerts_insights_route.schema.yaml b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/insights/alerts/post_alerts_insights_route.schema.yaml
index 5ab58c6023ee5..a4a647784ee29 100644
--- a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/insights/alerts/post_alerts_insights_route.schema.yaml
+++ b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/insights/alerts/post_alerts_insights_route.schema.yaml
@@ -73,6 +73,10 @@ paths:
type: string
actionTypeId:
type: string
+ langSmithProject:
+ type: string
+ langSmithApiKey:
+ type: string
model:
type: string
replacements:
diff --git a/x-pack/plugins/elastic_assistant/server/routes/insights/alerts/post_alerts_insights.ts b/x-pack/plugins/elastic_assistant/server/routes/insights/alerts/post_alerts_insights.ts
index 455f50703e836..e58e4cd0f8e20 100644
--- a/x-pack/plugins/elastic_assistant/server/routes/insights/alerts/post_alerts_insights.ts
+++ b/x-pack/plugins/elastic_assistant/server/routes/insights/alerts/post_alerts_insights.ts
@@ -19,6 +19,7 @@ import { transformError } from '@kbn/securitysolution-es-utils';
import { INSIGHTS_ALERTS } from '../../../../common/constants';
import { getAssistantToolParams, isInsightsFeatureEnabled } from './helpers';
import { DEFAULT_PLUGIN_NAME, getPluginNameFromRequest } from '../../helpers';
+import { getLangSmithTracer } from '../../evaluate/utils';
import { buildResponse } from '../../../lib/build_response';
import { ElasticAssistantRequestHandlerContext } from '../../../types';
import { getLlmType } from '../../utils';
@@ -73,7 +74,14 @@ export const postAlertsInsightsRoute = (router: IRouter
Date: Thu, 18 Apr 2024 15:19:48 -0400
Subject: [PATCH 17/69] skip failing test suite (#180982)
---
.../test_suites/observability/slos/delete_slo.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/slos/delete_slo.ts b/x-pack/test_serverless/api_integration/test_suites/observability/slos/delete_slo.ts
index 59d1faa8d4c10..c56b8255b4111 100644
--- a/x-pack/test_serverless/api_integration/test_suites/observability/slos/delete_slo.ts
+++ b/x-pack/test_serverless/api_integration/test_suites/observability/slos/delete_slo.ts
@@ -47,7 +47,8 @@ export default function ({ getService }: FtrProviderContext) {
return {};
}
};
- describe('delete_slo', () => {
+ // Failing: See https://github.com/elastic/kibana/issues/180982
+ describe.skip('delete_slo', () => {
// DATE_VIEW should match the index template:
// x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json
const DATE_VIEW = 'kbn-data-forge-fake_hosts';
From 1a83533ef12a3a311d287185a48f1aedbcd444ac Mon Sep 17 00:00:00 2001
From: Tiago Costa
Date: Thu, 18 Apr 2024 20:21:37 +0100
Subject: [PATCH 18/69] skip flaky suite (#164032)
---
.../server/integration_tests/task_state_validation.test.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts b/x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts
index a4ffa7514e02c..75e5c9d942398 100644
--- a/x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts
+++ b/x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts
@@ -258,7 +258,8 @@ describe('task state validation', () => {
});
});
- describe('allow_reading_invalid_state: false', () => {
+ // FLAKY: https://github.com/elastic/kibana/issues/164032
+ describe.skip('allow_reading_invalid_state: false', () => {
const taskIdsToRemove: string[] = [];
let esServer: TestElasticsearchUtils;
let kibanaServer: TestKibanaUtils;
From 98a73920a9ed495862a83efa45643ca4166fa5b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gerg=C5=91=20=C3=81brah=C3=A1m?=
Date: Thu, 18 Apr 2024 21:25:49 +0200
Subject: [PATCH 19/69] [EDR Workflows][chore] Fix `load_agent_policies` script
for cloud and serverless (#181183)
## Summary
For the script
`x-pack/plugins/security_solution/scripts/endpoint/load_agent_policies.js`:
- fixes the `self-signed certificate in certificate chain` error when
using with cloud environment (by simply *not* using certificate)
- adds a new option called `apikey` which makes it possible to use with
serverless environment
---
.../endpoint/agent_policy_generator/index.ts | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/x-pack/plugins/security_solution/scripts/endpoint/agent_policy_generator/index.ts b/x-pack/plugins/security_solution/scripts/endpoint/agent_policy_generator/index.ts
index f8677694bed34..104bf337be5d3 100644
--- a/x-pack/plugins/security_solution/scripts/endpoint/agent_policy_generator/index.ts
+++ b/x-pack/plugins/security_solution/scripts/endpoint/agent_policy_generator/index.ts
@@ -38,13 +38,15 @@ export const cli = () => {
kibana: 'http://127.0.0.1:5601',
username: 'elastic',
password: 'changeme',
+ apikey: undefined,
},
help: `
- --count Number of agent policies to create. Default: 10
- --concurrency Number of concurrent agent policies can be created. Default: 10
- --kibana The URL to kibana including credentials. Default: http://127.0.0.1:5601
- --username The username to use for authentication. Default: elastic
- --password The password to use for authentication. Default: changeme
+ --count Number of agent policies to create. Default: 10
+ --concurrency Number of concurrent agent policies can be created. Default: 10
+ --kibana The URL to kibana including credentials. Default: http://127.0.0.1:5601
+ --username The username to use for authentication for local or cloud environment. Default: elastic
+ --password The password to use for authentication for local or cloud environment. Default: changeme
+ --apikey API key for authenticating for Serverless environment. Default: -
`,
},
}
@@ -56,6 +58,9 @@ const agentPolicyGenerator: RunFn = async ({ flags, log }) => {
url: flags.kibana as string,
username: flags.username as string,
password: flags.password as string,
+ apiKey: flags.apikey as string,
+ noCertForSsl: true,
+ log,
});
const totalPoliciesCount = flags.count as unknown as number;
From fec1df1c46d4ecc89fd94d3f9dc7db35152f150a Mon Sep 17 00:00:00 2001
From: Tiago Costa
Date: Thu, 18 Apr 2024 20:58:16 +0100
Subject: [PATCH 20/69] skip flaky suite (#181102)
---
.../public/hooks/use_source_indices_fields.test.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/x-pack/plugins/search_playground/public/hooks/use_source_indices_fields.test.tsx b/x-pack/plugins/search_playground/public/hooks/use_source_indices_fields.test.tsx
index 754002f21d568..a066c33e412ca 100644
--- a/x-pack/plugins/search_playground/public/hooks/use_source_indices_fields.test.tsx
+++ b/x-pack/plugins/search_playground/public/hooks/use_source_indices_fields.test.tsx
@@ -20,7 +20,8 @@ let formHookSpy: jest.SpyInstance;
import { getIndicesWithNoSourceFields, useSourceIndicesFields } from './use_source_indices_field';
import { IndicesQuerySourceFields } from '../types';
-describe('useSourceIndicesFields Hook', () => {
+// FLAKY: https://github.com/elastic/kibana/issues/181102
+describe.skip('useSourceIndicesFields Hook', () => {
let postMock: jest.Mock;
const wrapper = ({ children }: { children: React.ReactNode }) => (
From 8f23f23f4d3263d2879df70446010f15359f8ebe Mon Sep 17 00:00:00 2001
From: Alexi Doak <109488926+doakalexi@users.noreply.github.com>
Date: Thu, 18 Apr 2024 15:40:59 -0700
Subject: [PATCH 21/69] [ResponseOps] Fix for flaky task state validation jest
integration test (#181206)
Resolves https://github.com/elastic/kibana/issues/164032#
## Summary
This PR unskips a flaky test caused by a race condition with a TM health
status log. We use a regex to find the log we care about instead of just
comparing the first log to the expected message.
### To verify
- Run the following command to run the test, and verify that it passes
```
node scripts/jest_integration.js x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts
```
---
.../integration_tests/task_state_validation.test.ts | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts b/x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts
index 75e5c9d942398..7f1d9d5e4aae9 100644
--- a/x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts
+++ b/x-pack/plugins/task_manager/server/integration_tests/task_state_validation.test.ts
@@ -258,8 +258,7 @@ describe('task state validation', () => {
});
});
- // FLAKY: https://github.com/elastic/kibana/issues/164032
- describe.skip('allow_reading_invalid_state: false', () => {
+ describe('allow_reading_invalid_state: false', () => {
const taskIdsToRemove: string[] = [];
let esServer: TestElasticsearchUtils;
let kibanaServer: TestKibanaUtils;
@@ -327,9 +326,11 @@ describe('task state validation', () => {
taskIdsToRemove.push(id);
await retry(async () => {
- expect(logSpy.mock.calls[0][0]).toBe(
- `Task (fooType/${id}) has a validation error: [foo]: expected value of type [string] but got [boolean]`
- );
+ const calls = logSpy.mock.calls as string[][];
+ const expected =
+ /^Task \(fooType\/.*\) has a validation error: \[foo\]: expected value of type \[string\] but got \[boolean\]/;
+ const found = calls.map((arr) => arr[0]).find((message) => message.match(expected) != null);
+ expect(found).toMatch(expected);
expect(updateSpy).toHaveBeenCalledWith(
expect.arrayContaining([expect.objectContaining({ id, taskType: 'fooType' })]),
{ validate: false }
From cbc68cd40ceff582083c2cf0514c29270ffe496b Mon Sep 17 00:00:00 2001
From: Cee Chen <549407+cee-chen@users.noreply.github.com>
Date: Thu, 18 Apr 2024 16:05:48 -0700
Subject: [PATCH 22/69] Upgrade EUI to v94.1.0 (major `EuiTable` refactors)
(#180514)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
`v93.6.0` ⏩ `v94.1.0`
> [!important]
> 👋 Hello everyone - this is a special release containing `EuiTable`'s
conversion to Emotion, several long-overdue cleanups and breaking
changes, and one or two fun new features. First, let's address the big
questions:
### Q: I'm listed as a codeowner, how much should I manually QA/review?
Answer: It depends on what exactly in your code changed, but _in
general_ I would strongly suggest at least pulling this branch down and
doing a quick visual smoke test of all tables (_note: **not**
datagrids_) in your apps/plugins. You should not expect to see any major
visual regressions.
If your table contained any kind of custom styling or behavior (e.g.
custom CSS, etc.) I **strongly** recommend taking more time to QA
thoroughly to ensure your table still looks and behaves as expected.
Teams with very manual or specific updates will be flagged below in
comment threads.
### Q: When do I need to review by?
This PR will be merged **after** 8.14FF. Because this upgrade touches so
many files and teams, we're aiming for asking for an admin merge by EOD
4/18 regardless of full approval status.
As always, you're welcome to ping us after merge if you find any issues
later ([see our
FAQ](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)),
as you will have until 8.15FF to catch any bugs.
### Q: What breaking changes were made, and why?
Here's a quick shortlist of all the changes made that affected the
majority of the commits in this PR:
#### Removed several top-level table props
- The `responsive` prop has been removed in favor of the new
`responsiveBreakpoint` prop (same `false` behavior as before)
- The following props were removed from basic and in-memory tables:
- `hasActions`, `isSelectable`, and `isExpandable`
- These props were not used for functionality and were only used for
styling tables in mobile/responsive views, which is not a best practice
pattern we wanted for our APIs. Mobile tables are now styled correctly
without needing consumers to pass these extra props.
- `textOnly`
- This prop was unused and had no meaningful impact on tables or table
content.
#### Removed hidden mobile vs. desktop DOM
Previously, EUI would set classes that applied `display: none` CSS for
content that was hidden for mobile vs. desktop. This is no longer the
case, and content that only displays for mobile or only displays for
desktop will no longer render to the DOM at all if the table is not in
that responsive state.
This is both more performant when rendering large quantities of
cells/content, and simpler to write test assertions for when comparing
what the user actually sees vs. what the DOM ‘sees’.
(c3eeb08441e4b6efe6505e7cddaa87b540ddb259,
78cefcd954a7b46eaccd05e431b5e24dc86071a3)
#### Removed direct usages of table `className`s
EuiTable `classNames` no longer have any styles attached to them, so
some instances where Kibana usages were applying the `className` for
styles have been replaced with direct component usage or removed
entirely (86ce80b61f92137df761d06a1d5f492d9f738dd7).
#### Custom table cell styles
Any custom CSS for table cells was previously being applied to the inner
`div.euiTableCellContent` wrapper. As of this latest release, the
`className` and `css` props will now be applied directly to the outer
`td.euiTableRowCell` element. If you were targeting custom styles table
cells, please re-QA your styles to ensure everything still looks as
expected.
---
Full changelog (click to collapse)
##
[`v94.1.0-backport.0`](https://github.com/elastic/eui/releases/v94.1.0-backport.0)
**This is a backport release only intended for use by Kibana.**
**Bug fixes**
- Fixed a visual text alignment regression in `EuiTableRowCell`s with
the `row` header scope
([#7681](https://github.com/elastic/eui/pull/7681))
**Accessibility**
- Improved `EuiBasicTable` and `EuiInMemoryTable`'s selection checkboxes
to have unique aria-labels per row
([#7672](https://github.com/elastic/eui/pull/7672))
## [`v94.1.0`](https://github.com/elastic/eui/releases/v94.1.0)
- Updated `EuiTableHeaderCell` to show a subdued `sortable` icon for
columns that are not currently sorted but can be
([#7656](https://github.com/elastic/eui/pull/7656))
- Updated `EuiBasicTable` and `EuiInMemoryTable`'s
`columns[].actions[]`'s to pass back click events to `onClick` callbacks
as the second callback
([#7667](https://github.com/elastic/eui/pull/7667))
## [`v94.0.0`](https://github.com/elastic/eui/releases/v94.0.0)
- Updated `EuiTable`, `EuiBasicTable`, and `EuiInMemoryTable` with a new
`responsiveBreakpoint` prop, which allows customizing the point at which
the table collapses into a mobile-friendly view with cards
([#7625](https://github.com/elastic/eui/pull/7625))
- Updated `EuiProvider`'s `componentDefaults` prop to allow configuring
`EuiTable.responsiveBreakpoint`
([#7625](https://github.com/elastic/eui/pull/7625))
**Bug fixes**
- `EuiBasicTable` & `EuiInMemoryTable` `isPrimary` actions are now
correctly shown on mobile views
([#7640](https://github.com/elastic/eui/pull/7640))
- Table `mobileOptions`:
([#7642](https://github.com/elastic/eui/pull/7642))
- `mobileOptions.align` is now respected instead of all cells being
forced to left alignment
- `textTruncate` and `textOnly` are now respected even if a `render`
function is not passed
**Breaking changes**
- Removed unused `EuiTableHeaderButton` component
([#7621](https://github.com/elastic/eui/pull/7621))
- Removed the `responsive` prop from `EuiTable`, `EuiBasicTable`, and
`EuiInMemoryTable`. Use the new `responsiveBreakpoint` prop instead
([#7625](https://github.com/elastic/eui/pull/7625))
- The following props are no longer needed by `EuiBasicTable` or
`EuiInMemoryTable` for responsive table behavior to work correctly, and
can be removed: ([#7632](https://github.com/elastic/eui/pull/7632))
- `isSelectable`
- `isExpandable`
- `hasActions`
- Removed the `showOnHover` prop from `EuiTableRowCell` /
`EuiBasicTable`/`EuiInMemoryTable`'s `columns` API. Use the new actions
`columns[].actions[].showOnHover` API instead.
([#7640](https://github.com/elastic/eui/pull/7640))
- Removed top-level `textOnly` prop from `EuiBasicTable` and
`EuiInMemoryTable`. Use `columns[].textOnly` instead.
([#7642](https://github.com/elastic/eui/pull/7642))
**DOM changes**
- `EuiTable` mobile headers no longer render in the DOM when not visible
(previously rendered with `display: none`). This may affect DOM testing
assertions. ([#7625](https://github.com/elastic/eui/pull/7625))
- `EuiTableRowCell` now applies passed `className`s to the parent ``
element, instead of to the inner cell content ``.
([#7631](https://github.com/elastic/eui/pull/7631))
- `EuiTableRow`s rendered by basic and memory tables now only render a
`.euiTableRow-isSelectable` className if the selection checkbox is not
disabled ([#7632](https://github.com/elastic/eui/pull/7632))
- `EuiTableRowCell`s with `textOnly` set to `false` will no longer
attempt to apply the `.euiTableCellContent__text` className to child
elements. ([#7641](https://github.com/elastic/eui/pull/7641))
- `EuiTableRowCell` no longer renders mobile headers to the DOM unless
the current table is displaying its responsive view.
([#7642](https://github.com/elastic/eui/pull/7642))
- `EuiTableHeaderCell` and `EuiTableRowCell` will no longer render in
the DOM at all on mobile if their columns' `mobileOptions.show` is set
to `false`. ([#7642](https://github.com/elastic/eui/pull/7642))
- `EuiTableHeaderCell` and `EuiTableRowCell` will no longer render in
the DOM at all on desktop if their columns' `mobileOptions.only` is set
to `true`. ([#7642](https://github.com/elastic/eui/pull/7642))
**CSS-in-JS conversions**
- Converted `EuiTable`, `EuiTableRow`, `EuiTableRowCell`, and all other
table subcomponents to Emotion
([#7654](https://github.com/elastic/eui/pull/7654))
- Removed the following `EuiTable` Sass variables:
([#7654](https://github.com/elastic/eui/pull/7654))
- `$euiTableCellContentPadding`
- `$euiTableCellContentPaddingCompressed`
- `$euiTableCellCheckboxWidth`
- `$euiTableHoverColor`
- `$euiTableSelectedColor`
- `$euiTableHoverSelectedColor`
- `$euiTableActionsBorderColor`
- `$euiTableHoverClickableColor`
- `$euiTableFocusClickableColor`
- Removed the following `EuiTable` Sass mixins:
([#7654](https://github.com/elastic/eui/pull/7654))
- `euiTableActionsBackgroundMobile`
- `euiTableCellCheckbox`
- `euiTableCell`
---
.../public/app.tsx | 12 +-
examples/field_formats_example/public/app.tsx | 53 +--
.../files_example/public/components/app.tsx | 5 +-
.../public/app/app.tsx | 62 ++--
package.json | 2 +-
.../src/components/table.tsx | 1 -
.../__snapshots__/status_table.test.tsx.snap | 2 -
.../src/status/components/status_table.tsx | 1 -
.../__snapshots__/i18n_service.test.tsx.snap | 2 +-
.../src/i18n_eui_mapping.tsx | 10 +-
.../documents_panel.test.tsx.snap | 1 -
.../__snapshots__/events_panel.test.tsx.snap | 2 -
.../pipeline_panel.test.tsx.snap | 1 -
.../components/sync_jobs/sync_jobs_table.tsx | 1 -
.../src/testbed/testbed.ts | 4 +-
.../src/query_history.test.tsx | 2 +-
.../src/query_history.tsx | 2 +-
.../field_stats/field_number_summary.tsx | 2 +-
src/dev/license_checker/config.ts | 2 +-
.../components/table/table.test.tsx | 15 +-
.../__snapshots__/data_view.test.tsx.snap | 314 +++++++----------
.../__snapshots__/indices_list.test.tsx.snap | 12 +-
.../indices_list/indices_list.tsx | 2 +-
.../color/__snapshots__/color.test.tsx.snap | 3 -
.../__snapshots__/static_lookup.test.tsx.snap | 2 -
.../url/__snapshots__/url.test.tsx.snap | 256 ++++++--------
.../__snapshots__/samples.test.tsx.snap | 1 -
.../table/__snapshots__/table.test.tsx.snap | 2 -
.../table/__snapshots__/table.test.tsx.snap | 1 -
.../table/__snapshots__/table.test.tsx.snap | 1 -
.../delete_modal_msg.test.tsx.snap | 4 -
.../index_pattern_table.tsx | 1 -
.../syntax_suggestions_popover.tsx | 1 -
.../clusters_table/clusters_table.test.tsx | 18 +-
.../clusters_table/clusters_table.tsx | 1 -
.../shards_view/shard_failure_table.tsx | 1 -
.../components/details/req_details_stats.tsx | 2 +-
.../__snapshots__/flyout.test.tsx.snap | 1 -
.../__snapshots__/relationships.test.tsx.snap | 6 -
.../__snapshots__/table.test.tsx.snap | 6 +-
.../components/delete_confirm_modal.test.tsx | 4 +-
.../objects_table/components/table.tsx | 2 +-
.../drilldown_table/drilldown_table.tsx | 4 +-
.../drilldown_template_table.tsx | 6 +-
.../doc_viewer_table/legacy/table.tsx | 3 +-
.../components/doc_viewer_table/table.scss | 12 +-
.../components/doc_viewer_table/table.tsx | 2 +-
test/functional/services/inspector.ts | 2 +-
test/functional/services/listing_table.ts | 10 +-
.../context_editor/index.tsx | 1 -
.../summary_table/helpers.test.tsx | 2 +-
.../summary_table/helpers.tsx | 2 +-
.../summary_table/index.tsx | 1 -
.../change_points_table.tsx | 7 +-
.../category_table/category_table.tsx | 2 -
.../components/maintenance_windows_list.tsx | 1 -
.../components/var_config/var_config.tsx | 1 -
.../all_cases/all_cases_list.test.tsx | 7 -
.../public/components/all_cases/table.tsx | 2 -
.../dashboard_sections/benchmarks_section.tsx | 2 +-
.../auto_follow_pattern_table.js | 1 -
.../follower_indices_table.js | 1 -
.../field_types_help_popover.tsx | 2 +-
.../data_visualizer_stats_table.tsx | 4 +-
.../data_drift/data_drift_overview_table.tsx | 1 -
.../analytics_tables/analytics_table.tsx | 2 -
.../analytics_tables/query_clicks_table.tsx | 1 -
.../analytics_tables/recent_queries_table.tsx | 2 -
.../api_logs/components/api_logs_table.tsx | 1 -
.../crawler/components/domains_table.test.tsx | 8 +-
.../curations/components/curations_table.tsx | 2 -
.../components/suggestions_table.tsx | 2 -
.../ignored_queries_panel.tsx | 1 -
.../tables/test_helpers/shared_columns.tsx | 8 +-
.../non_text_fields_body.test.tsx | 18 +-
.../result_settings_table.tsx | 2 +-
.../text_fields_body.test.tsx | 18 +-
.../search_application_schema.tsx | 5 +-
.../extraction_rules_table.tsx | 1 -
.../domain_management/domains_table.test.tsx | 6 +-
.../role_mapping/role_mappings_table.tsx | 2 +-
.../shared/sources_table/sources_table.tsx | 2 +-
.../group_source_prioritization.tsx | 2 +-
.../package_policies_table.tsx | 1 -
.../sections/agent_policy/list_page/index.tsx | 2 -
.../components/agent_list_table.tsx | 2 -
.../enrollment_token_list_page/index.tsx | 1 -
.../uninstall_token_list_page/index.tsx | 1 -
.../sections/data_stream/list_page/index.tsx | 1 -
.../detail/overview/markdown_renderers.tsx | 4 +-
.../__jest__/policy_table.test.tsx | 6 +-
.../__jest__/components/index_table.test.js | 2 +-
.../component_template_list/table.tsx | 1 -
.../field_parameters/relations_parameter.tsx | 1 -
.../data_stream_table/data_stream_table.tsx | 1 -
.../policies_table/policies_table.tsx | 1 -
.../index_list/index_table/index_table.js | 16 +-
.../template_table/template_table.tsx | 1 -
.../template_table/template_table.tsx | 1 -
.../sections/pipelines_list/table.tsx | 1 -
.../dimension_panel/dimension_editor.tsx | 2 +-
.../pipelines_table.test.js.snap | 2 -
.../pipeline_list/pipelines_table.js | 1 -
.../custom_selection_table.js | 2 +-
.../analytics_list/analytics_list.tsx | 3 -
.../analytics_id_selector.tsx | 2 -
.../components/jobs_list/jobs_list.js | 13 +-
.../advanced_detector_modal/function_help.tsx | 2 +-
.../nodes_overview/allocated_models.tsx | 3 -
.../nodes_overview/nodes_list.tsx | 3 -
.../model_management/models_list.tsx | 3 -
.../pipelines/expanded_row.tsx | 3 -
.../components/notifications_list.tsx | 3 -
.../components/analytics_panel/table.tsx | 3 -
.../anomaly_detection_panel/table.tsx | 3 -
.../__snapshots__/events_table.test.js.snap | 2 -
.../table/__snapshots__/table.test.js.snap | 2 -
.../settings/calendars/list/table/table.js | 1 -
.../list/__snapshots__/table.test.js.snap | 4 -
.../settings/filter_lists/list/table.js | 1 -
.../__snapshots__/latest_active.test.js.snap | 1 -
.../__snapshots__/latest_types.test.js.snap | 1 -
.../latest_versions.test.js.snap | 1 -
.../ccr/__snapshots__/ccr.test.js.snap | 1 -
.../logs/__snapshots__/logs.test.js.snap | 1 -
.../service_overview_errors_table/index.tsx | 17 +-
.../shared/overview_table_container/index.tsx | 5 +-
.../dataset_quality/table/table.tsx | 1 -
.../tabs/metadata/add_pin_to_row.tsx | 21 +-
.../asset_details/tabs/metadata/table.tsx | 5 +-
.../tabs/processes/processes_table.tsx | 5 +-
.../anomalies_table/anomalies_table.tsx | 1 -
.../sections/anomalies/table.tsx | 2 -
.../metrics/hosts/components/hosts_table.tsx | 3 +-
.../metrics/hosts/hooks/use_hosts_table.tsx | 6 +-
.../components/message_panel/message_text.tsx | 31 +-
.../journeys/private_locations.journey.ts | 8 +-
.../journeys/test_now_mode.journey.ts | 4 +-
.../browser_steps_list.tsx | 6 +-
.../monitor_summary/test_runs_table.tsx | 4 +-
.../monitor_list_table/monitor_list.tsx | 9 +-
.../settings/global_params/params_list.tsx | 1 -
.../waterfall_flyout_table.tsx | 4 +-
.../simple/ping_list/ping_list_table.tsx | 4 +-
.../monitor/ping_list/ping_list_table.tsx | 4 +-
.../availability_reporting.tsx | 2 +-
.../components/waterfall_flyout_table.tsx | 4 +-
.../overview/monitor_list/monitor_list.tsx | 4 +-
.../check_steps/steps_list.test.tsx | 27 +-
.../synthetics/check_steps/steps_list.tsx | 4 +-
.../legacy_uptime/lib/helper/rtl_helpers.tsx | 35 --
.../impactful_metrics/js_errors.tsx | 2 +-
.../cypress/e2e/all/packs_create_edit.cy.ts | 2 +-
.../form/pack_queries_status_table.tsx | 1 -
.../packs/pack_queries_status_table.tsx | 1 -
.../public/packs/pack_queries_table.tsx | 2 +-
.../remote_cluster_table.js | 1 -
.../management/report_listing_table.tsx | 1 -
.../message_list/citations_table.tsx | 1 -
.../sources_panel/indices_table.tsx | 1 -
.../api_keys_grid/api_keys_grid_page.tsx | 1 -
.../role_mappings_grid_page.test.tsx | 34 +-
.../role_mappings_grid_page.tsx | 176 ++++------
.../privilege_space_table.tsx | 1 -
.../roles/roles_grid/roles_grid_page.test.tsx | 22 +-
.../roles/roles_grid/roles_grid_page.tsx | 243 ++++++--------
.../public/management/table_utils.tsx | 37 --
.../users/users_grid/users_grid_page.tsx | 1 -
.../get_comments/stream/message_text.tsx | 31 +-
.../__snapshots__/index.test.tsx.snap | 3 -
.../event_fields_browser.test.tsx | 16 +-
.../ml_popover/jobs_table/jobs_table.tsx | 2 +-
.../execution_log_table.tsx | 1 -
.../linked_to_list/index.tsx | 1 -
.../linked_to_rule/index.test.tsx | 2 +-
.../add_prebuilt_rules_table.tsx | 1 -
.../components/rules_table/rules_tables.tsx | 1 -
.../upgrade_prebuilt_rules_table.tsx | 1 -
.../execution_events_table.tsx | 1 -
.../alerts_count_panel/alerts_count.test.tsx | 10 +-
.../alerts_count_panel/alerts_count.tsx | 8 +-
.../entity_analytics_anomalies/index.test.tsx | 2 +-
.../entity_analytics_anomalies/index.tsx | 2 +-
.../tabs/risk_inputs/risk_inputs.test.tsx | 4 +-
.../tabs/risk_inputs/risk_inputs_tab.tsx | 3 +-
.../components/risk_score_preview_table.tsx | 3 +-
.../risk_summary_flyout/risk_summary.test.tsx | 17 +-
.../risk_summary_flyout/risk_summary.tsx | 2 +-
.../authentications_host_table.test.tsx.snap | 316 +++++++++---------
.../authentications_user_table.test.tsx.snap | 316 +++++++++---------
.../uncommon_process_table/index.test.tsx | 26 +-
.../components/actions_log_table.tsx | 1 -
.../public/resolver/view/panel.test.tsx | 71 ++--
.../open_timeline/timelines_table/index.tsx | 2 -
.../row_renderers_browser.tsx | 1 -
.../policy_list/policy_table/policy_table.tsx | 1 -
.../repository_table/repository_table.tsx | 1 -
.../restore_table/restore_table.tsx | 1 -
.../components/snapshot_table.tsx | 1 -
.../spaces_grid/spaces_grid_page.tsx | 1 -
.../transform_list/transform_list.tsx | 3 -
.../translations/translations/fr-FR.json | 1 -
.../translations/translations/ja-JP.json | 1 -
.../translations/translations/zh-CN.json | 1 -
.../components/field_items/field_items.tsx | 7 -
.../components/field_items/index.ts | 2 +-
.../components/field_table/field_table.tsx | 4 +-
.../components/rule_error_log.test.tsx | 2 +-
.../components/rules_list_table.tsx | 1 -
.../watch_list_page/watch_list_page.tsx | 1 -
.../page_objects/tag_management_page.ts | 2 +-
.../services/ml/data_frame_analytics_table.ts | 8 +-
.../services/ml/stack_management_jobs.ts | 2 +-
yarn.lock | 8 +-
214 files changed, 1068 insertions(+), 1656 deletions(-)
delete mode 100644 x-pack/plugins/security/public/management/table_utils.tsx
diff --git a/examples/data_view_field_editor_example/public/app.tsx b/examples/data_view_field_editor_example/public/app.tsx
index 71e10634cd818..336c29aa2a1ca 100644
--- a/examples/data_view_field_editor_example/public/app.tsx
+++ b/examples/data_view_field_editor_example/public/app.tsx
@@ -7,6 +7,7 @@
*/
import {
+ EuiProvider,
DefaultItemAction,
EuiButton,
EuiCheckbox,
@@ -121,7 +122,6 @@ const DataViewFieldEditorExample = ({ dataView, dataViewFieldEditor }: Props) =>
items={fields}
columns={columns}
pagination={true}
- hasActions={true}
sorting={{
sort: {
field: 'name',
@@ -135,10 +135,12 @@ const DataViewFieldEditorExample = ({ dataView, dataViewFieldEditor }: Props) =>
);
return (
-
-
- {content}
-
+
+
+
+ {content}
+
+
);
};
diff --git a/examples/field_formats_example/public/app.tsx b/examples/field_formats_example/public/app.tsx
index 6aa2f2d5e6c75..2961925f0a160 100644
--- a/examples/field_formats_example/public/app.tsx
+++ b/examples/field_formats_example/public/app.tsx
@@ -14,6 +14,7 @@ import {
EuiCodeBlock,
EuiLink,
EuiPageTemplate,
+ EuiProvider,
EuiSpacer,
EuiText,
EuiTitle,
@@ -61,7 +62,6 @@ const UsingAnExistingFieldFormatExample: React.FC<{ deps: Deps }> = (props) => {
= (props) => {
= (props) => {
export const App: React.FC<{ deps: Deps }> = (props) => {
return (
-
-
-
-
- Using an existing field format
-
-
-
-
-
-
- Creating a custom field format
-
-
-
-
-
-
- Creating a custom field format editor
-
-
-
-
-
+
+
+
+
+
+ Using an existing field format
+
+
+
+
+
+
+ Creating a custom field format
+
+
+
+
+
+
+ Creating a custom field format editor
+
+
+
+
+
+
);
};
diff --git a/examples/files_example/public/components/app.tsx b/examples/files_example/public/components/app.tsx
index db0968d7b43f2..5fea8c5fbc42d 100644
--- a/examples/files_example/public/components/app.tsx
+++ b/examples/files_example/public/components/app.tsx
@@ -12,6 +12,7 @@ import type { FileJSON } from '@kbn/files-plugin/common';
import type { FilesClientResponses } from '@kbn/files-plugin/public';
import {
+ EuiProvider,
EuiPageTemplate,
EuiInMemoryTable,
EuiInMemoryTableProps,
@@ -131,7 +132,7 @@ export const FilesExampleApp = ({ files, notifications }: FilesExampleAppDeps) =
];
return (
- <>
+
@@ -185,6 +186,6 @@ export const FilesExampleApp = ({ files, notifications }: FilesExampleAppDeps) =
}}
/>
)}
- >
+
);
};
diff --git a/examples/partial_results_example/public/app/app.tsx b/examples/partial_results_example/public/app/app.tsx
index 333ce7f6c263e..fb0fe9e3dbef4 100644
--- a/examples/partial_results_example/public/app/app.tsx
+++ b/examples/partial_results_example/public/app/app.tsx
@@ -9,6 +9,7 @@
import React, { useContext, useEffect, useState } from 'react';
import { pluck } from 'rxjs';
import {
+ EuiProvider,
EuiBasicTable,
EuiCallOut,
EuiCodeBlock,
@@ -40,35 +41,36 @@ export function App() {
}, [expressions]);
return (
-
-
-
-
-
- This example listens for the window events and adds them to the table along with a
- trigger counter.
-
-
-
- {expression}
-
- {datatable ? (
- ({
- field,
- name,
- 'data-test-subj': `example-column-${field.toLowerCase()}`,
- }))}
- items={datatable.rows ?? []}
- />
- ) : (
-
- Click or press any key.
-
- )}
-
-
+
+
+
+
+
+
+ This example listens for the window events and adds them to the table along with a
+ trigger counter.
+
+
+
+ {expression}
+
+ {datatable ? (
+ ({
+ field,
+ name,
+ 'data-test-subj': `example-column-${field.toLowerCase()}`,
+ }))}
+ items={datatable.rows ?? []}
+ />
+ ) : (
+
+ Click or press any key.
+
+ )}
+
+
+
);
}
diff --git a/package.json b/package.json
index 19f84d4203033..f23061e31e692 100644
--- a/package.json
+++ b/package.json
@@ -107,7 +107,7 @@
"@elastic/ecs": "^8.11.1",
"@elastic/elasticsearch": "^8.13.0",
"@elastic/ems-client": "8.5.1",
- "@elastic/eui": "93.6.0",
+ "@elastic/eui": "94.1.0-backport.0",
"@elastic/filesaver": "1.1.2",
"@elastic/node-crypto": "1.2.1",
"@elastic/numeral": "^2.5.1",
diff --git a/packages/content-management/table_list_view_table/src/components/table.tsx b/packages/content-management/table_list_view_table/src/components/table.tsx
index 42bd676343362..a459bc26ede50 100644
--- a/packages/content-management/table_list_view_table/src/components/table.tsx
+++ b/packages/content-management/table_list_view_table/src/components/table.tsx
@@ -242,7 +242,6 @@ export function Table({
data-test-subj="itemsInMemTable"
rowHeader="attributes.title"
tableCaption={tableCaption}
- isSelectable
/>
);
}
diff --git a/packages/core/apps/core-apps-browser-internal/src/status/components/__snapshots__/status_table.test.tsx.snap b/packages/core/apps/core-apps-browser-internal/src/status/components/__snapshots__/status_table.test.tsx.snap
index cb10255eb9998..934027aa35ea7 100644
--- a/packages/core/apps/core-apps-browser-internal/src/status/components/__snapshots__/status_table.test.tsx.snap
+++ b/packages/core/apps/core-apps-browser-internal/src/status/components/__snapshots__/status_table.test.tsx.snap
@@ -38,7 +38,6 @@ exports[`StatusTable renders when statuses is provided 1`] = `
]
}
data-test-subj="statusBreakdown"
- isExpandable={true}
itemId={[Function]}
itemIdToExpandedRowMap={Object {}}
items={
@@ -58,7 +57,6 @@ exports[`StatusTable renders when statuses is provided 1`] = `
},
]
}
- responsive={true}
rowProps={[Function]}
searchFormat="eql"
sorting={
diff --git a/packages/core/apps/core-apps-browser-internal/src/status/components/status_table.tsx b/packages/core/apps/core-apps-browser-internal/src/status/components/status_table.tsx
index 37833ebfde923..977dd3efb3e0e 100644
--- a/packages/core/apps/core-apps-browser-internal/src/status/components/status_table.tsx
+++ b/packages/core/apps/core-apps-browser-internal/src/status/components/status_table.tsx
@@ -104,7 +104,6 @@ export const StatusTable: FunctionComponent = ({ statuses }) =
columns={tableColumns}
itemId={(item) => item.id}
items={statuses}
- isExpandable={true}
itemIdToExpandedRowMap={itemIdToExpandedRowMap}
rowProps={({ state }) => ({
className: `status-table-row-${state.uiColor}`,
diff --git a/packages/core/i18n/core-i18n-browser-internal/src/__snapshots__/i18n_service.test.tsx.snap b/packages/core/i18n/core-i18n-browser-internal/src/__snapshots__/i18n_service.test.tsx.snap
index 44170ebcfb06e..d9fc8ecec8050 100644
--- a/packages/core/i18n/core-i18n-browser-internal/src/__snapshots__/i18n_service.test.tsx.snap
+++ b/packages/core/i18n/core-i18n-browser-internal/src/__snapshots__/i18n_service.test.tsx.snap
@@ -14,7 +14,7 @@ exports[`#start() returns \`Context\` component 1`] = `
"euiAutoRefresh.buttonLabelOn": [Function],
"euiBasicTable.noItemsMessage": "No items found",
"euiBasicTable.selectAllRows": "Select all rows",
- "euiBasicTable.selectThisRow": "Select this row",
+ "euiBasicTable.selectThisRow": [Function],
"euiBasicTable.tableAutoCaptionWithPagination": [Function],
"euiBasicTable.tableAutoCaptionWithoutPagination": [Function],
"euiBasicTable.tableCaptionWithPagination": [Function],
diff --git a/packages/core/i18n/core-i18n-browser-internal/src/i18n_eui_mapping.tsx b/packages/core/i18n/core-i18n-browser-internal/src/i18n_eui_mapping.tsx
index e4f769c8779c7..3ea767bc5b6bc 100644
--- a/packages/core/i18n/core-i18n-browser-internal/src/i18n_eui_mapping.tsx
+++ b/packages/core/i18n/core-i18n-browser-internal/src/i18n_eui_mapping.tsx
@@ -38,10 +38,12 @@ export const getEuiContextMapping = (): EuiTokensObject => {
defaultMessage: 'Select all rows',
description: 'ARIA and displayed label on a checkbox to select all table rows',
}),
- 'euiBasicTable.selectThisRow': i18n.translate('core.euiBasicTable.selectThisRow', {
- defaultMessage: 'Select this row',
- description: 'ARIA and displayed label on a checkbox to select a single table row',
- }),
+ 'euiBasicTable.selectThisRow': ({ index }: EuiValues) =>
+ i18n.translate('core.euiBasicTable.selectThisRow', {
+ defaultMessage: 'Select row {index}',
+ values: { index },
+ description: 'ARIA and displayed label on a checkbox to select a single table row',
+ }),
'euiBasicTable.tableCaptionWithPagination': ({ tableCaption, page, pageCount }: EuiValues) =>
i18n.translate('core.euiBasicTable.tableCaptionWithPagination', {
defaultMessage: '{tableCaption}; Page {page} of {pageCount}.',
diff --git a/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/documents_panel.test.tsx.snap b/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/documents_panel.test.tsx.snap
index 40f115c567f81..66caa5b55f567 100644
--- a/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/documents_panel.test.tsx.snap
+++ b/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/documents_panel.test.tsx.snap
@@ -119,7 +119,6 @@ exports[`DocumentsPanel renders 1`] = `
token="euiBasicTable.noItemsMessage"
/>
}
- responsive={true}
tableLayout="fixed"
/>
diff --git a/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/events_panel.test.tsx.snap b/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/events_panel.test.tsx.snap
index d4bdda45ccc3b..8320547cb2107 100644
--- a/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/events_panel.test.tsx.snap
+++ b/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/events_panel.test.tsx.snap
@@ -54,7 +54,6 @@ exports[`EventsPanel renders 1`] = `
token="euiBasicTable.noItemsMessage"
/>
}
- responsive={true}
tableLayout="fixed"
/>
@@ -110,7 +109,6 @@ exports[`EventsPanel renders with some values missing 1`] = `
token="euiBasicTable.noItemsMessage"
/>
}
- responsive={true}
tableLayout="fixed"
/>
diff --git a/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/pipeline_panel.test.tsx.snap b/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/pipeline_panel.test.tsx.snap
index cddd85fc851b9..66d241be8d92c 100644
--- a/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/pipeline_panel.test.tsx.snap
+++ b/packages/kbn-search-connectors/components/sync_jobs/__snapshots__/pipeline_panel.test.tsx.snap
@@ -43,7 +43,6 @@ exports[`PipelinePanel renders 1`] = `
token="euiBasicTable.noItemsMessage"
/>
}
- responsive={true}
tableLayout="fixed"
/>
diff --git a/packages/kbn-search-connectors/components/sync_jobs/sync_jobs_table.tsx b/packages/kbn-search-connectors/components/sync_jobs/sync_jobs_table.tsx
index ffe2c26d636ed..87f3559c3fab6 100644
--- a/packages/kbn-search-connectors/components/sync_jobs/sync_jobs_table.tsx
+++ b/packages/kbn-search-connectors/components/sync_jobs/sync_jobs_table.tsx
@@ -263,7 +263,6 @@ export const SyncJobsTable: React.FC = ({
data-test-subj={`entSearchContent-index-${type}-syncJobs-table`}
items={syncJobs}
columns={columns}
- hasActions
onChange={onPaginate}
pagination={pagination}
tableLayout="fixed"
diff --git a/packages/kbn-test-jest-helpers/src/testbed/testbed.ts b/packages/kbn-test-jest-helpers/src/testbed/testbed.ts
index 284e8d557de6f..4559924c28aff 100644
--- a/packages/kbn-test-jest-helpers/src/testbed/testbed.ts
+++ b/packages/kbn-test-jest-helpers/src/testbed/testbed.ts
@@ -263,11 +263,11 @@ export function registerTestBed ({
reactWrapper: row,
- columns: row.find('.euiTableCellContent').map((col) => ({
+ columns: row.find('div.euiTableCellContent').map((col) => ({
reactWrapper: col,
// We can't access the td value with col.text() because
// eui adds an extra div in td on mobile => (.euiTableRowCell__mobileHeader)
- value: col.find('.euiTableCellContent').text(),
+ value: col.find('div.euiTableCellContent').text(),
})),
}));
diff --git a/packages/kbn-text-based-editor/src/query_history.test.tsx b/packages/kbn-text-based-editor/src/query_history.test.tsx
index 6ee970321a9ae..d1b356e31eaa1 100644
--- a/packages/kbn-text-based-editor/src/query_history.test.tsx
+++ b/packages/kbn-text-based-editor/src/query_history.test.tsx
@@ -159,7 +159,7 @@ describe('QueryHistory', () => {
/>
);
expect(screen.getByRole('table')).toHaveTextContent(
- 'Time ranRecent queriesLast durationTime ranMar. 25, 24 08:45:27Recent queriesfrom kibana_sample_data_flights | limit 10Last duration2ms'
+ 'Time ranRecent queriesLast durationMar. 25, 24 08:45:27from kibana_sample_data_flights | limit 102ms'
);
});
});
diff --git a/packages/kbn-text-based-editor/src/query_history.tsx b/packages/kbn-text-based-editor/src/query_history.tsx
index 3e597cd1ed86f..0759c7fd7e816 100644
--- a/packages/kbn-text-based-editor/src/query_history.tsx
+++ b/packages/kbn-text-based-editor/src/query_history.tsx
@@ -380,7 +380,7 @@ export function QueryHistory({
defaultMessage: 'Queries history table',
}
)}
- responsive={false}
+ responsiveBreakpoint={false}
items={historyItems}
columns={columns}
sorting={sorting}
diff --git a/packages/kbn-unified-field-list/src/components/field_stats/field_number_summary.tsx b/packages/kbn-unified-field-list/src/components/field_stats/field_number_summary.tsx
index 8e4cdc3d0ff88..5d573e926f5ba 100755
--- a/packages/kbn-unified-field-list/src/components/field_stats/field_number_summary.tsx
+++ b/packages/kbn-unified-field-list/src/components/field_stats/field_number_summary.tsx
@@ -88,7 +88,7 @@ export const FieldNumberSummary: React.FC = ({
columns={summaryTableColumns}
tableCaption={summaryTableTitle}
data-test-subj={`${dataTestSubject}-numberSummary`}
- responsive={false}
+ responsiveBreakpoint={false}
css={css`
& .euiTableHeaderCell {
${euiScreenReaderOnly()}
diff --git a/src/dev/license_checker/config.ts b/src/dev/license_checker/config.ts
index e0e4b2f1376fa..c708ab543476d 100644
--- a/src/dev/license_checker/config.ts
+++ b/src/dev/license_checker/config.ts
@@ -86,7 +86,7 @@ export const LICENSE_OVERRIDES = {
'jsts@1.6.2': ['Eclipse Distribution License - v 1.0'], // cf. https://github.com/bjornharrtell/jsts
'@mapbox/jsonlint-lines-primitives@2.0.2': ['MIT'], // license in readme https://github.com/tmcw/jsonlint
'@elastic/ems-client@8.5.1': ['Elastic License 2.0'],
- '@elastic/eui@93.6.0': ['SSPL-1.0 OR Elastic License 2.0'],
+ '@elastic/eui@94.1.0-backport.0': ['SSPL-1.0 OR Elastic License 2.0'],
'language-subtag-registry@0.3.21': ['CC-BY-4.0'], // retired ODC‑By license https://github.com/mattcg/language-subtag-registry
'buffers@0.1.1': ['MIT'], // license in importing module https://www.npmjs.com/package/binary
'@bufbuild/protobuf@1.2.1': ['Apache-2.0'], // license (Apache-2.0 AND BSD-3-Clause)
diff --git a/src/plugins/data/public/search/session/sessions_mgmt/components/table/table.test.tsx b/src/plugins/data/public/search/session/sessions_mgmt/components/table/table.test.tsx
index de96c865b90e0..6394deeab843b 100644
--- a/src/plugins/data/public/search/session/sessions_mgmt/components/table/table.test.tsx
+++ b/src/plugins/data/public/search/session/sessions_mgmt/components/table/table.test.tsx
@@ -100,8 +100,7 @@ describe('Background Search Session Management Table', () => {
);
});
- expect(table.find('thead th .euiTableCellContent__text').map((node) => node.text()))
- .toMatchInlineSnapshot(`
+ expect(table.find('thead th').map((node) => node.text())).toMatchInlineSnapshot(`
Array [
"App",
"Name",
@@ -136,12 +135,12 @@ describe('Background Search Session Management Table', () => {
expect(table.find('tbody td').map((node) => node.text())).toMatchInlineSnapshot(`
Array [
- "App",
- "Namevery background search Info",
- "# Searches0",
- "StatusExpired",
- "Created2 Dec, 2020, 00:19:32",
- "Expiration--",
+ "",
+ "very background search Info",
+ "0",
+ "Expired",
+ "2 Dec, 2020, 00:19:32",
+ "--",
"",
"",
]
diff --git a/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap b/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap
index eb243025df2f7..77df622eaddbb 100644
--- a/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap
+++ b/src/plugins/data/public/utils/table_inspector_view/components/__snapshots__/data_view.test.tsx.snap
@@ -200,123 +200,79 @@ Array [
class="euiBasicTable insDataTableFormat__table eui-xScroll css-1f59z3t"
data-test-subj="inspectorTable"
>
-
- |