Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into fix/siem-time…
Browse files Browse the repository at this point in the history
…line-drag-and-drop
  • Loading branch information
patrykkopycinski committed Nov 25, 2019
2 parents 03cab12 + 8282450 commit 6ca281f
Show file tree
Hide file tree
Showing 32 changed files with 1,432 additions and 1,160 deletions.
4 changes: 4 additions & 0 deletions x-pack/legacy/plugins/ml/common/util/job_utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { Job } from '../../public/application/jobs/new_job/common/job_creator/configs';

export interface ValidationMessage {
id: string;
}
Expand Down Expand Up @@ -39,3 +41,5 @@ export function validateModelMemoryLimitUnits(
export function processCreatedBy(customSettings: { created_by?: string }): void;

export function mlFunctionToESAggregation(functionName: string): string | null;

export function isModelPlotEnabled(job: Job, detectorIndex: number, entityFields: any[]): boolean;
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const AnnotationsTable = injectI18n(class AnnotationsTable extends Component {
earliestMs: null,
latestMs: null,
maxAnnotations: ANNOTATIONS_TABLE_DEFAULT_QUERY_SIZE
}).then((resp) => {
}).toPromise().then((resp) => {
this.setState((prevState, props) => ({
annotations: resp.annotations[props.jobs[0].job_id] || [],
errorMessage: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ jest.mock('../../../services/job_service', () => ({
}
}));

jest.mock('../../../services/ml_api_service', () => ({
ml: {
annotations: {
getAnnotations: jest.fn().mockResolvedValue({ annotations: [] })
jest.mock('../../../services/ml_api_service', () => {
const { of } = require('rxjs');
const mockAnnotations$ = of({ annotations: [] });
return {
ml: {
annotations: {
getAnnotations: jest.fn().mockReturnValue(mockAnnotations$)
}
}
}
}));
};}
);

describe('AnnotationsTable', () => {
test('Minimal initialization without props.', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function explorerChartsContainerServiceFactory(callback) {
range.min,
range.max,
config.interval
);
).toPromise();
} else {
// Extract the partition, by, over fields on which to filter.
const criteriaFields = [];
Expand Down Expand Up @@ -169,7 +169,7 @@ export function explorerChartsContainerServiceFactory(callback) {
range.min,
range.max,
interval
)
).toPromise()
.then((resp) => {
// Return data in format required by the explorer charts.
const results = resp.results;
Expand Down Expand Up @@ -201,7 +201,7 @@ export function explorerChartsContainerServiceFactory(callback) {
range.min,
range.max,
ANOMALIES_MAX_RESULTS
);
).toPromise();
}

// Query 3 - load any scheduled events for the job.
Expand All @@ -213,7 +213,7 @@ export function explorerChartsContainerServiceFactory(callback) {
config.interval,
1,
MAX_SCHEDULED_EVENTS
);
).toPromise();
}

// Query 4 - load context data distribution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,39 @@ jest.mock('../../services/job_service', () => ({
}
}));

jest.mock('../../services/results_service', () => ({
mlResultsService: {
getMetricData(indices) {
jest.mock('../../services/results_service', () => {
const { of } = require('rxjs');
return {
mlResultsService: {
getMetricData(indices) {
// this is for 'call anomalyChangeListener with actual series config'
if (indices[0] === 'farequote-2017') {
return Promise.resolve(mockSeriesPromisesResponse[0][0]);
}
// this is for 'filtering should skip values of null'
return Promise.resolve(mockMetricClone);
},
getRecordsForCriteria() {
return Promise.resolve(mockSeriesPromisesResponse[0][1]);
},
getScheduledEventsByBucket() {
return Promise.resolve(mockSeriesPromisesResponse[0][2]);
},
getEventDistributionData(indices) {
if (indices[0] === 'farequote-2017') {
return of(mockSeriesPromisesResponse[0][0]);
}
// this is for 'filtering should skip values of null'
return of(mockMetricClone);
},
getRecordsForCriteria() {
return of(mockSeriesPromisesResponse[0][1]);
},
getScheduledEventsByBucket() {
return of(mockSeriesPromisesResponse[0][2]);
},
getEventDistributionData(indices) {
// this is for 'call anomalyChangeListener with actual series config'
if (indices[0] === 'farequote-2017') {
return Promise.resolve([]);
if (indices[0] === 'farequote-2017') {
return Promise.resolve([]);
}
// this is for 'filtering should skip values of null' and
// resolves with a dummy object to trigger the processing
// of the event distribution chartdata filtering
return Promise.resolve([{
entity: 'mock'
}]);
}
// this is for 'filtering should skip values of null' and
// resolves with a dummy object to trigger the processing
// of the event distribution chartdata filtering
return Promise.resolve([{
entity: 'mock'
}]);
}
}
}));
};
});

jest.mock('../../util/string_utils', () => ({
mlEscape(d) { return d; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export function loadAnnotationsTableData(selectedCells, selectedJobs, interval,
earliestMs: timeRange.earliestMs,
latestMs: timeRange.latestMs,
maxAnnotations: ANNOTATIONS_TABLE_DEFAULT_QUERY_SIZE
}).then((resp) => {
}).toPromise().then((resp) => {
if (resp.error !== undefined || resp.annotations === undefined) {
return resolve([]);
}
Expand Down Expand Up @@ -477,7 +477,7 @@ export async function loadAnomaliesTableData(
ANOMALIES_TABLE_DEFAULT_QUERY_SIZE,
MAX_CATEGORY_EXAMPLES,
influencersFilterQuery
).then((resp) => {
).toPromise().then((resp) => {
const anomalies = resp.anomalies;
const detectorsByJob = mlJobService.detectorsByJob;
anomalies.forEach((anomaly) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,17 @@ export class ResultsLoader {
if (agg === null) {
return { [dtrIndex]: [emptyModelItem] };
}
const resp = await mlResultsService.getModelPlotOutput(
this._jobCreator.jobId,
dtrIndex,
[],
this._lastModelTimeStamp,
this._jobCreator.end,
`${this._chartInterval.getInterval().asMilliseconds()}ms`,
agg.mlModelPlotAgg
);
const resp = await mlResultsService
.getModelPlotOutput(
this._jobCreator.jobId,
dtrIndex,
[],
this._lastModelTimeStamp,
this._jobCreator.end,
`${this._chartInterval.getInterval().asMilliseconds()}ms`,
agg.mlModelPlotAgg
)
.toPromise();

return this._createModel(resp, dtrIndex);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { Observable } from 'rxjs';
import { Job } from '../jobs/new_job/common/job_creator/configs';

export interface ForecastData {
success: boolean;
results: any;
}

export const mlForecastService: {
getForecastData: (
job: Job,
detectorIndex: number,
forecastId: string,
entityFields: any[],
earliestMs: number,
latestMs: number,
interval: string,
aggType: any
) => Observable<ForecastData>;
};
Loading

0 comments on commit 6ca281f

Please sign in to comment.