mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
parent
27b5cc7136
commit
1087d8b473
2 changed files with 18 additions and 13 deletions
|
@ -77,14 +77,17 @@ export class MachineLearningFlyout extends Component<FlyoutProps, FlyoutState> {
|
|||
this.setState({ isLoading: true });
|
||||
try {
|
||||
const { serviceName, transactionType } = this.props.urlParams;
|
||||
if (serviceName) {
|
||||
const res = await startMLJob({ serviceName, transactionType });
|
||||
const didSucceed = res.datafeeds[0].success && res.jobs[0].success;
|
||||
if (!didSucceed) {
|
||||
throw new Error('Creating ML job failed');
|
||||
}
|
||||
this.addSuccessToast();
|
||||
if (!serviceName || !transactionType) {
|
||||
throw new Error(
|
||||
'Service name and transaction type are required to create this ML job'
|
||||
);
|
||||
}
|
||||
const res = await startMLJob({ serviceName, transactionType });
|
||||
const didSucceed = res.datafeeds[0].success && res.jobs[0].success;
|
||||
if (!didSucceed) {
|
||||
throw new Error('Creating ML job failed');
|
||||
}
|
||||
this.addSuccessToast();
|
||||
} catch (e) {
|
||||
this.addErrorToast();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { ESFilter } from 'elasticsearch';
|
||||
import chrome from 'ui/chrome';
|
||||
import {
|
||||
PROCESSOR_EVENT,
|
||||
SERVICE_NAME,
|
||||
TRANSACTION_TYPE
|
||||
} from '../../../common/elasticsearch_fieldnames';
|
||||
|
@ -40,15 +41,16 @@ export async function startMLJob({
|
|||
transactionType
|
||||
}: {
|
||||
serviceName: string;
|
||||
transactionType?: string;
|
||||
transactionType: string;
|
||||
}) {
|
||||
const indexPatternName = chrome.getInjected('apmIndexPatternTitle');
|
||||
const groups = ['apm', serviceName.toLowerCase()];
|
||||
const filter: ESFilter[] = [{ term: { [SERVICE_NAME]: serviceName } }];
|
||||
if (transactionType) {
|
||||
groups.push(transactionType.toLowerCase());
|
||||
filter.push({ term: { [TRANSACTION_TYPE]: transactionType } });
|
||||
}
|
||||
const filter: ESFilter[] = [
|
||||
{ term: { [SERVICE_NAME]: serviceName } },
|
||||
{ term: { [PROCESSOR_EVENT]: 'transaction' } },
|
||||
{ term: { [TRANSACTION_TYPE]: transactionType } }
|
||||
];
|
||||
groups.push(transactionType.toLowerCase());
|
||||
return callApi<StartedMLJobApiResponse>({
|
||||
method: 'POST',
|
||||
pathname: `/api/ml/modules/setup/apm_transaction`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue