-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dataset filtering to the anomalies page
Make dataset fetching a common functionality Add anomaies datasets route Hook up datasets with client side hook and UI Hook up dataset filtering to anomalies API endpoint Hook up dataset filtering with log entry rate endpoint
- Loading branch information
Showing
26 changed files
with
512 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
x-pack/plugins/infra/common/http_api/log_analysis/results/log_entry_anomalies_datasets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
|
||
import { | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
timeRangeRT, | ||
routeTimingMetadataRT, | ||
} from '../../shared'; | ||
|
||
export const LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_DATASETS_PATH = | ||
'/api/infra/log_analysis/results/log_entry_anomalies_datasets'; | ||
|
||
/** | ||
* request | ||
*/ | ||
|
||
export const getLogEntryAnomaliesDatasetsRequestPayloadRT = rt.type({ | ||
data: rt.type({ | ||
// the id of the source configuration | ||
sourceId: rt.string, | ||
// the time range to fetch the anomalies datasets from | ||
timeRange: timeRangeRT, | ||
}), | ||
}); | ||
|
||
export type GetLogEntryAnomaliesDatasetsRequestPayload = rt.TypeOf< | ||
typeof getLogEntryAnomaliesDatasetsRequestPayloadRT | ||
>; | ||
|
||
/** | ||
* response | ||
*/ | ||
|
||
export const getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT = rt.intersection([ | ||
rt.type({ | ||
data: rt.type({ | ||
datasets: rt.array(rt.string), | ||
}), | ||
}), | ||
rt.partial({ | ||
timing: routeTimingMetadataRT, | ||
}), | ||
]); | ||
|
||
export type GetLogEntryAnomaliesDatasetsSuccessResponsePayload = rt.TypeOf< | ||
typeof getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT | ||
>; | ||
|
||
export const getLogEntryAnomaliesDatasetsResponsePayloadRT = rt.union([ | ||
getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT, | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
]); | ||
|
||
export type GetLogEntryAnomaliesDatasetsReponsePayload = rt.TypeOf< | ||
typeof getLogEntryAnomaliesDatasetsResponsePayloadRT | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
.../infra/public/pages/logs/log_entry_rate/service_calls/get_log_entry_anomalies_datasets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 { fold } from 'fp-ts/lib/Either'; | ||
import { pipe } from 'fp-ts/lib/pipeable'; | ||
import { identity } from 'fp-ts/lib/function'; | ||
import { npStart } from '../../../../legacy_singletons'; | ||
|
||
import { | ||
getLogEntryAnomaliesDatasetsRequestPayloadRT, | ||
getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT, | ||
LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_DATASETS_PATH, | ||
} from '../../../../../common/http_api/log_analysis'; | ||
import { createPlainError, throwErrors } from '../../../../../common/runtime_types'; | ||
|
||
export const callGetLogEntryAnomaliesDatasetsAPI = async ( | ||
sourceId: string, | ||
startTime: number, | ||
endTime: number | ||
) => { | ||
const response = await npStart.http.fetch(LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_DATASETS_PATH, { | ||
method: 'POST', | ||
body: JSON.stringify( | ||
getLogEntryAnomaliesDatasetsRequestPayloadRT.encode({ | ||
data: { | ||
sourceId, | ||
timeRange: { | ||
startTime, | ||
endTime, | ||
}, | ||
}, | ||
}) | ||
), | ||
}); | ||
|
||
return pipe( | ||
getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT.decode(response), | ||
fold(throwErrors(createPlainError), identity) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.