-
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
[add data] ability to disable processors #7065
Merged
BigFunger
merged 4 commits into
elastic:feature/ingest
from
BigFunger:add-data-disable-processors
Apr 27, 2016
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a9048e7
[add data] hides disabled processors
BigFunger b2f30f9
Merge branch 'feature/ingest' into add-data-disable-processors
BigFunger 93ea5ed
[add data] added error handling when getting processors, and fixed co…
BigFunger f0e99c3
[add data] added tests for ingest.getProcessors
BigFunger 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
90 changes: 90 additions & 0 deletions
90
src/plugins/kibana/server/lib/__tests__/process_es_ingest_processors_response.js
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,90 @@ | ||
import processESIngestProcessorsResponse from '../process_es_ingest_processors_response'; | ||
import expect from 'expect.js'; | ||
import _ from 'lodash'; | ||
|
||
describe('processESIngestSimulateResponse', function () { | ||
|
||
it('should return a list of strings indicating the enabled processors', function () { | ||
const response = { | ||
nodes: { | ||
node_foo: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_foo' }, | ||
{ type: 'proc_bar' } | ||
] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const expected = [ 'proc_foo', 'proc_bar' ]; | ||
const actual = processESIngestProcessorsResponse(response); | ||
|
||
expect(_.isEqual(actual, expected)).to.be.ok(); | ||
}); | ||
|
||
it('should return a unique list of processors', function () { | ||
const response = { | ||
nodes: { | ||
node_foo: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_foo' }, | ||
{ type: 'proc_bar' } | ||
] | ||
} | ||
}, | ||
node_bar: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_foo' }, | ||
{ type: 'proc_bar' } | ||
] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const expected = [ 'proc_foo', 'proc_bar' ]; | ||
const actual = processESIngestProcessorsResponse(response); | ||
|
||
expect(_.isEqual(actual, expected)).to.be.ok(); | ||
}); | ||
|
||
it('should combine the available processors from all nodes', function () { | ||
const response = { | ||
nodes: { | ||
node_foo: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_foo' } | ||
] | ||
} | ||
}, | ||
node_bar: { | ||
ingest: { | ||
processors: [ | ||
{ type: 'proc_bar' } | ||
] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const expected = [ 'proc_foo', 'proc_bar' ]; | ||
const actual = processESIngestProcessorsResponse(response); | ||
|
||
expect(_.isEqual(actual, expected)).to.be.ok(); | ||
}); | ||
|
||
it('should return an empty array for unexpected response', function () { | ||
expect(_.isEqual(processESIngestProcessorsResponse({ nodes: {}}), [])).to.be.ok(); | ||
expect(_.isEqual(processESIngestProcessorsResponse({}), [])).to.be.ok(); | ||
expect(_.isEqual(processESIngestProcessorsResponse(undefined), [])).to.be.ok(); | ||
expect(_.isEqual(processESIngestProcessorsResponse(null), [])).to.be.ok(); | ||
expect(_.isEqual(processESIngestProcessorsResponse(''), [])).to.be.ok(); | ||
expect(_.isEqual(processESIngestProcessorsResponse(1), [])).to.be.ok(); | ||
}); | ||
|
||
}); |
16 changes: 16 additions & 0 deletions
16
src/plugins/kibana/server/lib/process_es_ingest_processors_response.js
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,16 @@ | ||
const _ = require('lodash'); | ||
|
||
export default function processESIngestProcessorsResponse(response) { | ||
const nodes = _.get(response, 'nodes'); | ||
|
||
const results = _.chain(nodes) | ||
.map('ingest.processors') | ||
.reduce((result, processors) => { | ||
return result.concat(processors); | ||
}) | ||
.map('type') | ||
.unique() | ||
.value(); | ||
|
||
return results; | ||
}; |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { registerPost } from './register_post'; | ||
import { registerDelete } from './register_delete'; | ||
import { registerProcessors } from './register_processors'; | ||
import { registerSimulate } from './register_simulate'; | ||
|
||
export default function (server) { | ||
registerPost(server); | ||
registerDelete(server); | ||
registerProcessors(server); | ||
registerSimulate(server); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/plugins/kibana/server/routes/api/ingest/register_processors.js
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,24 @@ | ||
import _ from 'lodash'; | ||
import handleESError from '../../../lib/handle_es_error'; | ||
import handleResponse from '../../../lib/process_es_ingest_processors_response'; | ||
import { keysToCamelCaseShallow, keysToSnakeCaseShallow } from '../../../../common/lib/case_conversion'; | ||
|
||
export function registerProcessors(server) { | ||
server.route({ | ||
path: '/api/kibana/ingest/processors', | ||
method: 'GET', | ||
handler: function (request, reply) { | ||
const boundCallWithRequest = _.partial(server.plugins.elasticsearch.callWithRequest, request); | ||
|
||
return boundCallWithRequest('transport.request', { | ||
path: '/_nodes/ingest', | ||
method: 'GET' | ||
}) | ||
.then(handleResponse) | ||
.then(reply) | ||
.catch((error) => { | ||
reply(handleESError(error)); | ||
}); | ||
} | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
define(function (require) { | ||
var Promise = require('bluebird'); | ||
var _ = require('intern/dojo/node!lodash'); | ||
var expect = require('intern/dojo/node!expect.js'); | ||
|
||
return function (bdd, scenarioManager, request) { | ||
bdd.describe('processors', () => { | ||
|
||
bdd.it('should return 200 for a successful run', function () { | ||
return request.get('/kibana/ingest/processors') | ||
.expect(200) | ||
.then((response) => { | ||
expect(_.isArray(response.body)).to.be(true); | ||
}); | ||
}); | ||
|
||
}); | ||
}; | ||
}); |
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
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.
We're establishing a bad pattern here with simulate and now this. This url could conflict with the ingest config endpoints (which will eventually support GET) if the user creates an index called
processors
.We either need to come up with different urls for this endpoint and simulate, or we should move the existing ingest API endpoints to something like
/api/kibana/ingest/config/{id}
. What do you think?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.
Per our discussion, I agree that we can resolve this potential conflict by putting those urls under the
config
category.