-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7065 from BigFunger/add-data-disable-processors
[add data] ability to disable processors
- Loading branch information
Showing
9 changed files
with
211 additions
and
5 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
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