Skip to content

Commit

Permalink
Only show anomalies with a score greater than 50
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipb committed Sep 29, 2020
1 parent ecee577 commit b7a9f8c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,6 @@ async function fetchMetricsHostsAnomalies(

const finalizeFetchLogEntryAnomaliesSpan = startTracingSpan('fetch metrics hosts anomalies');

// console.log(
// 'data',
// JSON.stringify(
// await mlSystem.mlAnomalySearch(
// createMetricsHostsAnomaliesQuery(jobIds, startTime, endTime, sort, expandedPagination)
// ),
// null,
// 2
// )
// );
const results = decodeOrThrow(metricsHostsAnomaliesResponseRT)(
await mlSystem.mlAnomalySearch(
createMetricsHostsAnomaliesQuery(jobIds, startTime, endTime, sort, expandedPagination)
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ export const createTimeRangeFilters = (startTime: number, endTime: number) => [
},
];

export const createAnomalyScoreFilter = (minScore: number) => [
{
range: {
record_score: {
gte: minScore,
},
},
},
];

export const createResultTypeFilters = (resultTypes: Array<'model_plot' | 'record'>) => [
{
terms: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
createTimeRangeFilters,
createResultTypeFilters,
defaultRequestParameters,
createAnomalyScoreFilter,
} from './common';
import { Sort, Pagination } from '../../../../common/http_api/infra_ml';

Expand All @@ -35,6 +36,7 @@ export const createMetricsHostsAnomaliesQuery = (

const filters = [
...createJobIdsFilters(jobIds),
...createAnomalyScoreFilter(50),
...createTimeRangeFilters(startTime, endTime),
...createResultTypeFilters(['record']),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
createTimeRangeFilters,
createResultTypeFilters,
defaultRequestParameters,
createAnomalyScoreFilter,
} from './common';
import { Sort, Pagination } from '../../../../common/http_api/infra_ml';

Expand All @@ -35,6 +36,7 @@ export const createMetricsK8sAnomaliesQuery = (

const filters = [
...createJobIdsFilters(jobIds),
...createAnomalyScoreFilter(50),
...createTimeRangeFilters(startTime, endTime),
...createResultTypeFilters(['record']),
];
Expand Down

0 comments on commit b7a9f8c

Please sign in to comment.