Skip to content
Merged
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
38 changes: 2 additions & 36 deletions x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,14 @@
* 2.0.
*/

import type { estypes } from '@elastic/elasticsearch';
// import { IndexPatternTitle } from '../kibana';
// import { RuntimeMappings } from '../fields';
// import { JobId } from './job';
import { estypes } from '@elastic/elasticsearch';

export type DatafeedId = string;

export type Datafeed = estypes.Datafeed;
// export interface Datafeed extends estypes.DatafeedConfig {
// runtime_mappings?: RuntimeMappings;
// aggs?: Aggregation;
// }
// export interface Datafeed {
// datafeed_id: DatafeedId;
// aggregations?: Aggregation;
// aggs?: Aggregation;
// chunking_config?: ChunkingConfig;
// frequency?: string;
// indices: IndexPatternTitle[];
// indexes?: IndexPatternTitle[]; // The datafeed can contain indexes and indices
// job_id: JobId;
// query: object;
// query_delay?: string;
// script_fields?: Record<string, any>;
// runtime_mappings?: RuntimeMappings;
// scroll_size?: number;
// delayed_data_check_config?: object;
// indices_options?: IndicesOptions;
// }

export type ChunkingConfig = estypes.ChunkingConfig;

// export interface ChunkingConfig {
// mode: 'auto' | 'manual' | 'off';
// time_span?: string;
// }

export type Aggregation = Record<string, estypes.AggregationContainer>;

export type IndicesOptions = estypes.IndicesOptions;
// export interface IndicesOptions {
// expand_wildcards?: 'all' | 'open' | 'closed' | 'hidden' | 'none';
// ignore_unavailable?: boolean;
// allow_no_indices?: boolean;
// ignore_throttled?: boolean;
// }
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,6 @@
* 2.0.
*/

import { Node } from './job_stats';
import { DATAFEED_STATE } from '../../constants/states';
import { estypes } from '@elastic/elasticsearch';

export interface DatafeedStats {
datafeed_id: string;
state: DATAFEED_STATE;
node: Node;
assignment_explanation: string;
timing_stats: TimingStats;
}

interface TimingStats {
job_id: string;
search_count: number;
bucket_count: number;
total_search_time_ms: number;
average_search_time_per_bucket_ms: number;
exponential_average_search_time_per_hour_ms: number;
}
export type DatafeedStats = estypes.DatafeedStats;
80 changes: 2 additions & 78 deletions x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,103 +6,27 @@
*/

import { estypes } from '@elastic/elasticsearch';
import { UrlConfig } from '../custom_urls';
import { CREATED_BY_LABEL } from '../../constants/new_job';

export type JobId = string;
export type BucketSpan = string;

export interface CustomSettings {
custom_urls?: UrlConfig[];
created_by?: CREATED_BY_LABEL;
job_tags?: {
[tag: string]: string;
};
}

export type Job = estypes.Job;
// export interface Job {
// job_id: JobId;
// analysis_config: AnalysisConfig;
// analysis_limits?: AnalysisLimits;
// background_persist_interval?: string;
// custom_settings?: CustomSettings;
// data_description: DataDescription;
// description: string;
// groups: string[];
// model_plot_config?: ModelPlotConfig;
// model_snapshot_retention_days?: number;
// daily_model_snapshot_retention_after_days?: number;
// renormalization_window_days?: number;
// results_index_name?: string;
// results_retention_days?: number;

// // optional properties added when the job has been created
// create_time?: number;
// finished_time?: number;
// job_type?: 'anomaly_detector';
// job_version?: string;
// model_snapshot_id?: string;
// deleting?: boolean;
// }

export type AnalysisConfig = estypes.AnalysisConfig;
// export interface AnalysisConfig {
// bucket_span: BucketSpan;
// categorization_field_name?: string;
// categorization_filters?: string[];
// categorization_analyzer?: object | string;
// detectors: Detector[];
// influencers: string[];
// latency?: number;
// multivariate_by_fields?: boolean;
// summary_count_field_name?: string;
// per_partition_categorization?: PerPartitionCategorization;
// }

export type Detector = estypes.Detector;
// export interface Detector {
// by_field_name?: string;
// detector_description?: string;
// detector_index?: number;
// exclude_frequent?: string;
// field_name?: string;
// function: string;
// over_field_name?: string;
// partition_field_name?: string;
// use_null?: boolean;
// custom_rules?: CustomRule[];
// }

export type AnalysisLimits = estypes.AnalysisLimits;
// export interface AnalysisLimits {
// categorization_examples_limit?: number;
// model_memory_limit: string;
// }

export type DataDescription = estypes.DataDescription;
// export interface DataDescription {
// format?: string;
// time_field: string;
// time_format?: string;
// }

export type ModelPlotConfig = estypes.ModelPlotConfig;
// export interface ModelPlotConfig {
// enabled?: boolean;
// annotations_enabled?: boolean;
// terms?: string;
// }

export type CustomRule = estypes.DetectionRule;
// TODO, finish this when it's needed
// export interface CustomRule {
// actions: string[];
// scope?: object;
// conditions: any[];
// }

export interface PerPartitionCategorization {
enabled?: boolean;
stop_on_warn?: boolean;
}

export type CustomSettings = estypes.CustomSettings;
90 changes: 11 additions & 79 deletions x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,25 @@
* 2.0.
*/

import { JOB_STATE } from '../../constants/states';
import { estypes } from '@elastic/elasticsearch';

export interface JobStats {
job_id: string;
data_counts: DataCounts;
export type JobStats = estypes.JobStats & {
model_size_stats: ModelSizeStats;
forecasts_stats: ForecastsStats;
state: JOB_STATE;
node: Node;
assignment_explanation: string;
open_time: string;
timing_stats: TimingStats;
}
};

export interface DataCounts {
job_id: string;
processed_record_count: number;
processed_field_count: number;
input_bytes: number;
input_field_count: number;
invalid_date_count: number;
missing_field_count: number;
out_of_order_timestamp_count: number;
empty_bucket_count: number;
sparse_bucket_count: number;
bucket_count: number;
earliest_record_timestamp: number;
latest_record_timestamp: number;
last_data_time: number;
input_record_count: number;
latest_empty_bucket_timestamp: number;
latest_sparse_bucket_timestamp: number;
latest_bucket_timestamp?: number; // stat added by the UI
}
export type DataCounts = estypes.DataCounts;

export interface ModelSizeStats {
job_id: string;
result_type: string;
model_bytes: number;
export type ModelSizeStats = estypes.ModelSizeStats & {
model_bytes_exceeded: number;
model_bytes_memory_limit: number;
peak_model_bytes?: number;
total_by_field_count: number;
total_over_field_count: number;
total_partition_field_count: number;
bucket_allocation_failures_count: number;
memory_status: 'ok' | 'soft_limit' | 'hard_limit';
categorized_doc_count: number;
total_category_count: number;
frequent_category_count: number;
rare_category_count: number;
dead_category_count: number;
categorization_status: 'ok' | 'warn';
log_time: number;
timestamp: number;
}
};

export interface ForecastsStats {
total: number;
forecasted_jobs: number;
memory_bytes?: any;
records?: any;
processing_time_ms?: any;
status?: any;
}
export type TimingStats = estypes.TimingStats & {
total_bucket_processing_time_ms: number;
};

export interface Node {
id: string;
name: string;
ephemeral_id: string;
transport_address: string;
attributes: {
'transform.remote_connect'?: boolean;
'ml.machine_memory'?: number;
'xpack.installed'?: boolean;
'transform.node'?: boolean;
'ml.max_open_jobs'?: number;
};
}
export type ForecastsStats = estypes.JobForecastStatistics;

interface TimingStats {
job_id: string;
bucket_count: number;
total_bucket_processing_time_ms: number;
minimum_bucket_processing_time_ms: number;
maximum_bucket_processing_time_ms: number;
average_bucket_processing_time_ms: number;
exponential_average_bucket_processing_time_ms: number;
exponential_average_bucket_processing_time_per_hour_ms: number;
}
export type Node = estypes.DiscoveryNode;
4 changes: 2 additions & 2 deletions x-pack/plugins/ml/common/util/job_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { each, isEmpty, isEqual, pick } from 'lodash';
import semverGte from 'semver/functions/gte';
import moment, { Duration } from 'moment';
import type { estypes } from '@elastic/elasticsearch';
import { estypes } from '@elastic/elasticsearch';
// @ts-ignore
import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -819,7 +819,7 @@ export function getLatestDataOrBucketTimestamp(
* in the job wizards and so would be lost in a clone.
*/
export function processCreatedBy(customSettings: CustomSettings) {
if (Object.values(CREATED_BY_LABEL).includes(customSettings.created_by!)) {
if (Object.values(CREATED_BY_LABEL).includes(customSettings.created_by as CREATED_BY_LABEL)) {
delete customSettings.created_by;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import moment from 'moment-timezone';
import { estypes } from '@elastic/elasticsearch';
import { useEffect, useMemo } from 'react';

import {
Expand All @@ -18,7 +19,6 @@ import { i18n } from '@kbn/i18n';

import { CoreSetup } from 'src/core/public';

import type { estypes } from '@elastic/elasticsearch';
import {
IndexPattern,
IFieldType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import { FindFileStructureResponse } from '../../../../../../../file_upload/comm
interface Props {
mappingsString: string;
pipelineString: string;
onMappingsStringChange(): void;
onPipelineStringChange(): void;
onMappingsStringChange(mappings: string): void;
onPipelineStringChange(pipeline: string): void;
combinedFields: CombinedField[];
onCombinedFieldsChange(combinedFields: CombinedField[]): void;
results: FindFileStructureResponse;
Expand Down Expand Up @@ -72,11 +72,9 @@ export class CombinedFieldsForm extends Component<Props, State> {
const pipeline = this.parsePipeline();

this.props.onMappingsStringChange(
// @ts-expect-error
JSON.stringify(addCombinedFieldsToMappings(mappings, [combinedField]), null, 2)
);
this.props.onPipelineStringChange(
// @ts-expect-error
JSON.stringify(addCombinedFieldsToPipeline(pipeline, [combinedField]), null, 2)
);
this.props.onCombinedFieldsChange([...this.props.combinedFields, combinedField]);
Expand All @@ -99,11 +97,9 @@ export class CombinedFieldsForm extends Component<Props, State> {
const removedCombinedFields = updatedCombinedFields.splice(index, 1);

this.props.onMappingsStringChange(
// @ts-expect-error
JSON.stringify(removeCombinedFieldsFromMappings(mappings, removedCombinedFields), null, 2)
);
this.props.onPipelineStringChange(
// @ts-expect-error
JSON.stringify(removeCombinedFieldsFromPipeline(pipeline, removedCombinedFields), null, 2)
);
this.props.onCombinedFieldsChange(updatedCombinedFields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ interface Props {
mappingsString: string;
pipelineString: string;
onIndexSettingsStringChange(): void;
onMappingsStringChange(): void;
onPipelineStringChange(): void;
onMappingsStringChange(mappings: string): void;
onPipelineStringChange(pipeline: string): void;
indexNameError: string;
indexPatternNameError: string;
combinedFields: CombinedField[];
Expand Down Expand Up @@ -175,7 +175,7 @@ export const AdvancedSettings: FC<Props> = ({
interface JsonEditorProps {
initialized: boolean;
data: string;
onChange(): void;
onChange(value: string): void;
}

const IndexSettings: FC<JsonEditorProps> = ({ initialized, data, onChange }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ interface Props {
mappingsString: string;
pipelineString: string;
onIndexSettingsStringChange(): void;
onMappingsStringChange(): void;
onPipelineStringChange(): void;
onMappingsStringChange(mappings: string): void;
onPipelineStringChange(pipeline: string): void;
indexNameError: string;
indexPatternNameError: string;
combinedFields: CombinedField[];
Expand Down
Loading