-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lens] Adds using queries/filters for field existence endpoint #59033
Merged
mbondyra
merged 17 commits into
elastic:master
from
mbondyra:IS-52826_field-existence-endpoint-respects-filters
Mar 12, 2020
Merged
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
967504e
fix: respect filters and query for displaying field existence
mbondyra b04f250
test: added dslQuery to test
mbondyra be49d62
test: fix tests
mbondyra 21429ea
fix: fix types
mbondyra 6b692ab
fix: integration tests
mbondyra f2aca43
test: add integration test
mbondyra 97e560b
refactor: add default
mbondyra 836d1e1
test: corrected id for new entry
mbondyra 770d241
refactor: change to post
mbondyra 61f2b35
types
mbondyra 57cea75
eslint
mbondyra c1043c2
test: fixes
mbondyra a496d75
Merge branch 'master' into IS-52826_field-existence-endpoint-respects…
mbondyra beb0a7a
test
mbondyra 4afd03f
fix test
mbondyra 7f3a136
Merge branch 'master' into IS-52826_field-existence-endpoint-respects…
elasticmachine 7993eef
Merge remote-tracking branch 'origin/master' into HEAD
wylieconlon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; | |
|
||
const TEST_START_TIME = encodeURIComponent('2015-09-19T06:31:44.000'); | ||
const TEST_END_TIME = encodeURIComponent('2015-09-23T18:31:44.000'); | ||
const DSL_QUERY = JSON.stringify({ match_all: {} }); | ||
const COMMON_HEADERS = { | ||
'kbn-xsrf': 'some-xsrf-token', | ||
}; | ||
|
@@ -150,7 +151,7 @@ export default ({ getService }: FtrProviderContext) => { | |
.get( | ||
`/api/lens/existing_fields/${encodeURIComponent( | ||
'logstash-*' | ||
)}?fromDate=${TEST_START_TIME}&toDate=${TEST_END_TIME}` | ||
)}?fromDate=${TEST_START_TIME}&toDate=${TEST_END_TIME}&dslQuery=${DSL_QUERY}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: dslQuery is now required, but could we provide a default |
||
) | ||
.set(COMMON_HEADERS) | ||
.expect(200); | ||
|
@@ -164,7 +165,7 @@ export default ({ getService }: FtrProviderContext) => { | |
.get( | ||
`/api/lens/existing_fields/${encodeURIComponent( | ||
'metricbeat-*' | ||
)}?fromDate=${TEST_START_TIME}&toDate=${TEST_END_TIME}` | ||
)}?fromDate=${TEST_START_TIME}&toDate=${TEST_END_TIME}&dslQuery=${DSL_QUERY}` | ||
) | ||
.set(COMMON_HEADERS) | ||
.expect(200); | ||
|
@@ -173,13 +174,54 @@ export default ({ getService }: FtrProviderContext) => { | |
expect(body.existingFieldNames.sort()).to.eql(metricBeatData.sort()); | ||
}); | ||
|
||
it('should throw a 404 for a non-existent index', async () => { | ||
await supertest | ||
it('should return fields filtered by query and filters', async () => { | ||
const expectedFieldNames = [ | ||
'@message', | ||
'@message.raw', | ||
'@tags', | ||
'@tags.raw', | ||
'@timestamp', | ||
'agent', | ||
'agent.raw', | ||
'bytes', | ||
'clientip', | ||
'extension', | ||
'extension.raw', | ||
'headings', | ||
'headings.raw', | ||
'host', | ||
'host.raw', | ||
'index', | ||
'index.raw', | ||
'referer', | ||
'request', | ||
'request.raw', | ||
'response', | ||
'response.raw', | ||
'spaces', | ||
'spaces.raw', | ||
'type', | ||
'url', | ||
'url.raw', | ||
'utc_time', | ||
'xss', | ||
'xss.raw', | ||
]; | ||
|
||
const dslQueryFiltered = JSON.stringify({ | ||
bool: { | ||
filter: [{ match: { referer: 'https://www.taylorswift.com/' } }], | ||
}, | ||
}); | ||
const { body } = await supertest | ||
.get( | ||
`/api/lens/existing_fields/nadachance?fromDate=${TEST_START_TIME}&toDate=${TEST_END_TIME}` | ||
`/api/lens/existing_fields/${encodeURIComponent( | ||
'logstash-*' | ||
)}?fromDate=${TEST_START_TIME}&toDate=${TEST_END_TIME}&dslQuery=${dslQueryFiltered}` | ||
) | ||
.set(COMMON_HEADERS) | ||
.expect(404); | ||
.expect(200); | ||
expect(body.existingFieldNames.sort()).to.eql(expectedFieldNames.sort()); | ||
}); | ||
}); | ||
}); | ||
|
Binary file modified
BIN
+346 KB
(100%)
x-pack/test/functional/es_archives/logstash_functional/data.json.gz
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: You've chosen to keep this as a GET request, so the query is passed as a string. Would it make sense to turn this into a POST request with a query body?