mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* fixed merge * fixed typechecks * fixed typechecks Co-authored-by: Thomas P <TPXP@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d4ef3a54d7
commit
9087e164c6
11 changed files with 205 additions and 27 deletions
|
@ -3135,10 +3135,10 @@
|
|||
},
|
||||
{
|
||||
"parentPluginId": "alerting",
|
||||
"id": "def-common.AlertingFrameworkHealth.alertingFrameworkHeath",
|
||||
"id": "def-common.AlertingFrameworkHealth.alertingFrameworkHealth",
|
||||
"type": "Object",
|
||||
"tags": [],
|
||||
"label": "alertingFrameworkHeath",
|
||||
"label": "alertingFrameworkHealth",
|
||||
"description": [],
|
||||
"signature": [
|
||||
{
|
||||
|
|
|
@ -74,6 +74,9 @@ The health API response contains the following properties:
|
|||
| `alerting_framework_health`
|
||||
| This state property has three substates that identify the health of the alerting framework API: `decryption_health`, `execution_health`, and `read_health`.
|
||||
|
||||
| deprecated::`alerting_framework_heath`
|
||||
| This state property has a typo, use `alerting_framework_health` instead. It has three substates that identify the health of the alerting framework API: `decryption_health`, `execution_health`, and `read_health`.
|
||||
|
||||
|===
|
||||
|
||||
`alerting_framework_health` consists of the following properties:
|
||||
|
|
|
@ -45,7 +45,7 @@ The API returns the following:
|
|||
{
|
||||
"isSufficientlySecure":true,
|
||||
"hasPermanentEncryptionKey":true,
|
||||
"alertingFrameworkHeath":{
|
||||
"alertingFrameworkHealth":{
|
||||
"decryptionHealth":{
|
||||
"status":"ok",
|
||||
"timestamp":"2021-02-10T23:35:04.949Z"
|
||||
|
@ -73,12 +73,12 @@ The health API response contains the following properties:
|
|||
| `hasPermanentEncryptionKey`
|
||||
| Return the state `false` if Encrypted Saved Object plugin has not a permanent encryption Key.
|
||||
|
||||
| `alertingFrameworkHeath`
|
||||
| `alertingFrameworkHealth`
|
||||
| This state property has three substates that identify the health of the alerting framework API: `decryptionHealth`, `executionHealth`, and `readHealth`.
|
||||
|
||||
|===
|
||||
|
||||
`alertingFrameworkHeath` consists of the following properties:
|
||||
`alertingFrameworkHealth` consists of the following properties:
|
||||
|
||||
[cols="2*<"]
|
||||
|===
|
||||
|
|
|
@ -24,7 +24,7 @@ export * from './parse_duration';
|
|||
export interface AlertingFrameworkHealth {
|
||||
isSufficientlySecure: boolean;
|
||||
hasPermanentEncryptionKey: boolean;
|
||||
alertingFrameworkHeath: AlertsHealth;
|
||||
alertingFrameworkHealth: AlertsHealth;
|
||||
}
|
||||
|
||||
export const LEGACY_BASE_ALERT_API_PATH = '/api/alerts';
|
||||
|
|
|
@ -97,6 +97,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alerting_framework_heath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alerting_framework_health" instead.',
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
execution_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
read_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alerting_framework_health: {
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
@ -138,6 +154,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alerting_framework_heath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alerting_framework_health" instead.',
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
execution_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
read_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alerting_framework_health: {
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
@ -179,6 +211,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alerting_framework_heath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alerting_framework_health" instead.',
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
execution_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
read_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alerting_framework_health: {
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
@ -220,6 +268,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alerting_framework_heath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alerting_framework_health" instead.',
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
execution_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
read_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alerting_framework_health: {
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
@ -261,6 +325,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alerting_framework_heath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alerting_framework_health" instead.',
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
execution_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
read_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alerting_framework_health: {
|
||||
decryption_health: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
|
|
@ -19,16 +19,23 @@ import { getSecurityHealth } from '../lib/get_security_health';
|
|||
const rewriteBodyRes: RewriteResponseCase<AlertingFrameworkHealth> = ({
|
||||
isSufficientlySecure,
|
||||
hasPermanentEncryptionKey,
|
||||
alertingFrameworkHeath,
|
||||
alertingFrameworkHealth,
|
||||
...rest
|
||||
}) => ({
|
||||
...rest,
|
||||
is_sufficiently_secure: isSufficientlySecure,
|
||||
has_permanent_encryption_key: hasPermanentEncryptionKey,
|
||||
alerting_framework_health: {
|
||||
decryption_health: alertingFrameworkHealth.decryptionHealth,
|
||||
execution_health: alertingFrameworkHealth.executionHealth,
|
||||
read_health: alertingFrameworkHealth.readHealth,
|
||||
},
|
||||
alerting_framework_heath: {
|
||||
decryption_health: alertingFrameworkHeath.decryptionHealth,
|
||||
execution_health: alertingFrameworkHeath.executionHealth,
|
||||
read_health: alertingFrameworkHeath.readHealth,
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alerting_framework_health" instead.',
|
||||
decryption_health: alertingFrameworkHealth.decryptionHealth,
|
||||
execution_health: alertingFrameworkHealth.executionHealth,
|
||||
read_health: alertingFrameworkHealth.readHealth,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -45,7 +52,7 @@ export const healthRoute = (
|
|||
router.handleLegacyErrors(
|
||||
verifyAccessAndContext(licenseState, async function (context, req, res) {
|
||||
try {
|
||||
const alertingFrameworkHeath = await context.alerting.getFrameworkHealth();
|
||||
const alertingFrameworkHealth = await context.alerting.getFrameworkHealth();
|
||||
|
||||
const securityHealth = await getSecurityHealth(
|
||||
async () => (licenseState ? licenseState.getIsSecurityEnabled() : null),
|
||||
|
@ -55,7 +62,7 @@ export const healthRoute = (
|
|||
|
||||
const frameworkHealth: AlertingFrameworkHealth = {
|
||||
...securityHealth,
|
||||
alertingFrameworkHeath,
|
||||
alertingFrameworkHealth,
|
||||
};
|
||||
|
||||
return res.ok({
|
||||
|
|
|
@ -80,6 +80,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alertingFrameworkHeath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alertingFrameworkHealth" instead.',
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
executionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
readHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alertingFrameworkHealth: {
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
@ -121,6 +137,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alertingFrameworkHeath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alertingFrameworkHealth" instead.',
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
executionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
readHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alertingFrameworkHealth: {
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
@ -162,6 +194,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alertingFrameworkHeath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alertingFrameworkHealth" instead.',
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
executionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
readHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alertingFrameworkHealth: {
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
@ -203,6 +251,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alertingFrameworkHeath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alertingFrameworkHealth" instead.',
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
executionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
readHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alertingFrameworkHealth: {
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
@ -244,6 +308,22 @@ describe('healthRoute', () => {
|
|||
expect(await handler(context, req, res)).toStrictEqual({
|
||||
body: {
|
||||
alertingFrameworkHeath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
_deprecated: 'This state property has a typo, use "alertingFrameworkHealth" instead.',
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
executionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
readHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
},
|
||||
},
|
||||
alertingFrameworkHealth: {
|
||||
decryptionHealth: {
|
||||
status: HealthStatus.OK,
|
||||
timestamp: currentDate,
|
||||
|
|
|
@ -32,7 +32,7 @@ export function healthRoute(
|
|||
}
|
||||
trackLegacyRouteUsage('health', usageCounter);
|
||||
try {
|
||||
const alertingFrameworkHeath = await context.alerting.getFrameworkHealth();
|
||||
const alertingFrameworkHealth = await context.alerting.getFrameworkHealth();
|
||||
|
||||
const securityHealth = await getSecurityHealth(
|
||||
async () => (licenseState ? licenseState.getIsSecurityEnabled() : null),
|
||||
|
@ -42,11 +42,18 @@ export function healthRoute(
|
|||
|
||||
const frameworkHealth: AlertingFrameworkHealth = {
|
||||
...securityHealth,
|
||||
alertingFrameworkHeath,
|
||||
alertingFrameworkHealth,
|
||||
};
|
||||
|
||||
return res.ok({
|
||||
body: frameworkHealth,
|
||||
body: {
|
||||
...frameworkHealth,
|
||||
alertingFrameworkHeath: {
|
||||
// Legacy: pre-v8.0 typo
|
||||
...alertingFrameworkHealth,
|
||||
_deprecated: 'This state property has a typo, use "alertingFrameworkHealth" instead.',
|
||||
},
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
return res.badRequest({ body: error });
|
||||
|
|
|
@ -61,7 +61,7 @@ describe('health check', () => {
|
|||
useKibanaMock().services.http.get = jest.fn().mockResolvedValue({
|
||||
is_sufficiently_secure: true,
|
||||
has_permanent_encryption_key: true,
|
||||
alerting_framework_heath: {
|
||||
alerting_framework_health: {
|
||||
decryption_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
execution_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
read_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
|
@ -85,7 +85,7 @@ describe('health check', () => {
|
|||
useKibanaMock().services.http.get = jest.fn().mockImplementation(async () => ({
|
||||
is_sufficiently_secure: false,
|
||||
has_permanent_encryption_key: true,
|
||||
alerting_framework_heath: {
|
||||
alerting_framework_health: {
|
||||
decryption_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
execution_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
read_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
|
@ -121,7 +121,7 @@ describe('health check', () => {
|
|||
useKibanaMock().services.http.get = jest.fn().mockImplementation(async () => ({
|
||||
is_sufficiently_secure: true,
|
||||
has_permanent_encryption_key: false,
|
||||
alerting_framework_heath: {
|
||||
alerting_framework_health: {
|
||||
decryption_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
execution_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
read_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
|
@ -157,7 +157,7 @@ describe('health check', () => {
|
|||
useKibanaMock().services.http.get = jest.fn().mockImplementation(async () => ({
|
||||
is_sufficiently_secure: false,
|
||||
has_permanent_encryption_key: false,
|
||||
alerting_framework_heath: {
|
||||
alerting_framework_health: {
|
||||
decryption_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
execution_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
read_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('alertingFrameworkHealth', () => {
|
|||
http.get.mockResolvedValueOnce({
|
||||
is_sufficiently_secure: true,
|
||||
has_permanent_encryption_key: true,
|
||||
alerting_framework_heath: {
|
||||
alerting_framework_health: {
|
||||
decryption_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
execution_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
read_health: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
|
@ -22,7 +22,7 @@ describe('alertingFrameworkHealth', () => {
|
|||
});
|
||||
const result = await alertingFrameworkHealth({ http });
|
||||
expect(result).toEqual({
|
||||
alertingFrameworkHeath: {
|
||||
alertingFrameworkHealth: {
|
||||
decryptionHealth: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
executionHealth: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
readHealth: { status: 'ok', timestamp: '2021-04-01T21:29:22.991Z' },
|
||||
|
|
|
@ -9,7 +9,7 @@ import { AsApiContract, RewriteRequestCase } from '../../../../../actions/common
|
|||
import { AlertingFrameworkHealth, AlertsHealth } from '../../../../../alerting/common';
|
||||
import { BASE_ALERTING_API_PATH } from '../../constants';
|
||||
|
||||
const rewriteAlertingFrameworkHeath: RewriteRequestCase<AlertsHealth> = ({
|
||||
const rewriteAlertingFrameworkHealth: RewriteRequestCase<AlertsHealth> = ({
|
||||
decryption_health: decryptionHealth,
|
||||
execution_health: executionHealth,
|
||||
read_health: readHealth,
|
||||
|
@ -24,12 +24,13 @@ const rewriteAlertingFrameworkHeath: RewriteRequestCase<AlertsHealth> = ({
|
|||
const rewriteBodyRes: RewriteRequestCase<AlertingFrameworkHealth> = ({
|
||||
is_sufficiently_secure: isSufficientlySecure,
|
||||
has_permanent_encryption_key: hasPermanentEncryptionKey,
|
||||
alerting_framework_heath: alertingFrameworkHeath,
|
||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||
alerting_framework_health: alertingFrameworkHealth,
|
||||
...res
|
||||
}: AsApiContract<AlertingFrameworkHealth>) => ({
|
||||
isSufficientlySecure,
|
||||
hasPermanentEncryptionKey,
|
||||
alertingFrameworkHeath,
|
||||
alertingFrameworkHealth,
|
||||
...res,
|
||||
});
|
||||
|
||||
|
@ -41,11 +42,11 @@ export async function alertingFrameworkHealth({
|
|||
const res = await http.get<AsApiContract<AlertingFrameworkHealth>>(
|
||||
`${BASE_ALERTING_API_PATH}/_health`
|
||||
);
|
||||
const alertingFrameworkHeath = rewriteAlertingFrameworkHeath(
|
||||
res.alerting_framework_heath as unknown as AsApiContract<AlertsHealth>
|
||||
const alertingFrameworkHealthRewrited = rewriteAlertingFrameworkHealth(
|
||||
res.alerting_framework_health as unknown as AsApiContract<AlertsHealth>
|
||||
);
|
||||
return {
|
||||
...rewriteBodyRes(res),
|
||||
alertingFrameworkHeath,
|
||||
alertingFrameworkHealth: alertingFrameworkHealthRewrited,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue