[8.7] [SecuritySolution] Fix index filters (#151069) (#151362)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[SecuritySolution] Fix index filters
(#151069)](https://github.com/elastic/kibana/pull/151069)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Angela
Chuang","email":"6295984+angorayc@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-02-15T18:12:27Z","message":"[SecuritySolution]
Fix index filters (#151069)\n\n## Summary\r\nRelevant issues:
\r\nhttps://github.com/elastic/kibana/pull/148681/files#r1104594568\r\nhttps://github.com/elastic/kibana/pull/136407\r\n\r\nPlease
enable feature flag: chartEmbeddablesEnabled\r\n\r\n### Steps to
verify:\r\n1. Check the selected index patterns you have from the
sourcerer\r\n2. Inspect KPIs on host / network / users pages, make sure
it matches\r\nthe selected index patterns from the sourcerer\r\n3. Click
`...` button of each KPIs and `Open in Lens`, Inspect >\r\nrequest, and
check the displayed index patterns matches index filters.\r\n\r\n###
Before: Indices were missing from the inspect panel:\r\n<img
width=\"2554\" alt=\"Screenshot 2023-02-13 at 19 50
47\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218560779-0df2a1e6-072c-4ccc-8004-e92256fadd05.png\">\r\n\r\nIndex
patterns were missing from Lens inspect panel: \r\n<img width=\"1281\"
alt=\"Screenshot 2023-02-13 at 19 51
14\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218560799-476614a6-fda2-452d-a043-47723c1bf13a.png\">\r\n\r\n###
After:\r\n<img width=\"2554\" alt=\"Screenshot 2023-02-13 at 19 57
46\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218561890-3ac6206f-ad64-46fe-88cd-ef11abce0651.png\">\r\n<img
width=\"2560\" alt=\"Screenshot 2023-02-13 at 19 58
11\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218561897-b9d5046d-335e-4309-be9f-28025605434d.png\">\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"2205ba74886577f818bd43ece5c0817daea56b5b","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:Threat
Hunting","Team: SecuritySolution","Team:Threat
Hunting:Explore","v8.7.0","v8.8.0"],"number":151069,"url":"https://github.com/elastic/kibana/pull/151069","mergeCommit":{"message":"[SecuritySolution]
Fix index filters (#151069)\n\n## Summary\r\nRelevant issues:
\r\nhttps://github.com/elastic/kibana/pull/148681/files#r1104594568\r\nhttps://github.com/elastic/kibana/pull/136407\r\n\r\nPlease
enable feature flag: chartEmbeddablesEnabled\r\n\r\n### Steps to
verify:\r\n1. Check the selected index patterns you have from the
sourcerer\r\n2. Inspect KPIs on host / network / users pages, make sure
it matches\r\nthe selected index patterns from the sourcerer\r\n3. Click
`...` button of each KPIs and `Open in Lens`, Inspect >\r\nrequest, and
check the displayed index patterns matches index filters.\r\n\r\n###
Before: Indices were missing from the inspect panel:\r\n<img
width=\"2554\" alt=\"Screenshot 2023-02-13 at 19 50
47\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218560779-0df2a1e6-072c-4ccc-8004-e92256fadd05.png\">\r\n\r\nIndex
patterns were missing from Lens inspect panel: \r\n<img width=\"1281\"
alt=\"Screenshot 2023-02-13 at 19 51
14\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218560799-476614a6-fda2-452d-a043-47723c1bf13a.png\">\r\n\r\n###
After:\r\n<img width=\"2554\" alt=\"Screenshot 2023-02-13 at 19 57
46\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218561890-3ac6206f-ad64-46fe-88cd-ef11abce0651.png\">\r\n<img
width=\"2560\" alt=\"Screenshot 2023-02-13 at 19 58
11\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218561897-b9d5046d-335e-4309-be9f-28025605434d.png\">\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"2205ba74886577f818bd43ece5c0817daea56b5b"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151069","number":151069,"mergeCommit":{"message":"[SecuritySolution]
Fix index filters (#151069)\n\n## Summary\r\nRelevant issues:
\r\nhttps://github.com/elastic/kibana/pull/148681/files#r1104594568\r\nhttps://github.com/elastic/kibana/pull/136407\r\n\r\nPlease
enable feature flag: chartEmbeddablesEnabled\r\n\r\n### Steps to
verify:\r\n1. Check the selected index patterns you have from the
sourcerer\r\n2. Inspect KPIs on host / network / users pages, make sure
it matches\r\nthe selected index patterns from the sourcerer\r\n3. Click
`...` button of each KPIs and `Open in Lens`, Inspect >\r\nrequest, and
check the displayed index patterns matches index filters.\r\n\r\n###
Before: Indices were missing from the inspect panel:\r\n<img
width=\"2554\" alt=\"Screenshot 2023-02-13 at 19 50
47\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218560779-0df2a1e6-072c-4ccc-8004-e92256fadd05.png\">\r\n\r\nIndex
patterns were missing from Lens inspect panel: \r\n<img width=\"1281\"
alt=\"Screenshot 2023-02-13 at 19 51
14\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218560799-476614a6-fda2-452d-a043-47723c1bf13a.png\">\r\n\r\n###
After:\r\n<img width=\"2554\" alt=\"Screenshot 2023-02-13 at 19 57
46\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218561890-3ac6206f-ad64-46fe-88cd-ef11abce0651.png\">\r\n<img
width=\"2560\" alt=\"Screenshot 2023-02-13 at 19 58
11\"\r\nsrc=\"https://user-images.githubusercontent.com/6295984/218561897-b9d5046d-335e-4309-be9f-28025605434d.png\">\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"2205ba74886577f818bd43ece5c0817daea56b5b"}}]}]
BACKPORT-->

Co-authored-by: Angela Chuang <6295984+angorayc@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-02-15 14:51:03 -05:00 committed by GitHub
parent e45cd84cb3
commit 28a83c4c53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 571 additions and 535 deletions

View file

@ -163,6 +163,32 @@ describe('SearchSource', () => {
expect(searchSource.getActiveIndexFilter()).toMatchObject(['auditbeat-*']);
});
test('pass _index from filter - phrases filter', () => {
const filter: Filter[] = [
{
meta: {
type: 'phrases',
key: '_index',
params: ['auditbeat-*', 'packetbeat-*'],
alias: null,
negate: false,
disabled: false,
},
query: {
bool: {
should: [
{ match_phrase: { _index: 'auditbeat-*' } },
{ match_phrase: { _index: 'packetbeat-*' } },
],
minimum_should_match: 1,
},
},
},
];
searchSource.setField('filter', filter);
expect(searchSource.getActiveIndexFilter()).toMatchObject(['auditbeat-*', 'packetbeat-*']);
});
test('pass _index from query and filter with negate equals to true', () => {
const filter = [
{

View file

@ -82,7 +82,13 @@ import {
} from 'rxjs/operators';
import { defer, EMPTY, from, lastValueFrom, Observable } from 'rxjs';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { buildEsQuery, Filter, isOfQueryType, isPhraseFilter } from '@kbn/es-query';
import {
buildEsQuery,
Filter,
isOfQueryType,
isPhraseFilter,
isPhrasesFilter,
} from '@kbn/es-query';
import { fieldWildcardFilter } from '@kbn/kibana-utils-plugin/common';
import { getHighlightRequest } from '@kbn/field-formats-plugin/common';
import type { DataView } from '@kbn/data-views-plugin/common';
@ -279,12 +285,16 @@ export class SearchSource {
}, []) ?? [];
const activeIndexPattern = filters?.reduce((acc, f) => {
if (isPhraseFilter(f)) {
const isPhraseFilterType = isPhraseFilter(f);
const isPhrasesFilterType = isPhrasesFilter(f);
const filtersToChange = isPhraseFilterType ? f.meta.params?.query : f.meta.params;
const filtersArray = Array.isArray(filtersToChange) ? filtersToChange : [filtersToChange];
if (isPhraseFilterType || isPhrasesFilterType) {
if (f.meta.key === '_index' && f.meta.disabled === false) {
if (f.meta.negate === false) {
return concat(acc, f.meta.params?.query ?? f.meta.params);
return concat(acc, filtersArray);
} else {
return difference(acc, [f.meta.params?.query]);
return difference(acc, filtersArray);
}
} else {
return acc;

View file

@ -124,23 +124,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -204,6 +187,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -68,23 +68,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -148,6 +131,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -104,23 +104,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -184,6 +167,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -91,23 +91,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -132,6 +115,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"internalReferences": Array [],
"query": Object {

View file

@ -94,23 +94,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -135,6 +118,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"internalReferences": Array [],
"query": Object {
@ -253,23 +253,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -294,6 +277,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"internalReferences": Array [],
"query": Object {

View file

@ -94,23 +94,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -135,6 +118,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"internalReferences": Array [],
"query": Object {
@ -284,23 +284,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -325,6 +308,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"internalReferences": Array [],
"query": Object {
@ -450,23 +450,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -491,6 +474,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"internalReferences": Array [],
"query": Object {

View file

@ -92,23 +92,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -126,6 +109,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"internalReferences": Array [
Object {

View file

@ -52,23 +52,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -132,6 +115,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -40,23 +40,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -120,6 +103,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -86,23 +86,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -166,6 +149,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -99,23 +99,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -179,6 +162,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -40,23 +40,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -120,6 +103,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -40,23 +40,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -120,6 +103,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -96,23 +96,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -193,6 +176,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -83,23 +83,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -180,6 +163,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -88,23 +88,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -185,6 +168,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -107,23 +107,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -204,6 +187,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -71,23 +71,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -168,6 +151,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -93,23 +93,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -190,6 +173,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -106,23 +106,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -203,6 +186,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -44,23 +44,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -141,6 +124,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -44,23 +44,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -141,6 +124,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -52,23 +52,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -110,6 +93,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -39,23 +39,6 @@ Object {
},
},
"filters": Array [
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -97,6 +80,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -68,23 +68,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -126,6 +109,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -119,23 +119,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -177,6 +160,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -124,23 +124,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -182,6 +165,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -69,23 +69,6 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
Object {
"meta": Object {
"alias": null,
@ -127,6 +110,23 @@ Object {
},
},
},
Object {
"meta": Object {
"alias": null,
"disabled": false,
"key": "host.id",
"negate": false,
"params": Object {
"query": "123",
},
"type": "phrase",
},
"query": Object {
"match_phrase": Object {
"host.id": "123",
},
},
},
],
"query": Object {
"language": "kql",

View file

@ -69,10 +69,10 @@ describe('useLensAttributes', () => {
expect(result?.current?.state.filters).toEqual([
...getExternalAlertLensAttributes().state.filters,
...filterFromSearchBar,
...getDetailsPageFilter('hosts', 'mockHost'),
...hostNameExistsFilter,
...getIndexFilters(['auditbeat-*']),
...filterFromSearchBar,
]);
});
@ -95,10 +95,10 @@ describe('useLensAttributes', () => {
expect(result?.current?.state.filters).toEqual([
...getExternalAlertLensAttributes().state.filters,
...filterFromSearchBar,
...getNetworkDetailsPageFilter('192.168.1.1'),
...sourceOrDestinationIpExistsFilter,
...getIndexFilters(['auditbeat-*']),
...filterFromSearchBar,
]);
});
@ -121,9 +121,9 @@ describe('useLensAttributes', () => {
expect(result?.current?.state.filters).toEqual([
...getExternalAlertLensAttributes().state.filters,
...filterFromSearchBar,
...getDetailsPageFilter('user', 'elastic'),
...getIndexFilters(['auditbeat-*']),
...filterFromSearchBar,
]);
});

View file

@ -108,10 +108,10 @@ export const useLensAttributes = ({
...(applyGlobalQueriesAndFilters ? { query } : {}),
filters: [
...attrs.state.filters,
...(applyGlobalQueriesAndFilters ? filters : []),
...pageFilters,
...tabsFilters,
...indexFilters,
...(applyGlobalQueriesAndFilters ? filters : []),
],
},
references: attrs?.references?.map((ref: { id: string; name: string; type: string }) => ({