forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Profiling] adding KQL bar to embeddables (elastic#171016)
Adding KQL bar to the `Flamegraph` and `Top 10 functions` embeddable. https://github.com/elastic/kibana/assets/55978943/ddd74947-d6e6-4fc5-a563-c1f62853a434 New version: <img width="1649" alt="Screenshot 2023-11-21 at 11 14 32" src="https://github.com/elastic/kibana/assets/55978943/16899d1e-485d-477a-bda0-48a22e9e0e56"> --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
2f258a2
commit 07432ab
Showing
20 changed files
with
414 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { toKueryFilterFormat, mergeKueries } from './kuery_utils'; | ||
|
||
describe('toKueryFilterFormat', () => { | ||
it('returns a single value', () => { | ||
expect(toKueryFilterFormat('key', ['foo'])).toEqual(`key : "foo"`); | ||
}); | ||
|
||
it('returns multiple values default separator', () => { | ||
expect(toKueryFilterFormat('key', ['foo', 'bar', 'baz'])).toEqual( | ||
`key : "foo" OR key : "bar" OR key : "baz"` | ||
); | ||
}); | ||
|
||
it('returns multiple values custom separator', () => { | ||
expect(toKueryFilterFormat('key', ['foo', 'bar', 'baz'], 'AND')).toEqual( | ||
`key : "foo" AND key : "bar" AND key : "baz"` | ||
); | ||
}); | ||
|
||
it('return empty string when no hostname', () => { | ||
expect(toKueryFilterFormat('key', [])).toEqual(''); | ||
}); | ||
|
||
describe('mergeKueries', () => { | ||
it('returns empty string when both kueries are empty', () => { | ||
expect(mergeKueries(['', ''])).toEqual(''); | ||
}); | ||
|
||
it('returns only first kuery when second is empty', () => { | ||
expect(mergeKueries(['host.name: "foo"', ''])).toEqual( | ||
'host.name: "foo"' | ||
); | ||
}); | ||
|
||
it('returns second kuery when first is empty', () => { | ||
expect(mergeKueries(['', 'host.name: "foo"'])).toEqual( | ||
'host.name: "foo"' | ||
); | ||
}); | ||
|
||
it('returns merged kueries with default separator', () => { | ||
expect( | ||
mergeKueries([ | ||
'host.name: "foo" OR host.name: "bar"', | ||
'process.id: "1"', | ||
]) | ||
).toEqual('host.name: "foo" OR host.name: "bar" AND process.id: "1"'); | ||
}); | ||
|
||
it('uses custom separator', () => { | ||
expect( | ||
mergeKueries(['host.name: "foo"', 'process.id: "1"'], 'OR') | ||
).toEqual('host.name: "foo" OR process.id: "1"'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { isEmpty } from 'lodash'; | ||
|
||
type Separator = 'OR' | 'AND'; | ||
|
||
export const toKueryFilterFormat = ( | ||
key: string, | ||
values: string[], | ||
separator: Separator = 'OR' | ||
) => values.map((value) => `${key} : "${value}"`).join(` ${separator} `); | ||
|
||
export const mergeKueries = (filters: string[], separator: Separator = 'AND') => | ||
filters.filter((filter) => !isEmpty(filter)).join(` ${separator} `); |
29 changes: 0 additions & 29 deletions
29
x-pack/plugins/apm/common/utils/to_kuery_filter_format.test.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.