Skip to content

Commit 78e1f7a

Browse files
committed
wip
1 parent 3a00241 commit 78e1f7a

File tree

8 files changed

+134
-187
lines changed

8 files changed

+134
-187
lines changed

x-pack/platform/packages/shared/kbn-slo-schema/src/rest_specs/routes/find_definition.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import { toBooleanRt } from '@kbn/io-ts-utils/src/to_boolean_rt';
88
import * as t from 'io-ts';
9-
import { healthStatusSchema, sloDefinitionSchema, transformHealthSchema } from '../../schema';
9+
import { sloDefinitionSchema, transformHealthSchema } from '../../schema';
1010

1111
const findSloDefinitionsParamsSchema = t.partial({
1212
query: t.partial({
@@ -21,7 +21,7 @@ const findSloDefinitionsParamsSchema = t.partial({
2121

2222
const healthMetadataSchema = t.partial({
2323
health: t.type({
24-
overall: healthStatusSchema,
24+
isProblematic: t.boolean,
2525
rollup: transformHealthSchema,
2626
summary: transformHealthSchema,
2727
}),

x-pack/platform/packages/shared/kbn-slo-schema/src/rest_specs/routes/get_slo_health.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77
import * as t from 'io-ts';
8-
import { healthStatusSchema, sloIdSchema, stateSchema, transformHealthSchema } from '../../schema';
8+
import { sloIdSchema, transformHealthSchema } from '../../schema';
99
import { allOrAnyString } from '../../schema/common';
1010

1111
const fetchSLOHealthResponseSchema = t.array(
@@ -14,11 +14,10 @@ const fetchSLOHealthResponseSchema = t.array(
1414
sloInstanceId: allOrAnyString,
1515
sloRevision: t.number,
1616
sloName: t.string,
17-
state: stateSchema,
1817
health: t.type({
19-
overall: transformHealthSchema,
20-
rollup: healthStatusSchema,
21-
summary: healthStatusSchema,
18+
isProblematic: t.boolean,
19+
rollup: transformHealthSchema,
20+
summary: transformHealthSchema,
2221
}),
2322
})
2423
);
@@ -33,4 +32,4 @@ type FetchSLOHealthResponse = t.OutputOf<typeof fetchSLOHealthResponseSchema>;
3332
type FetchSLOHealthParams = t.TypeOf<typeof fetchSLOHealthParamsSchema.props.body>;
3433

3534
export { fetchSLOHealthParamsSchema, fetchSLOHealthResponseSchema };
36-
export type { FetchSLOHealthResponse, FetchSLOHealthParams };
35+
export type { FetchSLOHealthParams, FetchSLOHealthResponse };

x-pack/platform/packages/shared/kbn-slo-schema/src/schema/health.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@ import * as t from 'io-ts';
1414
* If types need to diverge, they should be split into separate files.
1515
*/
1616

17-
const healthStatusSchema = t.union([t.literal('healthy'), t.literal('unhealthy')]);
18-
19-
const transformHealthSchema = t.type({
20-
status: t.union([t.literal('healthy'), t.literal('unhealthy'), t.literal('missing')]),
21-
state: t.union([t.literal('stopped'), t.literal('started'), t.literal('unavailable')]),
22-
});
23-
24-
const stateSchema = t.union([
25-
t.literal('no_data'),
26-
t.literal('indexing'),
27-
t.literal('running'),
28-
t.literal('stale'),
17+
const transformHealthSchema = t.intersection([
18+
t.type({
19+
isProblematic: t.boolean,
20+
missing: t.boolean,
21+
status: t.union([t.literal('healthy'), t.literal('unhealthy'), t.literal('unavailable')]),
22+
state: t.union([
23+
t.literal('stopped'),
24+
t.literal('started'),
25+
t.literal('stopping'),
26+
t.literal('aborting'),
27+
t.literal('failed'),
28+
t.literal('indexing'),
29+
t.literal('unavailable'),
30+
]),
31+
}),
32+
t.partial({
33+
stateMatches: t.boolean,
34+
}),
2935
]);
3036

31-
export { transformHealthSchema, healthStatusSchema, stateSchema };
37+
export { transformHealthSchema };

x-pack/solutions/observability/plugins/slo/public/pages/slo_details/components/slo_health_callout.tsx

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { i18n } from '@kbn/i18n';
1111
import { FormattedMessage } from '@kbn/i18n-react';
1212
import kbnRison from '@kbn/rison';
1313
import type { SLOWithSummaryResponse } from '@kbn/slo-schema';
14-
import { values } from 'lodash';
1514
import React from 'react';
1615
import { getSLOSummaryTransformId, getSLOTransformId } from '../../../../common/constants';
1716
import { useActionModal } from '../../../context/action_modal';
@@ -57,7 +56,7 @@ export function SloHealthCallout({ slo }: { slo: SLOWithSummaryResponse }) {
5756
}
5857

5958
const health = data[0].health;
60-
if (health.overall === 'healthy') {
59+
if (!health.isProblematic) {
6160
return null;
6261
}
6362

@@ -67,20 +66,7 @@ export function SloHealthCallout({ slo }: { slo: SLOWithSummaryResponse }) {
6766
const rollupUrl = getUrl(rollupTransformId);
6867
const summaryUrl = getUrl(summaryTransformId);
6968

70-
const rollup = {
71-
unhealthy: health.rollup.status === 'unhealthy',
72-
missing: health.rollup.status === 'missing',
73-
stopped: health.rollup.transformState === 'stopped',
74-
};
75-
const summary = {
76-
unhealthy: health.summary.status === 'unhealthy',
77-
missing: health.summary.status === 'missing',
78-
stopped: health.summary.transformState === 'stopped',
79-
};
80-
81-
const rollupHasIssue = values(rollup).some(Boolean);
82-
const summaryHasIssue = values(summary).some(Boolean);
83-
const count = [rollupHasIssue, summaryHasIssue].filter(Boolean).length;
69+
const count = [health.rollup.isProblematic, health.summary.isProblematic].filter(Boolean).length;
8470

8571
return (
8672
<EuiCallOut
@@ -98,20 +84,21 @@ export function SloHealthCallout({ slo }: { slo: SLOWithSummaryResponse }) {
9884
values={{ count }}
9985
/>
10086
<ul>
101-
{(rollup.unhealthy || rollup.stopped) && !!rollupUrl && (
102-
<li>
103-
<ContentWithInspectCta
104-
textSize="s"
105-
content={
106-
rollup.unhealthy
107-
? getUnhealthyText(rollupTransformId)
108-
: getStoppedText(rollupTransformId)
109-
}
110-
url={rollupUrl}
111-
/>
112-
</li>
113-
)}
114-
{rollup.missing && (
87+
{(health.rollup.status === 'unhealthy' || health.rollup.stateMatches === false) &&
88+
!!rollupUrl && (
89+
<li>
90+
<ContentWithInspectCta
91+
textSize="s"
92+
content={
93+
health.rollup.status === 'unhealthy'
94+
? getUnhealthyText(rollupTransformId)
95+
: getStateConflictText(rollupTransformId)
96+
}
97+
url={rollupUrl}
98+
/>
99+
</li>
100+
)}
101+
{health.rollup.missing && (
115102
<li>
116103
<ContentWithResetCta
117104
textSize="s"
@@ -121,20 +108,21 @@ export function SloHealthCallout({ slo }: { slo: SLOWithSummaryResponse }) {
121108
</li>
122109
)}
123110

124-
{(summary.unhealthy || summary.stopped) && !!summaryUrl && (
125-
<li>
126-
<ContentWithInspectCta
127-
textSize="s"
128-
content={
129-
summary.unhealthy
130-
? getUnhealthyText(summaryTransformId)
131-
: getStoppedText(summaryTransformId)
132-
}
133-
url={summaryUrl}
134-
/>
135-
</li>
136-
)}
137-
{summary.missing && (
111+
{(health.summary.status === 'unhealthy' || health.summary.stateMatches === false) &&
112+
!!summaryUrl && (
113+
<li>
114+
<ContentWithInspectCta
115+
textSize="s"
116+
content={
117+
health.summary.status === 'unhealthy'
118+
? getUnhealthyText(summaryTransformId)
119+
: getStateConflictText(rollupTransformId)
120+
}
121+
url={summaryUrl}
122+
/>
123+
</li>
124+
)}
125+
{health.summary.missing && (
138126
<li>
139127
<ContentWithResetCta
140128
textSize="s"
@@ -156,9 +144,9 @@ const getUnhealthyText = (transformId: string) =>
156144
values: { transformId },
157145
});
158146

159-
const getStoppedText = (transformId: string) =>
160-
i18n.translate('xpack.slo.sloDetails.healthCallout.stoppedTransformText', {
161-
defaultMessage: '{transformId} (stopped)',
147+
const getStateConflictText = (transformId: string) =>
148+
i18n.translate('xpack.slo.sloDetails.healthCallout.transformStateConflictText', {
149+
defaultMessage: '{transformId} (conflicting state)',
162150
values: { transformId },
163151
});
164152

x-pack/solutions/observability/plugins/slo/public/pages/slo_management/components/slo_management_table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export function SloManagementTable() {
278278
);
279279
}
280280

281-
return item.health.overall === 'healthy' ? (
281+
return !item.health.isProblematic ? (
282282
<EuiHealth color="success">
283283
{i18n.translate('xpack.slo.sloManagementTable.columns.health.healthy', {
284284
defaultMessage: 'Healthy',

x-pack/solutions/observability/plugins/slo/public/pages/slos/components/health_callout/health_callout.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export function HealthCallout({ sloList = [] }: { sloList: SLOWithSummaryRespons
2323
);
2424
const [isOpen, setIsOpen] = useState(false);
2525

26+
const dismiss = () => {
27+
setShowCallOut(false);
28+
sessionStorage.setItem('slo_health_callout_hidden', 'true');
29+
};
30+
2631
if (!showCallOut) {
2732
return null;
2833
}
@@ -31,18 +36,13 @@ export function HealthCallout({ sloList = [] }: { sloList: SLOWithSummaryRespons
3136
return null;
3237
}
3338

34-
const problematicSloList = results.filter((result) => result.health.overall !== 'healthy');
39+
const problematicSloList = results.filter((result) => result.health.isProblematic);
3540
if (problematicSloList.length === 0) {
3641
return null;
3742
}
3843

3944
const deduplicatedList = uniqBy(problematicSloList, (item) => item.sloId);
4045

41-
const dismiss = () => {
42-
setShowCallOut(false);
43-
sessionStorage.setItem('slo_health_callout_hidden', 'true');
44-
};
45-
4646
return (
4747
<EuiCallOut
4848
data-test-subj="sloHealthCallout"

x-pack/solutions/observability/plugins/slo/server/domain/models/health.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
* 2.0.
66
*/
77

8-
import type { healthStatusSchema, stateSchema, transformHealthSchema } from '@kbn/slo-schema';
8+
import type { transformHealthSchema } from '@kbn/slo-schema';
99
import type * as t from 'io-ts';
1010

1111
type TransformHealth = t.OutputOf<typeof transformHealthSchema>;
12-
type HealthStatus = t.OutputOf<typeof healthStatusSchema>;
13-
type State = t.OutputOf<typeof stateSchema>;
1412

15-
export type { TransformHealth, HealthStatus, State };
13+
export type { TransformHealth };

0 commit comments

Comments
 (0)