mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
This commit is contained in:
parent
0497683713
commit
ee95832a20
2 changed files with 20 additions and 8 deletions
|
@ -113,7 +113,8 @@ describe('ML - job utils', () => {
|
|||
{ 'function': 'sum', 'field_name': 'bytes', 'partition_field_name': 'clientip', 'detector_description': 'High bytes client IP' }, // eslint-disable-line max-len
|
||||
{ 'function': 'freq_rare', 'by_field_name': 'uri', 'over_field_name': 'clientip', 'detector_description': 'Freq rare URI' },
|
||||
{ 'function': 'count', 'by_field_name': 'mlcategory', 'detector_description': 'Count by category' },
|
||||
{ 'function': 'count', 'by_field_name': 'hrd', 'detector_description': 'count by hrd' }
|
||||
{ 'function': 'count', 'by_field_name': 'hrd', 'detector_description': 'count by hrd' },
|
||||
{ 'function': 'mean', 'field_name': 'NetworkDiff', 'detector_description': 'avg NetworkDiff' }
|
||||
]
|
||||
},
|
||||
datafeed_config: {
|
||||
|
@ -123,6 +124,12 @@ describe('ML - job utils', () => {
|
|||
'inline': 'return domainSplit(doc["query"].value, params).get(1);',
|
||||
'lang': 'painless'
|
||||
}
|
||||
},
|
||||
'NetworkDiff': {
|
||||
'script': {
|
||||
'source': 'doc["NetworkOut"].value - doc["NetworkIn"].value',
|
||||
'lang': 'painless'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,10 +147,14 @@ describe('ML - job utils', () => {
|
|||
expect(isTimeSeriesViewDetector(job, 2)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns false for a detector using count on a scripted field', () => {
|
||||
it('returns false for a detector using a script field as a by field', () => {
|
||||
expect(isTimeSeriesViewDetector(job, 3)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns false for a detector using a script field as a metric field_name', () => {
|
||||
expect(isTimeSeriesViewDetector(job, 4)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('isTimeSeriesViewFunction', () => {
|
||||
|
|
|
@ -67,13 +67,14 @@ export function isTimeSeriesViewDetector(job, dtrIndex) {
|
|||
(dtr.partition_field_name !== 'mlcategory') &&
|
||||
(dtr.over_field_name !== 'mlcategory');
|
||||
|
||||
const usesScriptedFields = _.has(job, 'datafeed_config.script_fields');
|
||||
const scriptedFields = usesScriptedFields ? _.keys(job.datafeed_config.script_fields) : [];
|
||||
if (isDetectorViewable === true && usesScriptedFields === true) {
|
||||
const usesScriptFields = _.has(job, 'datafeed_config.script_fields');
|
||||
if (isDetectorViewable === true && usesScriptFields === true) {
|
||||
// Perform extra check to see if the detector is using a scripted field.
|
||||
isDetectorViewable = (dtr.partition_field_name === undefined || scriptedFields.indexOf(dtr.partition_field_name) === -1) &&
|
||||
(dtr.by_field_name === undefined || scriptedFields.indexOf(dtr.by_field_name) === -1) &&
|
||||
(dtr.over_field_name === undefined || scriptedFields.indexOf(dtr.over_field_name) === -1);
|
||||
const scriptFields = usesScriptFields ? _.keys(job.datafeed_config.script_fields) : [];
|
||||
isDetectorViewable = scriptFields.indexOf(dtr.field_name) === -1 &&
|
||||
scriptFields.indexOf(dtr.partition_field_name) === -1 &&
|
||||
scriptFields.indexOf(dtr.by_field_name) === -1 &&
|
||||
scriptFields.indexOf(dtr.over_field_name) === -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue