Skip to content
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] edit pipeline #7193

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,10 @@ import './source_data';
import './processor_ui_container';
import '../processors';
import pipelineSetupTemplate from '../views/pipeline_setup.html';
import buildProcessorTypeArray from '../lib/build_processor_type_array';

const app = uiModules.get('kibana');

function buildProcessorTypeList(enabledProcessorTypeIds) {
return _(ProcessorTypes)
.map(Type => {
const instance = new Type();
return {
typeId: instance.typeId,
title: instance.title,
Type
};
})
.compact()
.filter((processorType) => enabledProcessorTypeIds.includes(processorType.typeId))
.sortBy('title')
.value();
}

app.directive('pipelineSetup', function () {
return {
restrict: 'E',
Expand All @@ -45,7 +30,10 @@ app.directive('pipelineSetup', function () {
//determines which processors are available on the cluster
ingest.getProcessors()
.then((enabledProcessorTypeIds) => {
$scope.processorTypes = buildProcessorTypeList(enabledProcessorTypeIds);
$scope.processorTypes = _(buildProcessorTypeArray(ProcessorTypes))
.filter((processorType) => enabledProcessorTypeIds.includes(processorType.typeId))
.sortBy('title')
.value();
})
.catch(notify.error);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import _ from 'lodash';

export default function buildProcessorTypeArray(Types) {
return _(Types)
.map(Type => {
const instance = new Type();
return {
typeId: instance.typeId,
title: instance.title,
Type
};
})
.compact()
.value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,19 @@ export default class Pipeline {
processors[index] = temp;
}

addExisting(existingProcessor) {
const Type = existingProcessor.constructor;
const newProcessor = this.add(Type);
_.assign(newProcessor, _.omit(existingProcessor, 'processorId'));
addExisting(oldProcessor) {
const Type = oldProcessor.constructor;
const newProcessor = this.add(Type, oldProcessor);

return newProcessor;
}

add(ProcessorType) {
add(ProcessorType, oldProcessor) {
const processors = this.processors;

this.processorCounter += 1;
const processorId = `processor_${this.processorCounter}`;
const newProcessor = new ProcessorType(processorId);
const newProcessor = new ProcessorType(processorId, oldProcessor);
processors.push(newProcessor);

return newProcessor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Append extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'append', 'Append');
this.targetField = '';
this.values = [];
_.assign(this,
{
targetField: '',
values: []
},
_.pick(oldProcessor, ['targetField', 'values']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import _ from 'lodash';
import Processor from '../base/view_model';

export class Convert extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'convert', 'Convert');
this.sourceField = '';
this.targetField = '';
this.type = 'auto';
_.assign(this,
{
sourceField: '',
targetField: '',
type: 'auto'
},
_.pick(oldProcessor, ['sourceField', 'targetField', 'type']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Date extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'date', 'Date');
this.sourceField = '';
this.targetField = '@timestamp';
this.formats = [];
this.timezone = 'Etc/UTC';
this.locale = 'ENGLISH';
this.customFormat = '';
_.assign(this,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but it might make intentions more clear if you use _.defaults here instead of _.assign since you're basically setting defaults.

{
sourceField: '',
targetField: '@timestamp',
formats: [],
timezone: 'Etc/UTC',
locale: 'ENGLISH',
customFormat: ''
},
_.pick(oldProcessor, ['sourceField', 'targetField', 'formats', 'timezone', 'locale', 'customFormat']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class GeoIp extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'geoip', 'Geo IP');
this.sourceField = '';
this.targetField = '';
this.databaseFile = '';
this.databaseFields = [];
_.assign(this,
{
sourceField: '',
targetField: '',
databaseFile: '',
databaseFields: []
},
_.pick(oldProcessor, ['sourceField', 'targetField', 'databaseFile', 'databaseFields']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import keysDeep from '../../lib/keys_deep';
import Processor from '../base/view_model';

export class Grok extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'grok', 'Grok');
this.sourceField = '';
this.pattern = '';
_.assign(this,
{
sourceField: '',
pattern: ''
},
_.pick(oldProcessor, ['sourceField', 'pattern']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Gsub extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'gsub', 'Gsub');
this.sourceField = '';
this.pattern = '';
this.replacement = '';
_.assign(this,
{
sourceField: '',
pattern: '',
replacement: ''
},
_.pick(oldProcessor, ['sourceField', 'pattern', 'replacement']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Join extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'join', 'Join');
this.sourceField = '';
this.separator = '';
_.assign(this,
{
sourceField: '',
separator: ''
},
_.pick(oldProcessor, ['sourceField', 'separator']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Lowercase extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'lowercase', 'Lowercase');
this.sourceField = '';
_.assign(this,
{
sourceField: ''
},
_.pick(oldProcessor, ['sourceField']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Remove extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'remove', 'Remove');
this.sourceField = '';
_.assign(this,
{
sourceField: ''
},
_.pick(oldProcessor, ['sourceField']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Rename extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'rename', 'Rename');
this.sourceField = '';
this.targetField = '';
_.assign(this,
{
sourceField: '',
targetField: ''
},
_.pick(oldProcessor, ['sourceField', 'targetField']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import Processor from '../base/view_model';
import _ from 'lodash';

export class Set extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'set', 'Set');
this.targetField = '';
this.value = '';
_.assign(this,
{
targetField: '',
value: ''
},
_.pick(oldProcessor, ['targetField', 'value']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Split extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'split', 'Split');
this.sourceField = '';
this.separator = '';
_.assign(this,
{
sourceField: '',
separator: ''
},
_.pick(oldProcessor, ['sourceField', 'separator']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Trim extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'trim', 'Trim');
this.sourceField = '';
_.assign(this,
{
sourceField: ''
},
_.pick(oldProcessor, ['sourceField']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import _ from 'lodash';
import Processor from '../base/view_model';

export class Uppercase extends Processor {
constructor(processorId) {
constructor(processorId, oldProcessor) {
super(processorId, 'uppercase', 'Uppercase');
this.sourceField = '';
_.assign(this,
{
sourceField: ''
},
_.pick(oldProcessor, ['sourceField']));
}

get description() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h2><em>New or Existing?</em>
Do you want to create a new pipeline, or edit an existing pipline?
</h2>

<select
class="form-control"
ng-options="pipeline as pipeline for pipeline in selectPipeline.pipelines"
ng-model="selectPipeline.pipelineName">
<option value="">Create a new pipeline</option>
</select>
Loading